Spire.PDFViewer is a powerful PDF Viewer component for .NET. It allows developers to load PDF document from stream, file and byte array.

Sun Mar 15, 2020 9:07 pm

I am using Free PdfViewer 4.1 and I can't get printing working.

Here is my code:

Code: Select all
    Private Sub ImprimirToolStripButton_Click(sender As Object, e As EventArgs) Handles ImprimirToolStripButton.Click

        If Me.PdfDocumentViewer1.PageCount > 0 Then
            Dim dialogPrint As PrintDialog = New PrintDialog()
            Dim myDocument As New PrintDocument
            With dialogPrint
                .AllowPrintToFile = True
                .AllowSomePages = True
                .Document = myDocument
                .PrinterSettings.MinimumPage = 1
                .PrinterSettings.MaximumPage = PdfDocumentViewer1.PageCount
                .PrinterSettings.FromPage = 1
                .PrinterSettings.ToPage = PdfDocumentViewer1.PageCount
                If .ShowDialog() = DialogResult.OK Then
                    PdfDocumentViewer1.PrintSettings.SelectPageRange(.PrinterSettings.FromPage, dialogPrint.PrinterSettings.ToPage)
                    PdfDocumentViewer1.PrintSettings.Copies = .PrinterSettings.Copies
                    PdfDocumentViewer1.PrintSettings.PaperSize = .Document.DefaultPageSettings.PaperSize
                    'PdfDocumentViewer1.PrintSettings.Landscape = .Document.DefaultPageSettings.Landscape
                    'PdfDocumentViewer1.PrintSettings.Color = .Document.DefaultPageSettings.Color
                    PdfDocumentViewer1.PrintSettings.Landscape = True
                    PdfDocumentViewer1.PrintSettings.Color = False
                    PdfDocumentViewer1.PrintSettings.PrinterName = .PrinterSettings.PrinterName
                    PdfDocumentViewer1.PrintDoc()
                End If
            End With
        End If

    End Sub


Document is printed in the selected printer, but Landscape and Color are ignored, and I get a coloured and vertical print instead of grayscale and lanscape.

Thank you in advance.

Alex

alexcasals
 
Posts: 3
Joined: Sat Mar 14, 2020 3:10 pm

Mon Mar 16, 2020 4:07 am

Hi Alex,

Thanks for your inquiry.
Regarding landscape printing, please set the parameter “autoPortraitOrLandscape” to false in SelectSinglePageLayout method.
Code: Select all
pdfDocumentViewer1.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, False)

And as for grayscale printing, I tested your code with our physical color printer(HP Color LaserJet MFP M281fdw), but the print result was grayscale instead of color. Attached are my input file and my print result.

To help us further look into your issue, please provide your input file as well as your printer name. Besides, I also suggest that you use Adobe to print your file directly in grayscale to see if this issue is caused by the printer. Look forward to your feedback.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1573
Joined: Tue Jul 09, 2019 2:22 am

Tue Mar 17, 2020 2:58 pm

Hi Rachel,

Thanks for your quick answer.

Lanscape is now working, after including the code you provided.

Unfortunately, grayscale is still ignored. It happens with every pdf I have tried. My printer is an HP Color Laserjet 1600 (using windows 7 drivers under windows 10). I will try with another printer ASAP.

Greetings,

Alex Casals

alexcasals
 
Posts: 3
Joined: Sat Mar 14, 2020 3:10 pm

Wed Mar 18, 2020 2:15 am

Hello,

Thanks for your response. I will wait for your further feedback.
Besides, what's the print result when directly printing with Adobe? If it is still color instead of grayscale, there may be something wrong with your printer settings.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1573
Joined: Tue Jul 09, 2019 2:22 am

Thu Mar 19, 2020 12:43 am

Using Adobe:

- if I check "Print in grayscale" in the adobe printdialog, I get it color printed.

- But if I go to "Properties" button in the same printdialog, and then in the printer properties I select grayscale, I get it grayscale printed.

It seems that the HP color laserjet 1600 printer driver (I must remember the driver is not Windows 10 approved), does not read document settings from printdialog, but It uses printer defaultsettings. Not sure if I'm explaining well.

I can't test code in another printer because now in Spain we are encouraged to stay at home. As soon this critical situation finishes, I'll try.

Alex

alexcasals
 
Posts: 3
Joined: Sat Mar 14, 2020 3:10 pm

Thu Mar 19, 2020 3:51 am

Hello,

Thanks for your feedback.
Sorry we don't have the same printer as yours (HP color laserjet 1600) to fully simulate your test environment. But I found that your printer model is relatively old, on HP ’s official website, I only found the printer driver that is suitable for Windows 8 or lower operating systems. And you mentioned that you test in Windows 10, maybe this caused the problem. Thus, I prefer to recommend that you perform the print test on Windows 7.
Meanwhile, you could also test with another printer after the critical situation is over. Look forward to your reply and hope you are well.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1573
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDFViewer