{oapdf_gg}
u encryption open a document before the one thing we need to do is encrypted (if you want to encrypt the document), to achieve this purpose, you can use the following methods: public void setEncryption (boolean strength, String userPassword, String ownerPassword, int permissions);
the 0109 features, see the sample code and sample code 0110. writer.setEncryption (PdfWriter.STRENGTH40BITS, null, null, PdfWriter.AllowCopy); sample code generated 0109 document can be opened without a password, but users can not print, modify the document. writer.setEncryption (PdfWriter.STRENGTH128BITS, "userpass", "ownerpass", PdfWriter.AllowCopy | PdfWriter.AllowPrinting); hit you try to open the sample code generated 0110 document, will be asked to enter a password ( 'userpass'), because of AllowPrinting parameters, you can print the document without any problem. fourth step addthe first step in explaining the different steps to the third example, you may have encountered a number of objects such as Phrase, Paragraph, such as in the next few chapters, all of these issues will be explained in detail. sometimes a writer you may want to have deliberately ignored the document, such as sample code 0111: When we created the two writer:writerA and writerB: PdfWriter writerA = PdfWriter.getInstance (document, new FileStream ( "Chap0111a.pdf", FileMode.Create )); PdfWriter writerB = PdfWriter.getInstance (document, new FileStream ( "Chap0111b.pdf", FileMode.Create )); we can create the nuances of the two documents: writerA.Pause (); document.add (new Paragraph ( "This paragraph will only be added to Chap0111b.pdf, not to Chap0111a.pdf ")); writerA.resume (); you can compare the document: Chap0111a.pdf and Chap0111b.pdf the difference between the fifth step, close the documentClosevery important document because it will shut down and is running the Writer to write the contents of documents, the method is called in the final, you should always close the document. Advanced Topics:reading PDF files part of the contents of the introduced only iText generated PDF document format and PDF format files can not resolve, not translation. |