Hello I have a pdf template with a form with the Extended features enable. After filling in the fields of this form using iTextSharp, a user with acrobat reader gets the error message:
"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."
I have been looking for a solutions and saw a couple posts on the subject so... Is there a way to keep the extended features enabled and modifying the pdf with iTextSharp ?
pdfTemplate = "\\template_evalform\EvaluationForm.pdf"
Dim newFile As String = "\\cdpharma-svr\www\vvp\media\_temp\" & test & "-Eval.pdf"
Dim pdfReader As New PdfReader(pdfTemplate)
Dim pdfStamper As New PdfStamper(pdfReader, New FileStream(newFile, FileMode.Create), "\0", True)
Dim pdfFormFields As AcroFields = pdfStamper.AcroFields
pdfFormFields.SetField("field_name", "bla bla bla")
Im not able to make the PDF extended features to work. Im following your recomendations :S
Dim fs As New IO.FileStream(fileName, IO.FileMode.Create)
Dim pdf As New PdfReader(templateName)
Dim pdfStm As New PdfStamper(pdf, fs, "\0", True)
Dim fields As AcroFields = pdfStm.AcroFields
fields.SetField(ParquesIndustriales.FIELD_NOMBRE, drParque(ParquesIndustriales.FIELD_NOMBRE))
fields.SetField(ParquesIndustriales.FIELD_DIRECCION, drParque(ParquesIndustriales.FIELD_DIRECCION))
pdfStm.FormFlattening = False
pdfStm.Close()
fs.Close()
I'm using Itextsharp v5.05 and created enabled reader pdf files. I wrote a c# class that fill the form and keep each individual pdf file extended reader. But, when I use this MergeFiles function here it create a new Merged file NOT extended reader and I
need your help with this please ...
my MergeFiles function is :
public static void MergeFiles(string destinationFile, string[] sourceFiles)
{
try
{
//1: Create the MemoryStream for the destination document.
using (MemoryStream ms = new MemoryStream())
{
//2: Create the PdfCopyFields object.
PdfCopyFields copy = new PdfCopyFields(ms);
// - Set the security and other settings for the destination file.
//copy.Writer.SetEncryption(PdfWriter.STRENGTH128BITS, null, "1234", PdfWriter.AllowPrinting | PdfWriter.AllowCopy | PdfWriter.AllowFillIn);
copy.Writer.ViewerPreferences = PdfWriter.PageModeUseOutlines;
// - Create an arraylist to hold bookmarks for later use.
ArrayList outlines = new ArrayList();
int pageOffset = 0;
int f = 0;
//3: Import the documents specified in args[1], args[2], etc...
while (f < sourceFiles.Length)
{
// Grab the file from args[] and open it with PdfReader.
string file = sourceFiles[f];
PdfReader reader = new PdfReader(file, PdfEncodings.ConvertToBytes("1234", null));
// PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create), '\0', true);
// Import the pages from the current file.
copy.AddDocument(reader);
// Create an ArrayList of bookmarks in the file being imported.
// ArrayList bookmarkLst = SimpleBookmark.GetBookmark(reader);
// Shift the pages to accomidate any pages that were imported before the current document.
// SimpleBookmark.ShiftPageNumbers(bookmarkLst, pageOffset, null);
// Fill the outlines ArrayList with each bookmark as a HashTable.
// foreach (Hashtable ht in bookmarkLst)
// {
// outlines.Add(ht);
// }
// Set the page offset to the last page imported.
pageOffset += reader.NumberOfPages;
f++;
}
//4: Put the outlines from all documents under a new "Root" outline and
// set them for destination document
// copy.Writer.Outlines = GetBookmarks("Root", ((Hashtable)outlines[0])["Page"], outlines);
//5: Close the PdfCopyFields object.
copy.Close();
//6: Save the MemoryStream to a file.
MemoryStreamToFile(ms, destinationFile);
}
}
catch (System.Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e.StackTrace);
Console.ReadLine();
}
}
#endregion
#region MemoryStreamToFile
/// <summary>
/// Saves a MemoryStream to the specified file name
/// </summary>
/// <param name="MS">MemoryStream to save</param>
/// <param name="FileName">File name to save MemoryStream as</param>
public static void MemoryStreamToFile(MemoryStream MS, string FileName)
{
using (FileStream fs = new FileStream(@FileName, FileMode.Create))
{
byte[] data = MS.ToArray();
fs.Write(data, 0, data.Length);
fs.Close();
}
}
#endregion
Member
12 Points
125 Posts
ITextSharp > Enable Extended Features
Aug 18, 2010 04:06 PM|Alex_808|LINK
Hello I have a pdf template with a form with the Extended features enable. After filling in the fields of this form using iTextSharp, a user with acrobat reader gets the error message:
Member
631 Points
164 Posts
Re: ITextSharp > Enable Extended Features
Aug 24, 2010 02:32 AM|kuujinbo|LINK
There was a recent update in SVN that may solve your problem:
http://itextsharp.svn.sourceforge.net/viewvc/itextsharp/
You need you download and build the solution.
http://kuujinbo.info/ | HTTP 301
Member
12 Points
125 Posts
Re: ITextSharp > Enable Extended Features
Aug 26, 2010 10:00 AM|Alex_808|LINK
I still have the same problem
Member
631 Points
164 Posts
Re: ITextSharp > Enable Extended Features
Aug 26, 2010 10:22 AM|kuujinbo|LINK
[1] did you build the source from trunk?
[2] are you properly using append mode?
pr => PdfReader object w/form
fs => Stream object for output file
http://kuujinbo.info/ | HTTP 301
Member
12 Points
125 Posts
Re: ITextSharp > Enable Extended Features
Aug 26, 2010 11:14 AM|Alex_808|LINK
Sir, i love you. (hade to specified append to true)
Thank you!!
None
0 Points
2 Posts
Re: ITextSharp > Enable Extended Features
Oct 19, 2010 01:00 PM|rajeev2012|LINK
I am having the same issue and have used the same suggested code, please see below, yet the problem persists...
PdfReader pr = new PdfReader(iFile);
System.IO.FileStream fs = new FileStream(oFile, System.IO.FileMode.CreateNew, FileAccess.ReadWrite);
PdfStamper ps = new PdfStamper(pr, fs, '\0', true);
AcroFields pf = ps.AcroFields;
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">PdfReader pr = new PdfReader(iFile);</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> System.IO.FileStream fs = new FileStream(oFile, System.IO.FileMode.CreateNew, FileAccess.ReadWrite);</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> PdfStamper ps = new PdfStamper(pr, fs, '\0', true);</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> AcroFields pf = ps.AcroFields;</div>pf.SetField("Form5_Dtls[0].Page1[0].CIN_C[0]", "U74140MH2007PTC170726");
Your help is appreciated ...
Member
12 Points
125 Posts
Re: ITextSharp > Enable Extended Features
Oct 21, 2010 03:53 PM|Alex_808|LINK
Hello, i can give you the code i used
None
0 Points
2 Posts
Re: ITextSharp > Enable Extended Features
Oct 22, 2010 12:50 AM|rajeev2012|LINK
Hi Alex
I have used the same code as well I am closing Filstream as well as pdfstamper. But, no luck ...
I have also tried to fill it through XML data (xfa.fill) but that fails, too.
Regards
Rajeev
None
0 Points
1 Post
Re: ITextSharp > Enable Extended Features
Nov 13, 2010 05:30 PM|B List|LINK
I just had to say that I love you too.
Adding append=true fixed my problem. That also required me to set ps.FormFlattening = false. (which is fine)
None
0 Points
1 Post
Re: ITextSharp > Enable Extended Features
Jan 18, 2011 07:49 PM|hugofloresgomez|LINK
Hi.
Im not able to make the PDF extended features to work. Im following your recomendations :S
Im using iTextSharp v 5.0.5.0 .... any help???
None
0 Points
1 Post
Re: ITextSharp > Enable Extended Features
Jun 22, 2011 01:46 PM|JIV|LINK
It is working for me with iTextSharp 5.1.1.0. Thanks to this thread for the solution!
None
0 Points
5 Posts
Re: ITextSharp > Enable Extended Features
Jun 28, 2011 10:34 AM|machanian|LINK
I'm using Itextsharp v5.05 and created enabled reader pdf files. I wrote a c# class that fill the form and keep each individual pdf file extended reader. But, when I use this MergeFiles function here it create a new Merged file NOT extended reader and I need your help with this please ...
my MergeFiles function is :