We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Extended Features disabled despite code fix

Despite using the methods in this post…

[ http://www.aspose.com/docs/display/pdfnet/Preserve+Extended+Rights+feature+while+working+with+Forms ]
…I’m still getting the [This document enabled extended features in Adobe 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] error message in Reader X.

Here is my code:

private FileInfo BuildPdfTemplateFile(int ProjectReviewRequestID, DataTable dt, bool editable)
{
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(HttpContext.Current.Server.MapPath("~/App_References/Aspose.Total.lic"));
DataRow dr = dt.Rows[0];
string templateFilePath = HttpContext.Current.Server.MapPath("~/Forms/ProjectReview/ProjectReview_A.pdf");
FileInfo newPDF = new FileInfo(Path.GetTempFileName());
File.Copy(templateFilePath, newPDF.ToString(), true);
File.SetAttributes(newPDF.FullName, FileAttributes.Normal);
FileStream fs = new FileStream(newPDF.ToString(), FileMode.Open, FileAccess.ReadWrite);
Aspose.Pdf.Document templateFile = new Aspose.Pdf.Document(fs);
Aspose.Pdf.Facades.Form newForm = new Aspose.Pdf.Facades.Form(templateFile);
string SubmitButtonName = “”;
string SubmitLabelName = “”;
foreach (DataColumn dc in dt.Columns)
{
foreach (string fieldName in newForm.FieldNames)
{
if (fieldName.Contains(dc.ColumnName))
{
if (dc.ColumnName.StartsWith(“OWVals”))
{ }
switch (dc.ColumnName)
{
case “StartDate”:
case “EndDate”:
case “DeliveryDate”:
if (!string.IsNullOrEmpty(dr[dc.ColumnName].ToString()))
newForm.FillField(fieldName, Convert.ToDateTime(dr[dc.ColumnName].ToString()).ToString(“d MMM yyyy”));
break;
default:
if (!string.IsNullOrEmpty(dr[dc.ColumnName].ToString()) && IsDataColumnNumeric(dc))
{
if (dc.ColumnName.ToString().StartsWith(“OWVal”))
if (fieldName.Contains(".#field[" + dr[dc.ColumnName].ToString() + “]”))
{
string indexString = “#field[” + dr[dc.ColumnName].ToString() + “]”;
newForm.FillField(fieldName.Replace(indexString, “”), dr[dc.ColumnName].ToString());
}
if (dc.ColumnName.ToString().StartsWith(“Skills”))
if (fieldName.Contains(".#field[" + dr[dc.ColumnName].ToString() + “]”))
{
string indexString = “#field[” + dr[dc.ColumnName].ToString() + “]”;
newForm.FillField(fieldName.Replace(indexString, “”), dr[dc.ColumnName].ToString());
}
if (!dc.ColumnName.ToString().StartsWith(“OWVal”) && !dc.ColumnName.ToString().StartsWith(“Skills”))
newForm.FillField(fieldName, dr[dc.ColumnName].ToString());
}
else if (dr[dc.ColumnName].ToString().StartsWith("<body xfa"))
{
//RichTextBoxField rtfField = (RichTextBoxField) templateFile.Form[fieldName];
//rtfField.RValue = dr[dc.ColumnName].ToString();
templateFile.Form.XFA[fieldName] = dr[dc.ColumnName].ToString();
}
else
newForm.FillField(fieldName, dr[dc.ColumnName].ToString());
break;
}
}

if (fieldName.Contains(“EmailSubmitButton”))
{
SubmitButtonName = fieldName;
}

if (fieldName.Contains(“EmailSubmitLabel”))
{
SubmitLabelName = fieldName;
}
}
}
if (!editable)
{
newForm.FlattenField(SubmitButtonName);
}
templateFile.Save();
newForm.Save(fs);
fs.Close();
return newPDF;
}

Any thoughts?

Hi Anne Marie,

Can you please share the source PDF form so that we can test the scenario at our end. We are sorry for this inconvenience.

I realize that it has been a while since I made this post originally, but if I reply with my PDFs, will anyone see it, or should I start a new thread?


Adding to the mix is that now we are aware that the modified PDFs are editable in Acrobat and Reader 10, but still break in both Reader 8 and Acrobat Pro and Reader 11.

Hi Anne Marie,


Thanks for your feedback. Please feel free to share your sample document here. We will investigate the scenario and will provide you more information accordingly.

Best Regard,

Is there an updated example of this using the facades library? The example being linked to uses obsolete methods.


http://www.aspose.com/docs/display/pdfnetarchived/Preserve+Extended+Rights+when+Working+with+Forms

Hi there,


Thanks for your interest in Aspose. Please not you found archived documentation link, so getting the issue. Please check correct documentation wiki, it will help you to accomplish your requirements.


Please feel free to contact us for any further assistance.

Best Regards,

The link you posted is the same link that I posted. The facades/form example uses an obsolete constructor & save() method. Are there any further examples that do not use the obsolete calls?




Hi there,


Thanks for your feedback. I am afraid there is some confusion, my shared link is using Aspsoe.Pdf namespace instead Aspose.Pdf.Facades. Please download latest version of Aspose.Pdf for .NET and try following sample code snippet for preserving extended rights while working with PDF Forms. It will help you to accomplish the task.

// Read the source PDF form with
FileAccess of Read and Write.
<o:p></o:p>

// We need ReadWrite permission because after modification,

// we need to save the updated contents in same document/file.

FileStream fs = new FileStream("d:\\pdftest\\Form.pdf", FileMode.Open, FileAccess.ReadWrite);

// Instantiate Document instance

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(fs);

// Get values from all fields

foreach (Aspose.Pdf.InteractiveFeatures.Forms.Field formField in pdfDocument.Form)

{

// If the fullname of field contains A1, perform the operation

if (formField.FullName.Contains("A1"))

{

// Cast form field as TextBox

Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField textBoxField = formField as Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField;

// Modify field value

textBoxField.Value = "Testing";

}

}

// Save the updated document in save FileStream

pdfDocument.Save();

// Close the File Stream object

fs.Close();

Please feel free to contact us for any further assistance.


Best Regards,

Thanks Tilal. I actually attempted the PDF.Document namespace approach first but for some reason the form fields in the document were not present. The loop that iterates through the form was empty. The Facades namespace was the only way I could get data into the form.


When using the PDF.Document namespace, pdfDocument.Form was an empty collection.

If you can offer some reasons as to what the cause/difference is then I could go down this route.

Thanks!

[EDIT] The link you posted also has information on Facades at the bottom of the page, which was the code I am using with the obsolete calls.


Hi there,

Thanks for your feedback. I will appreciate it if you please share your sample code and PDF form here, so I will look into it and guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

I emailed the code/pdf to you for confidentiality reasons.

Hi there,


Thanks for sharing the details via email. Please note you are using dynamic(XFA) PDF form, so you need to update XFA field as following, it will resolve the issue. Moreover please also check working with XFA forms documentation link for more details.

FileStream fs = new
FileStream(myDir+“inputform.pdf”,
FileMode.Open, FileAccess.ReadWrite);
<o:p></o:p>

// Instantiate Document instance

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(fs);

pdfDocument.Form.XFA["form1[0].Page1[0].testName[0]"] = "Test Value!";

pdfDocument.Save();

fs.Close();


Please feel free to contact us for any further assistance.


Best Regards,

That was it! Your help is very much appreciated.


Thank you.

Hi there,


Thanks for your feedback. It is good to know that you have managed to resolve the issue.

Please keep using Aspose and feel free to contact us for any further assistance, we will be more than happy to extend our support.

Best Regards,