GETTING STARTED GUIDE

PDF Technologies, Inc.

Overview

PDFTechLib is a .NET class library used to create, edit and otherwise manipulate PDF documents. The library does not require the use of Adobe products and is NOT a print driver.

You can create stylish PDF documents with just a few lines of code. The intuitive object model allows developers to quickly adopt and understand the wealth of code samples provided with our standard package.

You will be able to fill PDF e-forms, merge multiple documents, split existing PDF documents into multiple documents and finally create your own PDF documents using existing PDF documents as templates or from scratch.

The library is written in 100% C# managed code. This versatile library can be used in all kinds of ASP.NET applications. It can even run in restricted hosting environments.

PDFTechLib is licensed per developer and can be distributed ROYALTY FREE. Unlike other complicated and restrictive licensing plans, our simple licensing structure will allow you to quickly get started with development.

Creating a PDF document is as easy as the sample code below:

// If you purchased a license key, set the license like this: // PDFDocument.License = "JRO1F2MS-2021-188-J004A"; PDFDocument doc = new PDFDocument("sample.pdf"); doc.CurrentPage.Body.SetActiveFont("Arial", PDFFontStyles.Regular,12, Charset.ANSI_CHARSET, Color.Red); doc.CurrentPage.Body.AddText("Wow! What a good looking PDF Document!"); doc.Save();

2

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

SYSTEM REQUIREMENTS & DISTRIBUTION

PDFTechLib requires the following

• .Net Framework 4.0 or higher • Visual Studio 2010 or higher • Windows XP (x86) with Service Pack 3 or higher OS • 32-Bit (x86) or 64-Bit (x64) • 2 GB RAM or more

HOW TO INSTALL

After downloading the archive, run the installation package and follow the installation instructions.

HOW TO DISTRIBUTE

Programmers can distribute “PDFTechLib.dll” in their solutions.

The license key must be embedded in the solution code.

.Net Framework 4.0 must be present in target machines. Generally, ASP.NET Shared Hosting environments are restricted and most components cannot be run in these environments.

PDFTechLib.dll library is fully functional with minimum trust level in tightly restricted ASP.net environments. The exceptions to this are listed below:

• Signing PDF documents is not possible in restricted environments.

• EMF, HTML, XML to PDF feature cannot be used.

• Using installed system fonts is not possible because the Library requires access to the Widows/Font directory.

If you wish to use these features, the library must be given Full trust Level. If you find that your code works well on your development machine and not on the deployed target machine, more than likely the problem has to do with permissions.

3

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

ASP.NET projects can be given full trust by inserting the following section into the project’s web.config file:

More information on trust levels can be found here: http://msdn.microsoft.com/en-us/library/wyts434y.aspx

For executable code or console applications, the “Run as Administrator” option must be used in restricted environments.

To automate the “UAC administrator mode” you must add the following in the "App.manifest" file.

4

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

FEATURES

The main features of PDFTechLib are outlined below:

FONTS Standard Fonts True Type Fonts Open Type Fonts CJK Fonts Unicode Various char set Fonts embedding TEXT GENERATION Text Format Options Multiple Columns Auto Text Justified Texts Text Boxes Tagged texts DRAWING Various Shapes Hatch Brush Gradient Brush Layers IMAGES Vector images( EMF ,WMF support) Scalar Images Mask Transparency Stamps Watermarks INTERACTIVITY Acroforms Form filling Flatten Acroform Objects Form filling with XML, FDF or XFDF Attachments Annotations Bookmarks Actions

5

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

PAGE ELEMENTS Margins Header and footer Unit of Measure Page Transitions Auto Page Numbering Thumbnails Tables SETTINGS Document Properties Custom Properties Page Orientation Page Sizes Viewer Preferences SECURITY Encryption and Decryption Digital Signatures Recover owner password CONVERSION AND REPORTING HTML to PDF XML to PDF Text to PDF Tiff to PDF with CCITT Fax compression Text Extraction MISC. FEATURES PDF Page Templates Split, Merge and Extract functions PDF/A-1b : 2005 Compatible

6

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

DEVELOPER’S GUIDE

The Object Model

