Pdfs fail to produce xps

Step the supplied Visual Studio project.
The pdf supplied produces no xps.PdfTest.zip (564.4 KB)


Thank you for contacting support.

I have worked with the data shared by you and have been able to reproduce the issue in our environment. The generated PDF appears blank PDFToXPS_17.12.zip. A ticket with ID PDFNET-43915 has been logged in our issue management system for further investigation and resolution. The issue ID has been linked with this thread so that you will receive notification as soon as the issue is resolved.

We are sorry for the inconvenience.

When I step the code in VisualStudio, I repeatably get the Stream is Closed exception and this stack trace:

 Index  Function
*1      mscorlib.dll!System.IO.__Error.StreamIsClosed()
 2      mscorlib.dll!System.IO.MemoryStream.Position.get()
 3      System.Drawing.dll!System.Drawing.Internal.GPStream.Seek(long offset = 0x0000000000355c56, int origin = 0x00000000)
 4      [External Code]
 5      System.Drawing.dll!System.Drawing.Image.Save(System.IO.Stream stream, System.Drawing.Imaging.ImageCodecInfo encoder, System.Drawing.Imaging.EncoderParameters encoderParams)
 6      System.Drawing.dll!System.Drawing.Image.Save(System.IO.MemoryStream stream)
 7      System.Drawing.dll!System.Drawing.ImageConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType)
 8      System.dll!System.ComponentModel.TypeConverter.ConvertTo(object value, System.Type destinationType)
 9      Aspose.Pdf.dll!   .   (System.Drawing.Bitmap  = {System.Drawing.Bitmap},      = {   }, bool  = false)
 10     Aspose.Pdf.dll!  .(    = 0x00000001, System.Drawing.Bitmap  = {System.Drawing.Bitmap},      = {   }, bool  = false)
 11     Aspose.Pdf.dll!   .    (    = {  })
 12     Aspose.Pdf.dll!   .(    = {  })
 13     Aspose.Pdf.dll!   .    (    = {  })
 14     Aspose.Pdf.dll!   .    (    = {  }, System.Collections.Generic.List<   >  = Count = 0x0000000e)
 15     Aspose.Pdf.dll!   .    (     = {   },      = {   },     = {  })
 16     Aspose.Pdf.dll!  .(Aspose.Pdf.Document  = {Aspose.Pdf.Document}, ref     = {  }, Aspose.Pdf.UnifiedSaveOptions  = {Aspose.Pdf.XpsSaveOptions}, ref int  = 0x00000001)
 17     Aspose.Pdf.dll!  .(Aspose.Pdf.Document  = {Aspose.Pdf.Document}, ref     = {  }, Aspose.Pdf.UnifiedSaveOptions  = {Aspose.Pdf.XpsSaveOptions}, ref int  = 0x00000001)
 18     Aspose.Pdf.dll!   .(Aspose.Pdf.Document  = {Aspose.Pdf.Document}, System.IO.Stream  = {System.IO.FileStream}, Aspose.Pdf.XpsSaveOptions  = {Aspose.Pdf.XpsSaveOptions})
 19     Aspose.Pdf.dll!Aspose.Pdf.Document.Save(System.IO.Stream outputStream = {System.IO.FileStream}, Aspose.Pdf.SaveOptions options = {Aspose.Pdf.XpsSaveOptions})
 20     Aspose.Pdf.dll!Aspose.Pdf.Document.Save(System.IO.Stream outputStream = {System.IO.FileStream}, Aspose.Pdf.SaveFormat format = Xps)
 21     Aspose.Pdf.dll!Aspose.Pdf.Document.Save(string outputFileName = "output.xps", Aspose.Pdf.SaveFormat format = Xps)
 22     Case4334.exe!Case4334.Program.PrintPdf_01()
 23     Case4334.exe!Case4334.Program.Main(string[] args = {string[0x00000000]})
 24     [External Code]
 25     mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args)
 26     Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
 27     mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state)
 28     mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
 29     mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
 30     mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)
 31     mscorlib.dll!System.Threading.ThreadHelper.ThreadStart()
 32     [External Code]



Thank you for getting back to us.

I would like to share with you that while working with the project shared by you, the StreamIsClosed exception is not occurring in my environment. However, a blank XPS is being generated that I have shared with you earlier. Please try using Aspose.Pdf for .NET 17.12 in your environment and then share your kind feedback with us.

The behaviour is the same using 17.12 - there’s an exception and the produced XPS is blank.

