Free Support Forum - aspose.com

How to Print a PDF file using Print dialog box

Hi Team,

Could you please provide the sample code for print a PDF file using print dialog box with same quality.

Scenario:

If i click the print button then print dialog box should display.I need to select the printer name from print dialog box.See the attached sample Print dialog box.

Thanks and Regards

Saravanan.l

Hi Team,

Please provide us the complete sample code to preview and print a PDF file using print dialoge box .

Thanks and Regards

Saravanan.l

Hi Team,

Any update on the above issue.Please provide us the sample code.

Used Code:

Aspose.Pdf.Facades.PdfViewer viewer = new Aspose.Pdf.Facades.PdfViewer();

viewer.BindPdf(pdfFilePath);

viewer.AutoResize = true;

viewer.Resolution = 600;

viewer.AutoRotate = true;

viewer.PrintPageDialog = true;

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

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

System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();

ps.PrinterName = prtdoc.PrinterSettings.PrinterName;

pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);

pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

viewer.PrintDocumentWithSettings(pgs, ps);

viewer.Close();

Thansk and Regards

Saravanan.l

Hi Team,

We have valid license update 2013Dec26.

Any update on the above issues.Please provide us the solution ASAP.

Thanks and Regards

Saravanan.l

Hi Team,

We have valid license update 2013Dec26.

Any update on the above issues.Please provide us the solution ASAP.

1.Our requirement is if i click the print buuton means print dialog box should display.we need to select the printer name and pages from dialog box.Please code same code and also please see the below used code

2.How to insert page numbers in PDF.

Used code:

workbook.Save(pdfFilePath, Aspose.Cells.SaveFormat.Pdf);

Aspose.Pdf.Facades.PdfViewer viewer = new Aspose.Pdf.Facades.PdfViewer();

viewer.BindPdf(pdfFilePath);

viewer.AutoResize = true;

viewer.Resolution = 600;

viewer.AutoRotate = true;

viewer.PrintPageDialog = true;

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

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

System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();

ps.PrinterName = prtdoc.PrinterSettings.PrinterName;

pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);

pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

viewer.PrintDocumentWithSettings(pgs, ps);

viewer.Close();

viewer.PrintLargePdf(pdfFilePath, pgs, ps);

Thanks and Regards

Saravanan.l

Hi Saravanan,


Thanks for contacting support and sorry for the delayed response.

I have tested the scenario while using above specified code and as per my observations, the printdialog is not appearing. Nevertheless, I further investigating this issue and will get back to you soon. We are sorry for this inconveninece.

Hi Saravanan,


I have tested the scenario and I am able to
notice the same problem. For the sake of correction, I have logged this issue
as
PDFNEWNET-34780 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.

Hi Saravanan,


Thanks for your patience.

We have further investigated the issue PDFNEWNET-34780 and it does not seem to be an issue in Aspose.Pdf for .NET. Please try using the following code snippet to accomplish your requirement.

[C#]

Aspose.Pdf.Facades.PdfViewer
viewer = new Aspose.Pdf.Facades.PdfViewer();<o:p></o:p>

viewer.BindPdf("c:/pdftest/ResultantFile.pdf");

viewer.AutoResize = true;

viewer.Resolution = 600;

viewer.AutoRotate = true;

viewer.PrintPageDialog = true;

PrintDialog printDialog = new PrintDialog();

if (printDialog.ShowDialog() == DialogResult.OK)

{

System.Drawing.Printing.PrinterSettings ps = printDialog.PrinterSettings;

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

viewer.PrintDocumentWithSettings(pgs, ps);

}

viewer.Close();


In the event of any further query, please feel free to contact.