Trying to modify a Reader Enabled XFA-based PDF, without breaking the enablement is near impossible.... I don't recommend it.
Leonard On Dec 6, 2007, at 7:01 AM, Sérgio Oliveira wrote: > Hello, > > I´m also trying to achieve the same: change somes aspects of an > extended PDF file without breaking extended functionality. > > The aspects I´m trying to change using iText is the data section > and the scripts section of the xfa DOM. Using the code below, I´m > able to change both but: > > # if I call stp.AcroFields.Xfa.Changed = true; the rights will be lost > # if I not call stp.AcroFields.Xfa.Changed = true; the data will > not be merged > > Even If I just create a stamper and call > "stp.AcroFields.Xfa.Changed = true;" without changing anything in > the PDF, the rights will be lost, so I suppose this line of code is > the problem. > > So, my question is, what this line of code does? If I don´t call > this property, my data will not be merged, but it will be inside > the PDf, because the resulting PDf is bigger. > > That is way I was wondering if we can call something like this > using code inside the PDF (after the user opened it) instead of > using iText. iText would place the data and the code into the PDF, > but the changed flag would be activated inside the PDF using > LiveCycle designer code. > > Thank you > > > > Code > ////////////////////////////////////////// > PdfReader reader = new PdfReader(Server.MapPath("PDF_RDExtpdf.pdf")); > > PdfStamper stp = new PdfStamper(reader, new FileStream(@"c: > \newpdf.pdf", FileMode.CreateNew), reader.PdfVersion, true); > > XmlDocument doc = new XmlDocument(); > XmlDocument docXFA = new XmlDocument(); > XmlDocument docXFT = new XmlDocument(); > > XmlNamespaceManager oNamespaceMgr = new XmlNamespaceManager > (doc.NameTable); > oNamespaceMgr.AddNamespace("xdp", "http://ns.adobe.com/xdp/"); > oNamespaceMgr.AddNamespace("xfa", "http://www.xfa.org/schema/ > xfa-data/1.0/"); > oNamespaceMgr.AddNamespace("xft", "http://www.xfa.org/schema/ > xfa-template/2.5/"); > > > doc.LoadXml(stp.AcroFields.Xfa.DomDocument.InnerXml); > docXFA.Load(Server.MapPath("data.xdp")); > docXFT.Load(Server.MapPath("scripts.xml")); > > // Data > XmlNodeList nlist = doc.SelectNodes("//xfa:datasets", > oNamespaceMgr); > > for (i = 0; i <= nlist.Count - 1; i++) > { > nlist[i].InnerXml = docXFA.SelectNodes("//xfa:datasets", > oNamespaceMgr).Item(0).ChildNodes[0].OuterXml; > } > > > //scripts > > for (i = 0; i <= nlist.Count - 1; i++) > { > nlist.Item(0).InnerXml = docXFT.ChildNodes[0].OuterXml; > } > > > stp.AcroFields.Xfa.DomDocument.InnerXml = doc.InnerXml; > stp.AcroFields.Xfa.Changed = true; > stp.Close(); > ////////////////////////////////////////////////////////////////////// > / > > > > >> From: Leonard Rosenthol <[EMAIL PROTECTED]> >> Reply-To: Post all your questions about iText here <itext- >> [EMAIL PROTECTED]> >> To: Post all your questions about iText here <itext- >> [EMAIL PROTECTED]> >> Subject: Re: [iText-questions] How to change a PDF but preserve >> the rights >> Date: Mon, 3 Dec 2007 10:58:33 -0500 >> >> Nope and nope :(. >> >> Leonard >> >> On Dec 3, 2007, at 9:33 AM, Samuel B. Quiring wrote: >> >>> Leonard, >>> >>> Is there any documentation anywhere on this? Do you know of an >>> example iText program that I could look at? >>> >>> -Sam >>> ----- Original Message ----- >>> From: Leonard Rosenthol >>> To: Post all your questions about iText here >>> Sent: Monday, December 03, 2007 4:20 AM >>> Subject: Re: [iText-questions] How to change a PDF but preserve >>> the rights >>> >>> It _IS_ possible to fill in a PDF that has been "Reader Enabled" >>> w/ o violating the rights - but it MUST be done in a very >>> specific fashion using "append mode" on the source PDF AND only >>> modifying a limited number of objects in the PDF. >>> >>> So yes, if you are going to create a whole new PDF - you'll >>> break the "Reader Enabling". If you're careful about what you >>> do, and how you do it, you CAN accomplish your goal. >>> >>> Leonard >>> >>> >>> On Dec 3, 2007, at 2:05 AM, Samuel B. Quiring wrote: >>> >>>> I have a PDF containing an XFA form; isXfaPresent() == true. >>>> The PDF was authored so that it can be opened in Adobe Reader, >>>> fields in the form can be filled, and the form can be saved by >>>> Reader to the file system. >>>> >>>> Using iText I have read in the PDF, obtained the XfaForm, >>>> changed values in the XML Document, and written a new PDF to >>>> the file system. >>>> >>>> The PDF I write out contains the values I put into the XML, but >>>> the rights to save the PDF from Reader have been lost. Is this >>>> expected? Other features of the original PDF are also lost in >>>> the newly-written PDF. >>>> >>>> I wrote the changed PDF to a new file. If this is the reason >>>> the save rights were lost, is there a way I can modify the >>>> existing PDF in place so that the rights to save the file from >>>> Adobe Reader are maintained? >>>> >>>> -Sam >>>> ------------------------------------------------------------------- >>>> -- ---- >>>> SF.Net email is sponsored by: The Future of Linux Business >>>> White Paper >>>> from Novell. From the desktop to the data center, Linux is going >>>> mainstream. Let it simplify your IT future. >>>> http://altfarm.mediaplex.com/ad/ck/ >>>> 8857-50307-18918-4_______________________________________________ >>>> iText-questions mailing list >>>> iText-questions@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/itext-questions >>>> Buy the iText book: http://itext.ugent.be/itext-in-action/ >>> >>> >>> >>> -------------------------------------------------------------------- >>> -- --- >>> SF.Net email is sponsored by: The Future of Linux Business White >>> Paper >>> from Novell. From the desktop to the data center, Linux is going >>> mainstream. Let it simplify your IT future. >>> http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 >>> >>> >>> _______________________________________________ >>> iText-questions mailing list >>> iText-questions@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/itext-questions >>> Buy the iText book: http://itext.ugent.be/itext-in-action/ >>> -------------------------------------------------------------------- >>> -- --- >>> SF.Net email is sponsored by: The Future of Linux Business White >>> Paper >>> from Novell. From the desktop to the data center, Linux is going >>> mainstream. Let it simplify your IT future. >>> http://altfarm.mediaplex.com/ad/ck/ >>> 8857-50307-18918-4_______________________________________________ >>> iText-questions mailing list >>> iText-questions@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/itext-questions >>> Buy the iText book: http://itext.ugent.be/itext-in-action/ >> > > >> --------------------------------------------------------------------- >> ---- >> SF.Net email is sponsored by: The Future of Linux Business White >> Paper >> from Novell. From the desktop to the data center, Linux is going >> mainstream. Let it simplify your IT future. >> http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > > >> _______________________________________________ >> iText-questions mailing list >> iText-questions@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/itext-questions >> Buy the iText book: http://itext.ugent.be/itext-in-action/ > > _________________________________________________________________ > Don't just search. Find. Check out the new MSN Search! http:// > search.msn.click-url.com/go/onm00200636ave/direct/01/ > > > ---------------------------------------------------------------------- > --- > SF.Net email is sponsored by: The Future of Linux Business White Paper > from Novell. From the desktop to the data center, Linux is going > mainstream. Let it simplify your IT future. > http://altfarm.mediaplex.com/ad/ck/ > 8857-50307-18918-4_______________________________________________ > iText-questions mailing list > iText-questions@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/itext-questions > Buy the iText book: http://itext.ugent.be/itext-in-action/ ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/