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.

Wed Dec 04, 2019 2:46 pm

Hi, I can't seem to change the resolution when I want to print a pdf.
doc.PrintSettings.PrinterResolutionKind = PdfPrinterResolutionKind.High; does nothing, I always get a PdfPrinterResolutionKind.Draft.
I'm also wandering why I cant't just copy my PrinterSettings into your PrintSettings object. Now I have to map all the properties from my PrinterSettings.
Why is doc.PrintDocument.PrinterSettings obsolete? Is there a better way to map these settings?

[email protected]
 
Posts: 5
Joined: Mon May 13, 2019 11:38 am

Thu Dec 05, 2019 10:58 am

Hi,

Thanks for your inquiry.
To help us investigate your issue accurately, please offer us the following information.
1. Your input Pdf file.
2. The printed result file.
3. The complete code.
4. The printer information.

You could upload them here or send us([email protected]) via email.

We have made an adjustment of the print function. Now please use the properties in doc.PrintSettings while printing. If you couldn't find the properties you want, please tell us the detailed information, then we will make a further investigation and offer you a solution.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Tue Dec 10, 2019 8:15 am

I made a project to illustrate:

using Spire.Pdf;
using Spire.Pdf.Print;
using System;
using System.Drawing.Printing;
using System.IO;
using System.Windows.Forms;

namespace SpireTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
var pdfArray = File.ReadAllBytes("Test.pdf");
var printerSettings = new PrinterSettings();
// change some settings, simple version
// normally I would get this from an InPtr (devmode structure)
// printerSettings.SetHdevmode(devModeData)
printerSettings.DefaultPageSettings.Landscape = true;
printerSettings.DefaultPageSettings.Color = true;
printerSettings.DefaultPageSettings.PaperSize = new PaperSize() { RawKind = 11, PaperName = "A5", Height = 827, Width = 583 };
printerSettings.DefaultPageSettings.PrinterResolution = new PrinterResolution() { Kind = PrinterResolutionKind.High };
using (var doc = new PdfDocument(pdfArray))
{
doc.PrintSettings.Landscape = printerSettings.DefaultPageSettings.Landscape;
doc.PrintSettings.Color = printerSettings.DefaultPageSettings.Color;
doc.PrintSettings.PaperSize = printerSettings.DefaultPageSettings.PaperSize;
doc.PrintSettings.PrinterResolutionKind = MapPrinterResolutionsForDocument(printerSettings); //doc.PrintSettings.PrinterResolutionKind has no getter ?
//doc.PrintSettings.PrinterResolutionKind = PdfPrinterResolutionKind.Medium; // even hard coded doesn't work
doc.Print(); // resolution always ends up being 'Draft' see properties printed pdf
doc.Close();
}
}

private PdfPrinterResolutionKind MapPrinterResolutionsForDocument(PrinterSettings printerSettings)
{
PdfPrinterResolutionKind retVal = default;
var resolution = printerSettings.DefaultPageSettings.PrinterResolution;
switch (resolution.Kind)
{
case PrinterResolutionKind.High:
retVal = PdfPrinterResolutionKind.High;
break;
case PrinterResolutionKind.Medium:
retVal = PdfPrinterResolutionKind.Medium;
break;
case PrinterResolutionKind.Low:
retVal = PdfPrinterResolutionKind.Low;
break;
case PrinterResolutionKind.Draft:
retVal = PdfPrinterResolutionKind.Draft;
break;
case PrinterResolutionKind.Custom:
retVal = PdfPrinterResolutionKind.Custom;
break;
}
return retVal;
}
}
}

[email protected]
 
Posts: 5
Joined: Mon May 13, 2019 11:38 am

Tue Dec 10, 2019 10:11 am

Hi,

Thanks for your reply.
Yes, there is no Get property for doc.PrintSettings.PrinterResolutionKind. We will add it later. Once it is done, we will let you know.
I am confused about the meaning of "resolution always ends up being 'Draft' see properties printed pdf". Could you please describe it in detail?

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Tue Dec 10, 2019 10:38 am

Hi,
If you print a document it ends up in the print queue of your printer. If you right click on that print job you can see the properties of that job with which the printer will print that document. I can see Color = true, Landscape = true and under advanced I can see Papersize = A5 but resolution is always Draft. Which means that I can't print documents with a higher resolution than Draft, even if the printer supports this.
So it doesn't matter what I tell the PrinterResolutionKind to be, it will always be Draft.

[email protected]
 
Posts: 5
Joined: Mon May 13, 2019 11:38 am

Wed Dec 11, 2019 8:38 am

Hi,

Thanks for your reply.
I tested your case and didn't find the same issue as yours, but I found the resolution of the printing Pdf file will not have any changes whatever I set for it. I have logged this issue into our bug tracking system. Once there is any progress about it, we will inform you immediately.
Sorry for the inconvenience caused.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Thu Jan 09, 2020 11:26 am

Hi,

Hope you are doing well.
Glad to inform you that the Get property for doc.PrintSettings.PrinterResolutionKind has been finished in Spire.PDF Pack Version:6.1. Welcome to download and test it from the following links:
Our website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
NuGet link: https://www.nuget.org/packages/Spire.PDF/6.1.4

And below is the code for you.
Code: Select all
            //get the vaule of PrinterResolutionKind
            PdfPrinterResolutionKind a = doc.PrintSettings.PrinterResolutionKind;

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Wed Jan 15, 2020 9:49 am

You fixed it. Thanks.

[email protected]
 
Posts: 5
Joined: Mon May 13, 2019 11:38 am

Wed Jan 15, 2020 10:22 am

Hi,

Thanks for your feedback.
Any question, welcome to contact us.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Return to Spire.PDF