aspose.png (27.2 KB)
Hi !
I have been struggling for a few days to print on both sides with the Aspose.PDF module.
I tried all the known variants and I can’t understand where I’m wrong.
I used other printing components that are functional, but Aspose.PDF does not want …
Can you help me ?
public void PrintingPDFHidePrintDialog(string vs_file)
{
// Create PdfViewer object
PdfViewer viewer = new PdfViewer();
// Open input PDF file
viewer.BindPdf(vs_file);
// Set attributes for printing
viewer.AutoResize = true; // Print the file with adjusted size
viewer.AutoRotate = true; // Print the file with adjusted rotation
viewer.PrintPageDialog = false; // Do not produce the page number dialog when printing
// Create objects for printer and page settings and PrintDocument
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
ps.FromPage = 1;
ps.ToPage = 3;
ps.PrintRange = PrintRange.SomePages;
// Set XPS/PDF printer name
ps.PrinterName = cbx_imprimanta.Text;
// Set PageSize (if required)
pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
// Set PageMargins (if required)
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
if (ps.CanDuplex)
{
ps.Duplex = Duplex.Vertical;
MessageBox.Show("Duplex.OK");
}
else
{
MessageBox.Show("No Duplex.Mode");
}
// Print document using printer and page settings
viewer.PrintDocumentWithSettings(pgs, ps);
// Close the PDF file after priting
viewer.Close();
}