Every PDF document has a pages collection and pages in that collection.

Each page in return has a body which may contain images, text, a table and annotations.

For a full list of objects, methods and their properties, please refer to our online help pages.

7

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Getting started with your first PDF generation

Creating PDF documents is a breeze with PDFTechLib.

Following a series of easy steps is all you will need to create PDF document.

Declare your references

First, you need to declare the references to PDFTechLib. Using Visual Studio.NET, add a reference to your project to PDFTechLib.dll assembly.

Add the following line at the beginning of your code using PDFTech;

Create the document

Now create the instance of the PDFDocument class.

PDFDocument doc = new PDFDocument(“sample.pdf” );

Start adding content

After creating the page, you need to add content. To do this set the properties of the body object. By setting the Body properties you can render text and images on the page.

Here is how to accomplish this: doc.CurrentPage.Body.SetActiveFont("Arial",PDFFontStyles.Regular,12, Charset.ANSI_CHARSET, Color.Red); doc.CurrentPage.Body.AddText("Wow. That was easy!"); //now save the document doc.Save();

8

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Creating Content

PDFTechLib contains a wide array of tools and methods to create content on a PDF page. Content is images, text, shapes, curves, tables and lines.

The text can be aligned in any direction giving you the power to create effective documents.

When creating content on a page you can rely on the default coordinates or take into account the margin system. Read more about this in the “Page Margins” section.

Creating PDF/A compliant content

PDF/A is in fact a subset of PDF, leaving out PDF features not suited to long-term archiving. In addition, the standard places requirements on software products that read PDF/A files. A "conforming reader" must follow certain rules including following color management guidelines, using embedded fonts for rendering, and making annotation content available to users.

The Standard does not define an archiving strategy or the goals of an archiving system. It identifies a "profile" for electronic documents that ensures the documents can be reproduced the exact same way in years to come. A key element to this reproducibility is the requirement for PDF/A documents to be 100 % self-contained. All of the information necessary for displaying the document in the same manner every time is embedded in the file. This includes, but is not limited to, all content (text, raster images and vector graphics), fonts, and color information. A PDF/A document is not permitted to be reliant on information from external sources (e.g. font programs and hyperlinks).

Source: Wikipedia

Sample code:

PDFCreationOptions options = new PDFCreationOptions(); //Set the Compliance standard for PDF/A options.ComplianceStandard = PDFStandards.PDFA1b; PDFDocument MyPDF = new PDFDocument("PDFA.pdf", options); MyPDF.CurrentPage.Body.AddText("This creates a PDF/A document."); //Incompliant actions will throw exceptions when you call save method. Example: Encryption transparent images etc. Most of the PDF/A requirements will be taken care of automatically by the library. Such as font embedding, ICC Profiles etc. MyPDF.Save();

9

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Flowing Text and Column Support Our library exposes many unique methods to allow programmers who wish to generate long and content rich documents.

PDF documents offer a unique versatility in Content Management scenarios where documents need to be generated based on complex business rules. Insurance policies, corporate documents etc. are all generated based on rules or situations.

PDFTechLib does not use the page body as a graphical canvas object. All you have to do is create the object, set page size and column count, optionally set page margins, optionally set active font and size, then start adding text or tagged text or image(s) as required. All formatting, word wrapping, placing text to columns, creating paragraphs will be done by the library. You do not need to calculate any complex positioning.

The “AddText” and “AddTaggedText” methods allow you to add text form the cursor position.

Sample:

PDFCreationOptions options = new PDFCreationOptions(); options.PageSize = PDFPageSize.A4; options.SetMargin(50, 70, 50, 70); PDFDocument MyPDF = new PDFDocument("Sample.pdf", options); MyPDF.CurrentPage.Body.SetColumnCount(ColumnCount.TwoColumn); MyPDF.CurrentPage.Body.SetActiveFont("Arial", PDFFontStyles.Underline, 12); MyPDF.CurrentPage.Body.AddText("This is a flowing text. This can be as long as you wish. Line breaks are interpreted as a paragraph."); MyPDF.CurrentPage.Body.AddTaggedText("Here is the tagged text sample Please visit us."); MyPDF.CurrentPage.Body.AddImage(new PDFImage("sample.bmp")); MyPDF.Save();

