We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Exporting PDF to database from WinRT (XAML) app

Hi,

We are trying to save pdf form to the database. So far we can successfully save the file to the desktop and view it. We are able to send it back to the database (SharePoint 2013) but when we try to open it, it throws an exception stating that the file is corrupt. My guess is that it converts the PDF to utf-8 before sending it to the database (we are using REST). Is there a way to store the pdf to SharePoint without messing it up?

5 Replies

GL George Livingston Syncfusion Team July 25, 2013 12:07 PM UTC

Hi Khurram,

Thank you for using Syncfusion Products.

Can you please provide us the issue reproducing sample along with the corrupted PDF document. It would be more helpful for us to investigate on this.

Please let us know if you have any concerns.

Regards,

George



KB Khurram Bhatti September 3, 2013 01:30 PM UTC

My apologies for the delayed response. I didn't know that there is no automated message generated when someone responds to a post. Attached is the code that we are working on to store a PDF on SharePoint. The PDF gets generated correctly and can be saved to the desktop without any issue but when it is transferred to SharePoint, it becomes corrupt. Not sure if utf-8 encoding has anything to do with it or not.



PDF_Sync_Code_464a5306.zip


GL George Livingston Syncfusion Team September 4, 2013 12:01 PM UTC

Hi Khurram,

 

Thank you for your update.

 

On further analysis, we found that the issue is not due to the Syncfusion library. The PDF document contains content streams which is in encoded format, while converting the PDF document to string (UTF8/Unicode) the content streams gets corrupted. This causes the problem in opening the PDF document in Adobe Reader.

 

Please let us know if you need any further assistance.

 

Regards,

George.



KB Khurram Bhatti September 5, 2013 10:56 AM UTC

Thank you very much George for your kind help in this. How can we avoid that conversion of PDF into Unicode? Is it a limitation of the Windows 8 SDK?



GL George Livingston Syncfusion Team September 6, 2013 11:43 AM UTC

Hi Khurram,

 

We regret for the inconvenience caused.

 

On further analysis, we have found that this behaviour can be overcome by the using ToBase64String to encode the PDF byte[] to string and FromBase64String to decode string to PDF byte[] in the destination. On saving the byte[] in the destination the PDF document can be opened without any error in the Adobe Reader.

 

string encodedPdfData = Convert.ToBase64String(pdfByteArray);

byte[] decodedPdfData = Convert.FromBase64String(encodedPdfData);

 

Please let us know if you need any further assistance.

 

Regards,

George


Loader.
Live Chat Icon For mobile
Up arrow icon