  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | How to change a PDF but preserve the rights | How to change a PDF but preserve the rights 2007-12-03 - By Scott Dunbar
Back "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."
I feel like I'm missing something. You've got a PDF that appears to have at least PdfWriter.ALLOW_FILL_IN. If the form has that permission (retrieved from PdfReader.getPermissions()) then your code should allow you to fill in the form. If it has other permissions too then just set the output PDF with the result of PdfReader.getPermissions() using the PdfEncryptor. Something on the order of:
PdfReader reader = new PdfReader( "input.pdf" ); int pdfPermissions = reader.getPermissions(); if( !(pdfPermissions & PdfWriter.ALLOW_FILL_IN)) // throw exception? exit? either way, don't allow the form to be filled
// // modify the pdf contents as needed // PdfEncryptor.encrypt( reader, new FileOutputStream( "output.pdf"), null, null, // no user name and password pdfPermissions, true);
I apologize if I've missed something but it seems that, based on your original question, this is what you wanted.
Leonard Rosenthol wrote: > 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 <mailto:leonardr@(protected)> >> *To:* Post all your questions about iText here >> <mailto:itext-questions@(protected)> >> *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@(protected) >>> <mailto:iText-questions@(protected)> >>> 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@(protected) >> <mailto:iText-questions@(protected)> >> 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@(protected) >> <mailto:iText-questions@(protected)> >> 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@(protected) > https://lists.sourceforge.net/lists/listinfo/itext-questions > Buy the iText book: http://itext.ugent.be/itext-in-action/ >
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> "<font face="Arial" size="2">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."<br> <br> </font><br> I feel like I'm missing something. You've got a PDF that appears to have at least PdfWriter.ALLOW_FILL_IN. If the form has that permission (retrieved from PdfReader.getPermissions()) then your code should allow you to fill in the form. If it has other permissions too then just set the output PDF with the result of PdfReader.getPermissions() using the PdfEncryptor. Something on the order of:<br> <br> PdfReader reader = new PdfReader( "input.pdf" );<br> int pdfPermissions = reader.getPermissions();<br> if( !(pdfPermissions & PdfWriter.ALLOW_FILL_IN))<br> // throw exception? exit? either way, don't allow the form to be filled<br> <br> //<br> // modify the pdf contents as needed<br> //<br> PdfEncryptor.encrypt( reader,<br> new FileOutputStream( "output.pdf"),<br> null, null,  ; // no user name and password<br> pdfPermissions, <br> true);<br> <br> I apologize if I've missed something but it seems that, based on your original question, this is what you wanted.<br> <br> <br> <br> Leonard Rosenthol wrote: <blockquote cite="mid:D76E295E-A3C7-414E-8D44-99C494A588DE@(protected)" type="cite">Nope and nope :(. <div><br class="webkit-block-placeholder"> </div> <div>Leonard</div> <div><br> <div> <div>On Dec 3, 2007, at 9:33 AM, Samuel B. Quiring wrote:</div> <br class="Apple-interchange-newline"> <blockquote type="cite"> <div><font face="Arial" size="2">Leonard,</font></div> <div> </div> <div><font face="Arial" size="2">Is there any documentation anywhere on this? Do you know of an example iText program that I could look at?</font></div> <div> </div> <div><font face="Arial" size="2">-Sam</font></div> <blockquote style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;"> <div style="font-family: arial; font-style: normal; font-variant: normal; font -weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-- -- Original Message -- -- </div> <div style="background: rgb(228, 228, 228) none repeat scroll 0%; -moz-background -clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background -inline-policy: -moz-initial; font-family: arial; font-style: normal; font -variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>From:</b> <a moz-do-not-send="true" title="leonardr@(protected)" href="mailto:leonardr@(protected)">Leonard Rosenthol</a> </div> <div style="font-family: arial; font-style: normal; font-variant: normal; font -weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b> <a moz-do-not-send="true" title="itext-questions@(protected)" href="mailto:itext-questions@(protected)">Post all your questions about iText here</a> </div> <div style="font-family: arial; font-style: normal; font-variant: normal; font -weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b> Monday, December 03, 2007 4:20 AM</div> <div style="font-family: arial; font-style: normal; font-variant: normal; font -weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b> Re: [iText-questions] How to change a PDF but preserve the rights</div> <div><br> </div> 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. <div><br class="webkit-block-placeholder"> </div> <div>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.</div> <div><br class="webkit-block-placeholder"> </div> <div>Leonard</div> <div><br> <div><br> <div> <div>On Dec 3, 2007, at 2:05 AM, Samuel B. Quiring wrote:</div> <br class="Apple-interchange-newline"> <blockquote type="cite"> <div><font face="Arial" size="2">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.</font></div> <div> </div> <div><font face="Arial" size="2">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.</font></div> <div> </div> <div><font face="Arial" size="2">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.</font></div> <div> </div> <div><font face="Arial" size="2">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?</font></div> <div> </div> <div><font face="Arial" size="2">-Sam</font></div> <div style="margin: 0px;">-- ---- ---- ---- ---- ---- ---- ---- ---- -- -- ---- ---- ---- ---- -----</div> <div style="margin: 0px;">SF.Net email is sponsored by: The Future of Linux Business White Paper</div> <div style="margin: 0px;">from Novell.<span class="Apple-converted-space"> </span>From the desktop to the data center, Linux is going</div> <div style="margin: 0px;">mainstream.<span class="Apple-converted-space"> </span>Let it simplify your IT future.< /div> <div style="margin: 0px;"><a moz-do-not-send="true" href="http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4__ ____ ____ ______ __ ____ ____ ____ ____ _____">http://altfarm.mediaplex.com/ad/ck/8857-50307 -18918-4__ ____ ____ ____ ____ ____ ____ ____ ____ ____</a></div> <div style="margin: 0px;">iText-questions mailing list</div> <div style="margin: 0px;"><a moz-do-not-send="true" href="mailto:iText-questions@(protected)">iText-questions@(protected) .sourceforge.net</a></div> <div style="margin: 0px;"><a moz-do-not-send="true" href="https://lists.sourceforge.net/lists/listinfo/itext-questions">https:/ /lists.sourceforge.net/lists/listinfo/itext-questions</a></div> <div style="margin: 0px;">Buy the iText book: <a moz-do-not-send="true" href="http://itext.ugent.be/itext-in-action/">http:/ /itext.ugent.be/itext-in-action/</a></div> </blockquote> </div> <br> </div> </div> <div> <br class="khtml-block-placeholder"> </div> <hr> <div><br class="khtml-block-placeholder"> </div> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----<br> SF.Net email is sponsored by: The Future of Linux Business White Paper<br> from Novell. From the desktop to the data center, Linux is going<br> mainstream. Let it simplify your IT future.<br> <a moz-do-not-send="true" href="http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4">http://altfarm .mediaplex.com/ad/ck/8857-50307-18918-4</a> <div> <br class="khtml-block-placeholder"> </div> <hr> <div><br class="khtml-block-placeholder"> </div> __ ____ ____ ____ ____ ____ ____ ____ ____ ____<br> iText-questions mailing list<br> <a moz-do-not-send="true" href="mailto:iText-questions@(protected)">iText-questions@(protected) .sourceforge.net</a><br> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists /listinfo/itext-questions">https://lists.sourceforge.net/lists/listinfo/itext -questions</a><br> Buy the iText book: <a class="moz-txt-link-freetext" href="http://itext.ugent .be/itext-in-action/">http://itext.ugent.be/itext-in-action/</a><br> </blockquote> <div style="margin: 0px;">-- ---- ---- ---- ---- ---- ---- ---- ---- ------ -- ---- ---- ---- ------</div> <div style="margin: 0px;">SF.Net email is sponsored by: The Future of Linux Business White Paper</div> <div style="margin: 0px;">from Novell.<span class="Apple-converted-space"> </span>From the desktop to the data center, Linux is going</div> <div style="margin: 0px;">mainstream.<span class="Apple-converted-space"> </span>Let it simplify your IT future.< /div> <div style="margin: 0px;"><a moz-do-not-send="true" href="http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4__ ____ ____ ______ __ ____ ____ ____ ____ _____">http://altfarm.mediaplex.com/ad/ck/8857-50307 -18918-4__ ____ ____ ____ ____ ____ ____ ____ ____ ____</a></div> <div style="margin: 0px;">iText-questions mailing list</div> <div style="margin: 0px;"><a moz-do-not-send="true" href="mailto:iText-questions@(protected)">iText-questions@(protected) .sourceforge.net</a></div> <div style="margin: 0px;"><a moz-do-not-send="true" href="https://lists.sourceforge.net/lists/listinfo/itext-questions">https:/ /lists.sourceforge.net/lists/listinfo/itext-questions</a></div> <div style="margin: 0px;">Buy the iText book: <a moz-do-not-send="true" href="http://itext.ugent.be/itext-in-action/">http:/ /itext.ugent.be/itext-in-action/</a></div> </blockquote> </div> <br> </div> <pre wrap=""> <hr size="4" width="90%"> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- 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. <a class="moz-txt-link-freetext" href="http://altfarm.mediaplex.com/ad/ck/8857 -50307-18918-4">http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4</a></pre> <pre wrap=""> <hr size="4" width="90%"> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list <a class="moz-txt-link-abbreviated" href="mailto:iText-questions@(protected) .sourceforge.net">iText-questions@(protected)</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists /listinfo/itext-questions">https://lists.sourceforge.net/lists/listinfo/itext -questions</a> Buy the iText book: <a class="moz-txt-link-freetext" href="http://itext.ugent .be/itext-in-action/">http://itext.ugent.be/itext-in-action/</a> </pre> </blockquote> <br> </body> </html>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- 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@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|
 |