Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Sep 15, 2022 9:58 am

Hello,

I tried the new silent printing options in Spire.Office for WPF. I use the same printers with the same configuration that prints PDF in A6 size. 
It prints fine (A6) in the majority of printers and in Adobe (with the option "Automatically resize to fit paper" selected), but it prints as A4 on two printers. I tried page size options, but it only cut the document - scale was still for A4. I found some similar problems on the forum, but the solution -
Code: Select all
 pdf.PageScaling = PdfPrintPageScaling.ActualSize

is not available in this version, I think.

My code:
Code: Select all
dim By() as byte
            Dim doc As New PdfDocument()
            doc.LoadFromBytes(By)
            Dim H As New Print.PdfPrintSettings With {.PrinterName = PrinterName}
            doc.Print(H)


Is there any way to 'Automatically scale to fit paper' in code? Maybe there's some similar option to 'PdfPrintPageScaling.ActualSize'? Since the printers are identical and configured the same way, I am unsure of the origin of the scale problems.

Thank you in advance,
Jacek

j.strychalski
 
Posts: 9
Joined: Tue Apr 19, 2022 8:05 am

Fri Sep 16, 2022 6:59 am

Hello,

Thanks for your inquiry.
First, please reference the dll from the net folder to your WPF project, such as “NET 4.0” folder, as shown in the screenshot below. And please refer to the following code to achieve your requirement.
If you have any issue, just feel free to contact us.

Code: Select all
 Dim pdf As PdfDocument = New PdfDocument()
    pdf.LoadFromBytes(bytes)
    pdf.PrintSettings.PrinterName = "Your Print Name"
    pdf.PrintSettings.SelectPageRange(1, 1)
    pdf.PrintSettings.PaperSize = PdfPaperSizes.A6
    pdf.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, True)
    pdf.Print()
pdf.Close()


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Thu Oct 06, 2022 10:25 am

Hello Abel,

I just ran your code and used the recommended DLLs. Printing works fine, but now I have some licensing issues.
I previously used

Code: Select all
Dim RE As New Spire.Doc.LicenseProvider.SetLicenseKey("my_key")


However, it doesn't seem to work now.
Is Spire.Office for WPF not a suitable license for the NET4.0 library, or is there another way to insert license into my code?

Sincerely,
Jacek

j.strychalski
 
Posts: 9
Joined: Tue Apr 19, 2022 8:05 am

Fri Oct 07, 2022 2:39 am

Hello,

Thank you for your feedback.
According to the information you provided, you want to print a PDF document, but you use the key of Spire.Doc's license, so the printed result file will have a red warning message. In addition, please use the following code to use the key of the license:
Code: Select all
Spire.License.LicenseProvider.SetLicenseKey("your license key")

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF