Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Jun 27, 2016 4:13 pm

I'm trying to use Spire.PDF to convert from XPS to PDF in my c# application.

My application creates a FixedDocument and then saves it using XpsDocumentWriter.Write(). The created XPS file opens without any apparent problem using the Windows XPS Viewer.

If I try to load the same XPS file using PdfDocument.LoadFromFile() I get a System.InvalidOperationException "There is an error in XML document (2, 7831)." with an InnerException of "Invalid character in the given encoding. Line 2, position 7831."

If I take the same FixedDocument and display it in a DocumentViewer control I can save it to XPS using the XPS Document Writer virtual printer. The XPS created in this way doesn't cause the PdfDocument.LoadFromFile() exception.

I've looked at the inner structure of the two XPS files. They are different, but both appear to be valid.

bremen1874
 
Posts: 3
Joined: Mon Jun 27, 2016 2:41 pm

Tue Jun 28, 2016 1:34 am

Hi,

Thanks for your posting.
Please provide us your XPS file which has the error to help us do the investigation for the issue. Thank you.
You can also send it to support@e-iceblue.com if it is inconvenience to share it here.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Tue Jun 28, 2016 2:14 am

Thanks for the reply.

Sample attached. Real companies, junk data.

This should show the problem but I've removed Spine from the project for the moment so can't easily check.

Assuming the problem is there it's worth noting that I've tried unloading XPS files that Spire.PDF couldn't read to a few of the more obvious web based conversion sites and they handled them.

bremen1874
 
Posts: 3
Joined: Mon Jun 27, 2016 2:41 pm

Tue Jun 28, 2016 2:40 am

Hi,

I tested your attached xps file with the two methods below, and both worked fine on loading and converting. Please try them.
Code: Select all
#1
pdfDocument.LoadFromFile("..\\..\\Input\\bad.xps", FileFormat.XPS);
pdfDocument.SaveToFile("795701.pdf",FileFormat.PDF);

#2
pdfDocument.LoadFromXPS("..\\..\\Input\\bad.xps").
pdfDocument.SaveToFile("795702.pdf",FileFormat.PDF);


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Tue Jun 28, 2016 3:05 am

I will try it.

For convenience I was using the 'Free' version. Having looked at this some more it looks like the free version isn't at the same build level as the licensed version. Is this likely to be the cause of my problem?

I've no objection about paying for the licensed version if it gets the job done. Does the licensed version allow a conversion from a XPS MemoryStream? Having to save an intermediary XPS file isn't the end-of-the-world, but it's a bit inelegant.

bremen1874
 
Posts: 3
Joined: Mon Jun 27, 2016 2:41 pm

Tue Jun 28, 2016 3:30 am

Hi,

Sorry that the feature that loading a XPS MemoryStream has not been supported now. But we have added it as new feature into our schedule. We will inform you when it is supported. I recommend you to use our commercial edition of Spire.PDF which we give high priority of bug solutions and frequently version updates. We can offer you 1-month free license to remove the warning message.
If you needs it, please contact sales@e-iceblue.com.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Fri Aug 12, 2016 7:24 am

Hi,

Sorry for long silence. Thanks for your waiting, now the feature has been added, you can download and try the latest hotfix Spire.PDF Pack(Hot Fix) Version:3.7.198.

Sincerely,
Lucy
E-iceblue support team
User avatar

Lucy
 
Posts: 30
Joined: Wed Aug 03, 2016 1:59 am

Wed Aug 17, 2016 9:04 am

Hi,

How is your issue now? Is it resolved with the latest hotfix ? Could you please give us some feedback at your convenience. Thank you in advance.

Best regards,
Lucy
E-iceblue support team
User avatar

Lucy
 
Posts: 30
Joined: Wed Aug 03, 2016 1:59 am

Return to Spire.PDF