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.
Unfortunately, activation email could not send to your email. Please try again.

Reading and saving a PDF produces an invalid file

Thread ID:

Created:

Updated:

Platform:

Replies:

130446 May 13,2017 10:20 AM May 23,2017 02:31 AM ASP.NET Core 5
loading
Tags: PDF
John Nelson
Asked On May 13, 2017 10:20 AM

I have a simple test using .NET Core where I read in a PDF, set all text fields to "foo", and save it back to the file system:

public void Test_ValidPdfInput_ProducesInvalidPdfOutput()
{
using (var stream = File.Open("D:\\temp\\fw4.pdf", FileMode.Open, FileAccess.Read, FileShare.Read))
using (var pdf = new PdfLoadedDocument(stream, true))
using (var f = System.IO.File.OpenWrite("D:\\temp\\output.pdf"))
{
foreach (PdfLoadedField field in pdf.Form.Fields)
{
var textField = field as PdfLoadedTextBoxField;
if (textField != null)
{
textField.Text = "foo";
}
}
pdf.Save(f);
}
}

When I try to open the output PDF in Adobe Acrobat Reader DC, I get the following error:

"This document enabled extended features in Adobe Acrobat Reader. The document has been changed since it was created and use of extended features is no longer available. Please contact the author for the original version of this document."

None of the "foo" values appear and none of the fields are even displayed on the document where they should be.

However, when I open the PDF using Google Chrome Version 57.0.2987.133 (64-bit) it renders perfectly with all fields visible, editable, and with the expected "foo" value in them.

For reference, here are the packages in my csproj:

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="Syncfusion.Pdf.Portable" Version="15.2120.0.40" />
</ItemGroup>

Attached is a zip contianing the input PDF, and a sample output PDF from the code above.

Am I doing something incorrect, or is there a potential bug in Syncfusion.Pdf.Portable? Any help is appreciated.

Attachment: fw4_7a60c170.zip

Surya Kumar [Syncfusion]
Replied On May 15, 2017 08:15 AM

Hi John, 
 
Thank you for using Syncfusion products. 
 
We can reproduce the behavior which you have mentioned in the previous update. When analyzed the reason for this, it is found that the input document which you have attached is found to have XFA forms in them, in which “usage rights” are enabled in acrobat, which causes the error which you have mentioned. 
 
However, by loading this document as “PdfLoadedXfaDocument” and filling the form will fix the issue, but currently we do not have support for using PdfLoadedXfaDocument” in Asp.Net core so we have logged the feature request for “Need to add the XFA form support in Asp.Net Core”. Which can be tracked from below link: 
 
 
Please let us know if you need any further information in this. 
 
Regards,
Surya Kumar 
 


John Nelson
Replied On May 19, 2017 03:11 PM

Thank you for the response! This seems pretty straight forward, and I'm eager to get this update.

When I click the link I'm unable to see any details. Is there somewhere else I should look?

Surya Kumar [Syncfusion]
Replied On May 22, 2017 07:07 AM

Hi John, 
 
Sorry for the inconvenience caused, 
 
You can view your open features by logging in to your Direct-Trac account and you can open the “Features” tab to view the features linked with your account. 
 
Please find the Direct-Trac link for viewing features below: 
 
 
Let us know if you need any further information. 
 
Regards, 
Surya Kumar 


John Nelson
Replied On May 22, 2017 08:13 AM

Thanks for the reply. When I click on that link I end up on https://www.syncfusion.com/support/directtrac/features but it says "No records to display"

Surya Kumar [Syncfusion]
Replied On May 23, 2017 02:31 AM

Hi John, 
 
Sorry for the miscommunication. 
 
The link which we have sent on previous update will only be used for internal purpose, and cannot be viewed by others through forum. We will make sure to intimate you once this feature is implemented in the forum. So, keep track on this forum for updates regarding this feature. 
 
Regards, 
Surya Kumar 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;