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

Reading and saving a PDF produces an invalid file

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";

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:

<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" />

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

8 Replies

SK Surya Kumar Syncfusion Team May 15, 2017 12:15 PM UTC

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. 
Surya Kumar 

JN John Nelson May 19, 2017 07:11 PM UTC

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?

SK Surya Kumar Syncfusion Team May 22, 2017 11:07 AM UTC

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. 
Surya Kumar 

JN John Nelson May 22, 2017 12:13 PM UTC

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"

SK Surya Kumar Syncfusion Team May 23, 2017 06:31 AM UTC

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. 
Surya Kumar 

PS Paul Steiner November 15, 2018 09:17 PM UTC

Is there an update on this issue. I have the same problem.

KC Karthikeyan Chandrasekar Syncfusion Team November 16, 2018 12:19 PM UTC

Hi Paul, 
Thank you for your update. 
The Adobe reader throws the error “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”, if the document contain extended feature and if the document violate the extended feature rule. Could you please share us the feature used in extended feature PDF document.  So that we can check and provide you the solution. It will be easier for if you share us the input PDF.  At present we do not have XFA form field support in ASP.NET Core platform. 


DB Dilli Babu Nandha Gopal Syncfusion Team March 14, 2019 07:00 PM UTC

Hi Paul, 
We are glad to inform you that Essential Studio 2019 Volume 1 Beta Release v17.1.0.32 is rolled out. Here is the download link.  
Feature: XFA form support in ASP.NET core platform. 
XFA from Creation: 
//Create a new PDF XFA document. 
PdfXfaDocument document = new PdfXfaDocument(); 
//Add a new XFA page. 
PdfXfaPage xfaPage = document.Pages.Add(); 
//Create a new PDF XFA form 
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width); 
//Create a text element and add the properties. 
PdfXfaTextElement textElement = new PdfXfaTextElement("Hello World!"); 
//Add the field to the XFA form.            mainForm.Fields.Add(textElement); 
//Add the XFA form to the document. 
document.XfaForm = mainForm; 
//Save the PDF document to stream. 
MemoryStream stream = new MemoryStream(); 
document.Save(stream, PdfXfaType.Dynamic);  
XFA form filling: 
//Load the existing XFA document 
PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument(inputFileStream); 
//Load the existing XFA form 
PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm; 
//Get the loaded text box field. 
PdfLoadedXfaTextBoxField loadedTextBox = (loadedForm.Fields["form[0].subform1[0].firstName[0]"] as PdfLoadedXfaForm).Fields["text[0]"] as PdfLoadedXfaTextBoxField; 
//fill the text box 
loadedTextBox.Text = "First Name"; 
MemoryStream stream = new MemoryStream(); 
//Close the document. 
Kindly try our latest version of Essential Studio and let us know if you any other issue.  
Dilli babu. 

Live Chat Icon For mobile
Up arrow icon