locked
ITextSharp > Enable Extended Features RRS feed

  • Question

  • User195343576 posted

    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 ?
    Wednesday, August 18, 2010 4:06 PM

All replies

  • User1520641890 posted

    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.

    Tuesday, August 24, 2010 2:32 AM
  • User195343576 posted

    I still have the same problem


    Thursday, August 26, 2010 10:00 AM
  • User1520641890 posted

    [1] did you build the source from trunk?

    [2] are you properly using append mode?

    PdfStamper ps = new PdfStamper(pr, fs, '\0', true);

    pr => PdfReader object w/form

    fs => Stream object for output file

    Thursday, August 26, 2010 10:22 AM
  • User195343576 posted

    Sir, i love you. (hade to specified append to true)


    Thank you!! Laughing


    Thursday, August 26, 2010 11:14 AM
  • User-1590953342 posted

    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;

    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;

                    pf.SetField("Form5_Dtls[0].Page1[0].CIN_C[0]", "U74140MH2007PTC170726"); 


    Your help is appreciated ...

    Tuesday, October 19, 2010 1:00 PM
  • User195343576 posted

    Hello, i can give you the code i used 


    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")
    pdfStamper.Close() 'did you try closing it?




    Thursday, October 21, 2010 3:53 PM
  • User-1590953342 posted

    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


    Friday, October 22, 2010 12:50 AM
  • User1525893568 posted

    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)

    Saturday, November 13, 2010 5:30 PM
  • User-799268285 posted

    Hi.


    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()

    Im using iTextSharp v 5.0.5.0 .... any help???

    Tuesday, January 18, 2011 7:49 PM
  • User1683384398 posted

    It is working for me with iTextSharp 5.1.1.0. Thanks to this thread for the solution!

    Wednesday, June 22, 2011 1:46 PM
  • User-1206350641 posted

    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

     

    Tuesday, June 28, 2011 10:34 AM