10

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

TrueType and OpenType Fonts

PDFTechLib supports the use of both TrueType and Open Type fonts.

The SetActiveFont method allows you to switch between any types of font throughout a document. PDFTechLib can automatically use the system fonts.

You can easily embed the fonts you wish into the final document so that the document looks exactly the way it was intended in its final destination.

How to use a TrueType font: doc.CurrentPage.Body.SetActiveFont("verdana",PDFFontStyles.Regular, 12); doc.CurrentPage.Body.AddText("This text uses Verdana font, size 12 and the font is embedded");

** If a font needs to be bold or italic that font is searched for and embedded into the PDF document, if the font cannot be found then the font is imitated.

11

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Specifying an alternate font directory name

Make sure that you use the notation below to set the location of the alternate font directory. You have to use the “Server.MapPath” notation to ensure that you have access to this directory. Make sure that you have access to the entire path not just the folder at the end. This is especially useful in restricted environments where your code does not have access to the Windows/Fonts directory.

Here is how this can be done:

PDFCreationOptions options = new PDFCreationOptions(); options.LeftMargin = 20; options.RightMargin = 0; string fontDirectory = Server.MapPath(@"fonts"); options.FontDirectory = fontDirectory; PDFDocument MyPDF = new PDFDocument("test.pdf", options); MyPDF.DocumentInfo.Title = "test pdf"; MyPDF.AutoLaunch = true; string fontName = "MyriadPro"; MyPDF.PageHeader.SetActiveFont(fontName, PDFFontStyles.Bold, 18); MyPDF.PageHeader.SetTextAlignment(PDFTech.TextAlign.Center); MyPDF.PageHeader.AddText("PDF Document Generation Sample");

MyPDF.CurrentPage.Body.SetActiveFont(fontName, PDFFontStyles.Bold, 28); MyPDF.CurrentPage.Body.AddText("MyriadPro - o O y Y");

MyPDF.CurrentPage.Body.AddText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut id arcu sit amet massa malesuada sagittis. ");

MyPDF.Save();

12

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Tagged Text PDFTechLib provides support for a subset of HTML Tag Name Description tags. The usage of XHTML is required. Bold Italic The following methods support html formatted tagged Strikethrough text AddTaggedText, TaggedTextBox, Table.Cell.Value
new line Underline

Font Superscript Subscript Hyperlink

Paragraph


Horizontal line

13

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

TextOut Text Out is one of the basic functions of the library. You can place text anywhere on the page by specifying coordinates.

Sample:

PDFDocument MyPdf = new PDFDocument("Textoutsample.pdf"); MyPdf.CurrentPage.Body.TextOut(13, 133, 0, "Jim Jones", HorJust.Left, VertJust.Top); ...... MyPdf.Save();

14

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

TABLES

One of the most common scenarios of usage for our library is data reporting. PDFTechLib supports cascading data styling in addition to basic features to support the generation of tables for reporting.

You may merge cells horizontally or vertically to create flexible table structures.

- Automatic column width calculations - Automatic Row Height calculations - Column header replication - Text alignment in cells (left, right, center, up, down, middle) - Flexible cell content (Text, Tagged text, image) - Support for sophisticated styling for table and cell content (table, header, column header, row, column and cell based) - Easy to understand object structure

Sample basic code:

PDFDocument MyPDF = new PDFDocument("Tables.pdf"); Table table = new Table(2,2); table.DisplayHeader = true; table.column(0).header.SetValue("Name"); table.column(1).header.SetValue("Surname"); table.cell(0, 0).SetValue ( "John"); table.cell(0, 1).SetValue("Smith"); table.cell(1, 0).SetValue("Joe"); table.cell(1, 1).SetValue("Doe"); MyPDF.CurrentPage.Body.DrawTable(table); MyPDF.Save();

15

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Text Boxes (Text Areas) Text boxes are a powerful mechanism. You may position a text box anywhere on a page and fill it with text or tagged text. Word wrapping, Text alignment and positioning in this rectangle are automatically handled by the library. You may also create a body style for text boxes.

