Hi,
We're using exact code from this page - http://www.aspose.com/docs/display/pdfnet/Printing+PDF+to+an+XPS+Printer+%28Facades%29
PrintDocumentWithSettings fails with EndOfStreamException (Unable to read beyond the end of the stream.)
It fails all the time - tested with different documents and different print drivers and printers
Version used: 9.0.0.0
Here is our code:
using
(PdfViewer pdfViewer = newPdfViewer())
{
pdfViewer.BindPdf(
@"C:\temp\sample.pdf");
try
{
System.Drawing.Printing.
PrinterSettings printerSetttings = new System.Drawing.Printing.PrinterSettings();
printerSetttings.Copies = 1;
printerSetttings.PrinterName =
"Microsoft XPS Document Writer";
//Set output file name and PrintToFile attribute
printerSetttings.PrintFileName =
"C:\\temp\\printoutput.xps";
printerSetttings.PrintToFile =
true;
//Disable print page dialog
pdfViewer.PrintPageDialog =
false;
//Pass printer settings object to the method
pdfViewer.PrintDocumentWithSettings(printerSetttings);
pdfViewer.Close();
}
catch (Exception exception)
{
Log.Error(exception);
}
pdfViewer.Close();
pdfViewer.Dispose();
}