In order to see the exception you have to tick all the boxes in the Exceptions dialog in VS.


I am unable to reproduce this exception with Visual Studio 2017 even after checking all the check boxes in Exception Settings. So, there can be some other line of code that may be throwing this exception, the project you had shared with us earlier is not reproducing this exception in our environment. I have attached a screenshot for your kind reference. VS2017.JPG

You get a blank XPS whether the exception occurs or not.
So the exception and the blank output are unrelated - I thought there might be some connection which is why I told you about them.


I have updated the information in our issue management system. We will get back to you once we have some significant updates regarding this ticket. We appreciate your patience in this regard.

Can you tell me whether you have now fixed this? We’ve had no update since January.


We would like to update you that the ticket PDFNET-43915 is still pending for investigations owing to previously logged tickets in the queue. We will notify you as soon as some significant progress is made in this regard.

However, we also offer Paid Support, where issues are used to be investigated with higher priority. Our customers, who have paid support subscription, report their issue there which are meant to be investigated urgently. In case your reported issue is a blocker, you may please consider subscribing for Paid Support. For further information, please visit Paid Support FAQs.

Is there a status update? I first reported this in December 2017


Thank you for getting back to us.

We definitely value your concerns and realize the significance of the issue. Please note that we provide resolution against every issue reported by our customers - however, issues have been resolved on first come first serve basis, which we believe, is the fairest policy. There is large number of pending issues in the queue which were reported prior to your issue and we have been working over resolving those issues as well as introducing new features and improvements in the API.

As soon as we will have some updates, we will let you know. We really appreciate your patience and comprehension in this regard.

I just updated to Aspose.pdf 19.3 and the issue I first reported in December 2017 is still present.

Furthermore, I ran the Microsoft isxps tool on the XPS produced by the sample code and there were four FAILs:

+Start Test: Validating that package conforms to OPC specification 
  +Start Test: Validating package part names
  -End Test: Validating package part names Result: Pass
  +Start Test: Checking Content Types
    Fail: The following parts do not have an associated Content Type. [OPC M2.4]
    Info: Documents/1/FixedDocument.fdoc
    Info: Documents/1/Pages/1.fpage
    Info: FixedDocumentSequence.fdseq
    Info: Resources/576c1967-0000-0000-0000-000000000000.odttf
  -End Test: Checking Content Types Result: Fail
      . . .
 ----------Log Rollup----------
 TestName: isXPS c:\temp\output.xps
 PassRate: 90% Pass: 38 Warn: 0 Fail: 4 Block: 0
 Result: Fail

I would like to know:

  1. When will the originally reported defect be fixed?
  2. When will the isxps error be fixed?
  3. Is there a workaround to get aspose pdf to produce well-formed, non-blank xps from a well-formed input pdf?


Thank you for being patient.

We are afraid PDFNET-43915 is still unresolved. However, we have raised its priority to next level and will schedule it as soon as we can. Please spare us little more time.

Moreover, we have recorded your concerns related to isxps tool and will investigate the generated file in this context as well. About workaround, it may not be devised before the ticket is investigated. We will be updating you further as soon as any update will be available.

I asked you about a workaround - I have discovered that if do these operations I can produce xps with visible content:

  1. Construct an Aspose.Pdf.Document passing it the name of the pdf to be opened.
  2. Call the object’s Convert method to down-cast to PDF_A_1A
  3. Call the object’s Save method to create the xps file

Please would you explain why this method works?

Also, what checks can I do on the Aspose.Pdf.Document object that will tell me whether I need the Convert step? Not all pdfs need it, and it’s a relatively expensive operation - so I only want to call it if I have to.


Thank you for more details.

We are glad to know that you have discovered the workaround approach. Moreover, we have recorded your concerns and will let you know as soon as detailed investigations will be made into this ticket. Please spare us little time and we will get back to you with our findings.

I have two questions. I’d like actual concrete answers this time.

  1. Please tell me what checks I need to do on the pdf to determine whether the workaround is needed or not.
  2. Please give me a timescale for an actual fix. I reported this issue in December 2017


We are afraid we may not be able share such details prior investigations into this ticket. We understand the importance of this problem so the priority has been raised already. This ticket will tentatively be investigated within next two or three weeks. Please spare us some time and we will get back to you.

We really appreciate your patience.

The issues you have found earlier (filed as PDFNET-43915) have been fixed in Aspose.PDF for .NET 19.4.