Sample:

PDFDocument MyPdf = new PDFDocument("TextBox.pdf"); MyPdf.CurrentPage.Body.AddTextArea(new RectangleF(27, 27, 200, 200), "These lines of text are top left aligned. These lines of text are top left aligned.", true); MyPdf.Save();

16

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

USING TEMPLATES

PDFTechLib allows you to use pre-existing PDF documents as templates for new document creation. By using templates you can avoid having to code for certain visual aspects of the final output.

A good example is using a letterhead template for letters. Because the letterhead components such as the logo, header and footer are likely to stay the same, you can create the template using popular layout tools such as Adobe In-design and use the template over and over again to fill it with letter text.

Sample:

PDFCreationOptions options = new PDFCreationOptions(); options.TemplateFileName = "template1.pdf"; options.TemplatePageNumber = 1; options.SetMargin(105, 200, 105, 133); PDFDocument MyPdf = new PDFDocument("mydoc.pdf", options); MyPdf.CurrentPage.Body.SetColumnCount(ColumnCount.TwoColumn); MyPdf.CurrentPage.Body.AddText("What a nice template."); MyPdf.Save();

17

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Supported Page Sizes PDFTechLib allows the creation of PDF documents using different Page Size Pixel Height Pixel Width page sizes. The size of the paper is controlled through its width Letter 792 612 and height properties. The orientation can also be controlled. A4 842 595 A3 1190 842 The following page sizes are supported: Legal 1008 612 B5 728 516 C5 649 459 8x11 792 595 B4 1031 728 A5 595 419 Folio 936 612 Executive 756 522 EnvB4 1031 728 EnvB5 708 499

EnvC6 459 323 EnvDL 623 312 EnvMonarch 540 279 Env9 639 279 Env10 684 297

Env11 747 324 Unit of Measure

You can specify the precise position of text and images on a page using a variety of units of measure such as inches, millimeters, centimeters, and pixels. The default is pixels.

Example:

PDFCreationOptions options = new PDFCreationOptions(); options.UnitOfMeasure = UnitOfMeasure.Inch; PDFDocument doc = new PDFDocument("sample.pdf" ,options); doc.CurrentPage.Body.Shapes.DrawLine(new PDFPen(), 1, 1, 5, 1); doc.Save();

18

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Page margins PDFTechLib allows you to define page margins. All positioning then becomes relative to these margins. To that effect, an image or text positioned at (0, 0) would actually be positioned at the top left corner defined by the page margins.

Sample:

PDFCreationOptions options = new PDFCreationOptions(); options.UnitOfMeasure = UnitOfMeasure.Inch; options.LeftMargin = 0.5; options.TopMargin = 1; options.RightMargin = 0.5; options.BottomMargin = 1;

PDFDocument doc = new PDFDocument("sample.pdf", options);

//X is relative to page margins. 0 means the position on the left margin. int posX = 0; //Y is relative to page margins. 0 means the position on the top margin. int posY = 0; //Orientation can be 0 to 360 degree int textOrientation = 0; doc.CurrentPage.Body.TextOut(posX, posY, textOrientation, "Wow, what a wonderful margin."); doc.Save();

19

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

UNICODE SUPPORT

Unicode characters are supported using a simple parameter.

Supported CJK fonts (Far East)

• MonotypeHeiMedium • MonotypeSungLight • SinoTypeSongLight • HeiseiKakuGothicW5 • HeiseiMinchoW3 • HanyangSystemsGothicMedium • HanyangSystemsShinMyeongJoMedium

Sample:

PDFDocument MyPDF = new PDFDocument("Unicode.pdf"); MyPDF.CurrentPage.Body.SetActiveFont("Tahoma", PDFFontStyles.Regular, 12, Charset.GREEK_CHARSET); MyPDF.CurrentPage.Body.AddText("εγγράφων σχετικά µε τη µύγα από οποιαδήποτε. εφαρµογή δικτύου. Η βιβλιοθήκη δεν"); MyPDF.Save();

20

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Importing existing PDF files

Existing PDF files can be updated to include new content. You can insert new pages into an existing PDF document at any position.

Manipulation of PDF documents

