Specify Print dialog presets during PDF printing with Aspose.PDF for .NET

Can we set print dialog presets on pdf using Aspose.Pdf.Kit (or Aspose.Pdf)?


(In Adobe Acrobat choose File > Properties, and click the Advanced tab. In the Print Dialog Presets section, set options and click OK.)
<br><span id="ctl00_bcr_up___TextboxLastName">Hi Svensson,<br><br>You can use <a href="http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.pdfviewer.html">PdfViewer</a> class of Aspose.Pdf.Kit to print a PDF file. This class helps you utilize the .NET classes like PrinterSettings and PageSettings to set all the required attributes before printing. Please have a look at the following code to get a better idea:<br><div class="csharpcode">
            <span class="rem">//create PdfViewer object</span><br>
              Aspose.Pdf.Kit.PdfViewer viewer = <span class="kwrd">new</span> Aspose.Pdf.Kit.PdfViewer();<br>
              viewer.OpenPdfFile("input.pdf");<br>


//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.Simplex;

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.ClosePdfFile();



I hope this helps. If you find any issue or have some more questions, please do let us know.
Regards,

@md5jsv

The required feature can be obtained now using Aspose.PDF for .NET via latest enhancements that we made to the API. Please check below code snippet(s) in order to set Dialog Presets while printing PDF document using Aspose.PDF for .NET:

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

Please also check that code snippet for Facades.PdfContentEditor will be like below:

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);
}