Set print orientation to landscape

后端 未结 2 1733
无人共我
无人共我 2021-01-12 12:20

i already can create a print to print a file in my windows forms. However, whenever i add this code:

printDialog.PrinterSettings.DefaultPageSettings.Landscap         


        
相关标签:
2条回答
  • 2021-01-12 12:37

    The pdfprinting.net library is excellent for implementing the print functionality and be productive. Here is the simple code snippet to set print orientation to landscape(pdfPrint.IsLandscape = true;)

    var pdfPrint = new PdfPrint("demoCompany", "demoKey");
    string pdfFile = @"c:\test\test.pdf";
    pdfPrint.IsLandscape = true;
    
    int numberOfPages = pdfPrint.GetNumberOfPages(pdfFile);
    var status = pdfPrint.Print(pdfFile);
    if (status == PdfPrint.Status.OK) { 
         // check the result status of the Print method
         // your code here
    }
    // if you have pdf document in byte array that is also supported
    byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
    status = pdfPrint.Print(pdfFile);
    
    0 讨论(0)
  • 2021-01-12 12:53

    try setting the Landscape of PrintDocument as follows,

    printDocument1.DefaultPageSettings.Landscape = true;
    
    0 讨论(0)
提交回复
热议问题