Hi, I am evaluating ASPOSE to use for printing existing PDF files using asp.net. I can print the file just fine with the exception of the last page. The last page of each file will not print. Aspose.Pdf.Facades.PdfViewer.Pagecount reports the correct number of pages.
Please see the code below:
{
string fname = @“\is-apps02\RPM\Working\Admin\g_payroll.pdf”;
Aspose.Pdf.Facades.PdfViewer pdfv = new Aspose.Pdf.Facades.PdfViewer();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
System.Drawing.Printing.PrinterSettings prin = new System.Drawing.Printing.PrinterSettings();
pdfv.BindPdf(fname);
int pgcnt = 0;
pgcnt = pdfv.PageCount;
txt2.Text = pgcnt.ToString();
prin.PrintRange = System.Drawing.Printing.PrintRange.AllPages;
prin.PrinterName = cmbxPrinterNames.SelectedValue.ToString();
prin.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("letter", 827, 1169);
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
pgs.PaperSize = prin.DefaultPageSettings.PaperSize;
pdfv.PrintDocumentWithSettings(pgs, prin);
pdfv.Close();
Be glad to. I have tried a couple of files and got similar results. The file I am attaching is a 7 page document. It would only print the first 4 pages.
On the statement,
prin.DefaultPageSettings.PaperSize = New System.Drawing.Printing.PaperSize(“letter”, 850, 1150)
I assume the last 2 values are page width and height signifying 8.5: and 11.5 inches" ?
As per my observations, the shared PDF file has 6 pages and when trying to print PDF file to MS XPS Document Writer, the resultant file contains 6 pages. For your reference, I have also attached the resultant file generated over my end.