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

Free Support Forum - aspose.com

Printing PDF

Hi


Just a “simple” question…

Will it, with Aspose PDF, be possible to print an Existing PDF file to a specific printer or to show the default printing dialog in the process…

We have a customer that needs to send a PDF we generate in our application to a specific printer that saves the document to an external source…

Thanks in advance…

Hi Allan,

Thanks for your inquiry. Please check following documentation link to print PDF to a specific Printer and also check sample code for printing PDF document from memory stream using print dialogue. Hopefully it will help you to accomplish the task.

Printing Pdf to an XPS printer

FileStream fs = new FileStream(myDir + “HelloWorld.pdf”, FileMode.Open, FileAccess.Read);
byte[] tmpBytes = new byte[fs.Length];
fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length));
MemoryStream mystream = new MemoryStream(tmpBytes);
MyStream myStream = new MyStream(mystream);
PdfViewer viewer = new PdfViewer();
viewer.BindPdf(mystream);
viewer.PrintAsImage = true;
viewer.AutoResize = false;
// viewer.Resolution = 600;
viewer.AutoRotate = false;
//viewer.PrintPageDialog = true;
System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
if (printDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)<o:p></o:p>
{
System.Drawing.Printing.PrinterSettings ps = printDialog.PrinterSettings;<o:p></o:p>
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
pgs.PaperSize = new System.Drawing.Printing.PaperSize(“A4”, 827, 1169);
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
pgs.Landscape = true;
// ps.PrinterName = “Adobe PDF”;
// ps.PrintToFile = true;
// ps.PrintFileName = myDir + “testoutprint.pdf”;
viewer.PrintDocumentWithSettings(pgs, ps);
}
viewer.Close();

Please feel free to contact us for any further assistance.

Best Regards,

Hi Tilal


Thanks for answering…

Sounds very promising. Looks like we are into upgrading our Aspose Words license to a Total license :slight_smile:

Hi Allan,


Thanks for your feedback. It is good to know that you found the shared information useful.

Please give it a try and feel free to ask any question or concern. We will be more than happy to extend our support.

Best Regards,