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.




FileStream fs = new FileStream(myDir + “HelloWorld.pdf”, FileMode.Open, FileAccess.Read);<o:p></o:p>

byte[] tmpBytes = new byte[fs.Length];<o:p></o:p>

fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length));<o:p></o:p>

MemoryStream mystream = new MemoryStream(tmpBytes);<o:p></o:p>

MyStream myStream = new MyStream(mystream);<o:p></o:p>

PdfViewer viewer = new PdfViewer();<o:p></o:p>

viewer.BindPdf(mystream);<o:p></o:p>

viewer.PrintAsImage = true;<o:p></o:p>

viewer.AutoResize = false;<o:p></o:p>

// viewer.Resolution = 600;<o:p></o:p>

viewer.AutoRotate = false;<o:p></o:p>

//viewer.PrintPageDialog = true;<o:p></o:p>

System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();<o:p></o:p>

if (printDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)<o:p></o:p>

{<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();<o:p></o:p>

pgs.PaperSize = new System.Drawing.Printing.PaperSize(“A4”, 827, 1169);<o:p></o:p>

pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);<o:p></o:p>

pgs.Landscape = true;<o:p></o:p>

// ps.PrinterName = “Adobe PDF”;<o:p></o:p>

// ps.PrintToFile = true;<o:p></o:p>

// ps.PrintFileName = myDir + “testoutprint.pdf”;<o:p></o:p>

viewer.PrintDocumentWithSettings(pgs, ps);<o:p></o:p>

}<o:p></o:p>

viewer.Close();<o:p></o:p>

<o:p> </o:p>

<o:p>Please feel free to contact us for any further assistance.</o:p>

<o:p>
</o:p>

<o:p>Best Regards,</o:p>

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,