Existing PDF documents can be manipulated using PDFTechLib. You may merge multiple PDF files or to split a PDF file to individual pages. You may extract text out of PDF documents and alter the document security. Extraction of individual pages from existing PDF documents is also possible.

Merging PDF files

Multiple PDF files can be with a single line of code.

Sample:

PDFDocument doc = new PDFDocument("merge.pdf"); doc.LoadPdf("sample.pdf",""); doc.LoadPdf("document.pdf", ""); doc.Save();

Splitting PDF files

A PDF file can be split into multiple individual pages. Each page can then be saved as an individual PDF document.

Use the following source to automatically split a PDF file into multiple pages:

Sample:

PDFOperation operation = new PDFOperation("sample.pdf", ""); operation.SplitFile("target.pdf");

Sample.pdf is the original file to be split. Target.pdf is the name that will be used for all individual files that will be created as a result of the split operation.

21

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

TEXT EXTRACTION

PDF documents with text content can be scanned for text and the document text can be extracted.

Text extraction from PDF documents is a very important feature that can be very useful in certain scenarios. In cases where documents need to be searched for a specific text or abstract needs to be generated from one or more PDF documents, this feature is priceless.

The library provides many different options to extract specific pages. It also provides an option to extract text in flowing or physical format.

The following example extracts all pages in the “sample.pdf” and writes to the “sample.txt” using flowing style.

Sample: string Error = ""; //open the pdf document PDFOperation operation = new PDFOperation("c:\\sample.pdf", "");

//retrieve page count int pageCount = operation.GetPageCount(out Error); if (Error == "") { if (!operation.ExtractText(0, pageCount, LayoutType.Flowing, EncodingType.UTF8, false, true, false, "C:\\sample.txt", out Error)) Console.WriteLine(Error); } else { Console.WriteLine(Error); }

22

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

TEXT EXTRACTION FROM A SPECIFIC LOCATION OF A PDF DOCUMENT

Text can be extracted from a specific location of the PDF document. The rectangle denotes the coordinates on the page.

PDFOperation op = new PDFOperation("sample.pdf", ""); int pageNumber = 1; string text = op.ExtractText(pageNumber, new RectangleF(880, 740, 120, 20), UnitOfMeasure.Pixel); op.Close(); Console.WriteLine(text);

23

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

NUMBERING PAGES

You may choose from many page numbering styles. The following sample demonstrates, page numbering applied to the first three pages as Roman Style (I,II,III…) . Then starting from page 4, page numbering is restarted from 1 as regular style (1,2,3..)

The last page numbering style will continue to the end of the document.

Sample:

//Add Roman style Page Numbering range for the intro pages PageNumberingRange pnrintro = MyPDF.AddNumberingRange(0, 1); ; pnrintro.NumberingStyle = NumberingStyle.LowerCaseRoman;

//Add Regular Page Numbering range starting from page 4 PageNumberingRange pnrsections = MyPDF.AddNumberingRange(3, 1); ; pnrintro.NumberingStyle = NumberingStyle.Regular;

Links

You may embed URL links in PDF documents. Supported link types are URL links, File Links, Internal and External document links also called web links.

Sample:

PDFDocument MyPDF = new PDFDocument("Link.pdf"); MyPDF.CurrentPage.Body.AddTaggedText("Text web link", true); MyPDF.CurrentPage.Body.DrawTable(table); MyPDF.Save();

40

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Adding an Annotation to a PDF document

You can use the sample code below to add a Text or Rubber stamp annotation to an existing PDF document.

Sample: PDFDocument MyDocument = new PDFDocument("Sample.pdf"); PDFPage page = MyPDF.CurrentPage; page.Body.SetActiveFont("Helvetica", PDFFontStyles.Bold, 10); page.Body.TextOut(26, 60, 0, "Text Annotations");

