Problem with PDF -> XPS printing

Hi,

We’re using exact code from this page - Printing PDF documents|Aspose.PDF for .NET

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 = new PdfViewer())

{

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

}

Hi Martin,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 9.0.0 in VisualStudio 2010 application where I have used one of my sample PDF files and I am unable to notice any problem. The PDF file is properly being saved in XPS format. Can you please share some sample PDF files causing problem at your end so that we can test the scenario. We are sorry for this inconvenience.

Hi,

See attached PDF.

I forgot to mention - we're using .NET Client Profile 4.0 Aspose.Pdf DLL if that makes any difference (downloaded as nuget package).

Martin

Hi Martin,


Thanks for sharing the details.

I have again tested the scenario in VisualStudio 2010 application with target platform as .NET Framework 4.0_ClientProfile running over Windows 7 (x64) where I have referenced Aspose.Pdf for .NET 9.0.0 through NuGet package and I am unable to notice any problem. The PDF file is properly being printed. Can you please share some further details regarding your working environment so that we can further look into this matter.

We are sorry for your inconvenience.

PS, for your reference, I have also attached the resultant XPS generated over my end.

Hi Martin,


Thanks for additional information. I am afraid we are unable to replicate the issue, while we tested the scenario with .Net Framework Client Profile 4.0 Aspose.Pdf DLL using nuget package. We will appreciate if you please share a sample project and your environment details to reproduce the issue for further investigation.

We are sorry for the inconvenience caused.

Best Regards,

Hi,

See attached solution.

Before running it, make sure you have "Break on CLR exceptions" switched on (Debug / Exceptions / check Common Language Runtime Exceptions).

You will get EndOfStreamException on line 60.

Martin

Hi Martin,

Thanks for sharing the sample project.. While testing the scenario with the latest version of Aspose.Pdf for NET 9.1.0, We have managed to reproduce the reported issue and logged it in our bug tracking system as PDFNEWNET-36743 for further investigation and resolution. We will notify you via this thread as soon as it is resolved.

We are sorry for the inconvenience caused

Best Regards,

Hi Martin,


We have further investigated and found that your output file name is not correct so fixing it will resolve the printing problem. However, the mentioned exception is internal exception and handled properly. We have plan to fix it upcoming release. We will notify you as soon as these internal exceptions are fixed.

string printToFilePath = String.Format("{0}.xps", pdfPath);


Please feel free to contact us for any further assistance.


Best Regards,

The issues you have found earlier (filed as PDFNEWNET-36743) have been fixed in Aspose.Pdf for .NET 9.4.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.