We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set Print Dialog Presets while printing PDF document using Aspose.PDF for .NET

Can we set print dialog presets on pdf using Aspose.Pdf?


(In
Adobe Acrobat choose File > Properties, and click the Advanced
tab. In the Print Dialog Presets section, set options and click OK.)
I want to make it duplex and its by default set to simplex. I don’t want to print it though, i just want to set it in the properties.
Let me know if that is possible.

Thanks

Hi Ujjwal,


Thanks for your inquiry. I’m afraid the requested feature is not supported in Aspsoe.Pdf at the moment. However, I’ve logged a feature request as PDFNEWNET-35297 in our issue tracking system to set PDF document DuplexMode property. We will notify you via this forum thread as soon as it gets available.

Moreover, you can set Duplex setting at the time of printing using PdfViewer class of Aspose.Pdf.Facades as following.

PdfViewer viewer = new PdfViewer();

viewer.OpenPdfFile(“input.pdf”);


//create PrinterSettings object and set properties

System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();

printerSettings.PrinterName = “HP Officejet 4300 Series”;

printerSettings.Duplex = System.Drawing.Printing.Duplex.Default;

printerSettings.Copies = 2;

printerSettings.FromPage = 3;

printerSettings.ToPage = 5;


//create PageSettings object and set properties

System.Drawing.Printing.PageSettings pageSetting = new System.Drawing.Printing.PageSettings();

pageSetting.Landscape = true;


//print document using above settings

viewer.PrintDocumentWithSettings(pageSetting, printerSettings);

viewer.Close();


Sorry for the inconvenience faced.

Best Regards,

@ubshrest

In order to set Print Dialog Presets using Aspose.PDF for .NET, please use following code snippet with the latest version of the API:

Set Print Dialog Presets using Aspose.PDF

string outputFile = @"c:\35297.pdf";
using (Document doc = new Document())
{
doc.Pages.Add();
doc.Duplex = PrintDuplex.DuplexFlipLongEdge;
doc.Save(outputFile);
}

Please also take into account that correct code snippet for PdfContentEditor will be next:

string outputFile = @"c:\old_file.pdf";
string outputFile1 = @"c:\new_file.pdf";
using (PdfContentEditor ed = new PdfContentEditor())
{
ed.BindPdf(outputFile);
if ((ed.GetViewerPreference() & ViewerPreference.DuplexFlipShortEdge) > 0)
{
Console.WriteLine("The file has duplex flip short edge");
}
ed.ChangeViewerPreference(ViewerPreference.DuplexFlipShortEdge);
ed.Save(outputFile1);
}