//Text annotations page.Body.AddTextAnnotation("Comment", "Comment Annotation", TextAnnotationIcon.Comment, new RectangleF(26, 80, 100, 100)); page.Body.SetActiveFont("Helvetica", PDFFontStyles.Regular, 8); page.Body.TextOut(26, 106, 0, "Comment"); page.Body.AddTextAnnotation("Insert", "Insert Annotation", TextAnnotationIcon.Insert, new RectangleF(239, 80, 100, 100)); page.Body.TextOut(239, 106, 0, "Insert"); page.Body.AddTextAnnotation("Key", "Key Annotation", TextAnnotationIcon.Key, new RectangleF(346, 80, 100, 100)); page.Body.TextOut(346, 106, 0, "Key");

//Rubber stamp annotations page.Body.SetActiveFont("Helvetica", PDFFontStyles.Bold, 10); PDFRubberStampAnnotation rsa = page.Body.AddRubberStampAnnotation("Approved", "Approved annotation", RubberStampAnnotationIcon.SBApproved, new RectangleF(26, 186, 100, 30)); rsa.Opacity = 50; page.Body.SetActiveFont("Helvetica", PDFFontStyles.Regular, 8); page.Body.TextOut(26, 240, 0, "Approved"); page.Body.AddRubberStampAnnotation("Completed", "Completed annotation", RubberStampAnnotationIcon.SBCompleted, new RectangleF(160, 186, 100, 30)); page.Body.TextOut(160, 240, 0, "Completed"); page.Body.AddRubberStampAnnotation("Confidential", "Confidential annotation", RubberStampAnnotationIcon.SBConfidential, new RectangleF(293, 186, 100, 30)); page.Body.TextOut(293, 240, 0, "Confidential"); MyDocument.Save();

41

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Custom Watermarks

The sample below shows how a watermark can be added to an existing PDF document.

Sample: PDFCreationOptions options = new PDFCreationOptions(); options.Watermark.SetText("Approved"); PDFDocument MyDocument = new PDFDocument("Watermarks.pdf",options); MyDocument.PageHeader.SetTextAlignment(TextAlign.Center); MyDocument.PageHeader.AddText("Watermarks Sample"); MyDocument.PageHeader.Shapes.DrawLine(new PDFPen()); MyDocument.PageFooter.Shapes.DrawLine(new PDFPen()); MyDocument PDF.PageFooter.AddText("Watermarks Sample"); MyDocument.AutoLaunch = true; MyDocument.DocumentInfo.Title = "Demo [Watermarks]"; MyDocument.Save();

How to create a PDF document using a stream:

The sample below shows how a PDF document can be created using a stream.

Sample: PDFDocument MyDocument = new PDFDocument("TestDocument.pdf"); MyDocument.AutoLaunch = true; FileStream fileStream = new FileStream("presentation.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); MyDocument.LoadPdf(fileStream, ""); fileStream.Close(); MyDocument.Save();

42

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Extracting attachments to a folder:

Use the code below to extract PDF atachments to a folder. Please make sure that the folder is not protected or secured. sample: string sourceFileName = @"C:\pdf\Attachments.pdf"; string outputDirectory = @"c:\pdf\folder"; PDFDocument.ExtractAttachments(sourceFileName, outputDirectory);

Accessing attached documents in PDF:

Using the code below, you can access the attaced documents in a PDF document. The GetPDFAttachments method will return a collection. You can access the name and contents of the attachment from this collection. sample: string sourceFileName = @"C:\temp\Attachments.pdf"; string outputDirectory = @"c:\temp\ext"; List attachments = PDFDocument.GetPDFAttachments( sourceFileName ); for (int i = 0; i < attachments.Count; i++){ PDFAttachmentFileContent attachment = attachments[i]; String name = attachment.Name; Byte[] content = attachment.Content; }

43

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com

Printing the specified pdf document:

Use the code below to print the specified PDF document. sample:

ProcessStartInfo info = new ProcessStartInfo(); info.Verb = "print"; info.FileName = @"c:\output.pdf"; info.CreateNoWindow = true; info.WindowStyle = ProcessWindowStyle.Hidden;

Process p = new Process(); p.StartInfo = info; p.Start();

p.WaitForInputIdle(); System.Threading.Thread.Sleep(3000); if (false == p.CloseMainWindow()) p.Kill();

44

PDFTechLib Documentation & Getting Started Guide Copyright PDF Technologies Inc. 2015 – www.pdf-technologies.com