Please Help: Using BindPdf and Setting the Resolution

I’ve found online that the Resolution property must be set PRIOR to the BindPdf() call in order for the resolution to work when calling .PrintDocumentWithSettings() when using Aspose.Pdf.Kit. **This works.







**This doesn’t work

I am now using the latest PdfViewer within Aspose.Pdf.Facades and I don’t appear to see a difference in the resolution regardless of when its set. Can someone shed some light on when/how this property can be used?



Thanks,

Chris

Hi Chris,


Thanks for your inquiry. We have noticed that setting resolution property of PdfViewer Object has no impact on the output file. We have logged an investigation ticket PDFNEWNET-37737 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

Is there any additional information you can give me regarding the time frame (or priority) to fix it? I have decisions to make based on your answer.

Hi Chris,


Thanks for your inquiry. I am afraid we can not share any ETA or findings at the moment as your issue is recently noticed and pending for investigation. As soon as investigation of the issue is completed then we will be in good position to share an ETA/findings.

We are sorry for the inconvenience caused…

Best Regards,

@AsposeUser44

This is not a bug: the PdfViewer.Resolution property is not meant to setting the printer resolution. Rather, it is used in page-to-image conversion scenarios: when the PdfViewer.PrintAsImage property is set to true, or when you directly call methods PdfViewer.DecodePage() or PdfViewer.DecodeAllPages(). We will update the property description accordingly to avoid further misunderstanding.

In order to set the printer resolution, please use the PageSettings.PrinterResolution property:

//create PdfViewer object
PdfViewer viewer = new PdfViewer();

//open input PDF file
//viewer.OpenPdfFile(myDir+"input.pdf");
viewer.BindPdf(myDir + "PCL2PDF-out.pdf");

viewer.AutoResize = true;
viewer.AutoRotate = true;
// viewer.ScaleFactor = 0.5f; // decrease print size to 50%
// viewer.AutoRotateMode = AutoRotateMode.AntiClockWise;
viewer.PrintPageDialog = false;

System.Drawing.Printing.PrinterSettings nativePrinterSettings = new System.Drawing.Printing.PrinterSettings();
Aspose.Pdf.Printing.PrinterSettings ps = new Aspose.Pdf.Printing.PrinterSettings();
Aspose.Pdf.Printing.PageSettings pgs = new Aspose.Pdf.Printing.PageSettings();

pgs.PaperSize = new Aspose.Pdf.Printing.PaperSize("A4", 827, 1169);
pgs.Margins = new Aspose.Pdf.Devices.Margins(0, 0, 0, 0);
pgs.PaperSource = nativePrinterSettings.PaperSources[1].ToAsposePaperSource();

// Set printer resolution to 'Draft'
pgs.PrinterResolution = nativePrinterSettings.PrinterResolutions
    .Cast<System.Drawing.Printing.PrinterResolution>()
    .First(res => res.Kind == System.Drawing.Printing.PrinterResolutionKind.Draft)
    .ToAsposePrinterResolution();
ps.PrinterName = "Microsoft XPS Document Writer";
//ps.PrinterName = "Adobe Pdf";
ps.PrintRange = PrintRange.SomePages;

ps.FromPage = 1; //from;
ps.ToPage = 2; // to;
ps.PrintToFile = true;
ps.PrintFileName = myDir + "PDFtoXPS_test150.xps";
//ps.PrintFileName = myDir + "AsposePrint.pdf";
viewer.PrintDocumentWithSettings(pgs, ps);
//close the PDF file after priting
viewer.Close();

Also please note that software printers (Microsoft XPS Document Writer, Adobe PDF and so on) may ignore the PrinterResolution property and generate identical files for different resolutions set. Hardware printers should honor a set resolution.