{oapdf_gg}
Office software is closely linked to the PDF,the PDF is also must have to control!      Set home Page  Add to Favorites  
You are here:Home > PDF Application > PDF Development
PDF Development
Using C# language the whole PDF document Strategy Guide Graphic
Finishing by: Date:2009-04-17 20:59:48 Popularity: Tags:

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

  • strength is one of the following two constants:
    • PdfWriter. STRENGTH40BITS :40 bit
    • PdfWriter. STRENGTH128BITS :128 bit (Acrobat Reader 5.0 and above support)
  • UserPassword and can ownerPassword empty or zero length, in which case, ownerPassword will be replaced by a random string
  • Permissions for one of the following constants:
    • PdfWriter. AllowPrinting
    • PdfWriter. AllowModifyContents
    • PdfWriter. AllowCopy
    • PdfWriter. AllowModifyAnnotations
    • PdfWriter. AllowFillIn
    • PdfWriter. AllowScreenReaders
    • PdfWriter. AllowAssembly
    • PdfWriter. AllowDegradedPrinting

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 add

the 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 document

Close

very 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.

there isArticle InformationsComment Information
Category column

Site Help | Site Map | Feedback |
OAPDF.COM Copyright 2009 V1.1