Some test text!


Opening a document

The PDFDoc constructor creates a PDF document from scratch:

PDFDoc new_doc = new PDFDoc();

A newly-created document does not yet contain any pages. See the Working with Pages section for details on creating new pages and working with existing pages.

Using PDFTron SDK, you can open a document from a serialized file, from a memory buffer, or from a Filter stream.

To open an existing PDF document from a file, specify its file path in the PDFDoc constructor:

PDFDoc mydoc = new PDFDoc("in.pdf");

Here's how to open an existing PDF document from a memory buffer:

FileStream stm = new FileStream("in.pdf",
  FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(stm);
byte[] buffer = reader.ReadBytes(
  (int) reader.BaseStream.Length);
PDFDoc mydoc = new PDFDoc(buffer);

It's also easy to open a PDF document from a MemoryFilter or a custom Filter such as HTTPFilter.

After creating a PDFDoc object, it's good practice to call InitSecurityHandler() on it. If the document is encrypted, calling the method will decrypt it. If the document is not encrypted, calling the method is harmless.

PDFDoc doc = new PDFDoc("in.pdf");
if (!doc.InitSecurityHandler())
  Console.WriteLine("Document authentication error...");

PDFTron SDK security API is explained in details in the Security and PDF Security sections.

Get the anwsers you need: Support