Pdftechlib Is a .NET Class Library Used to Create, Edit and Otherwise Manipulate PDF Documents
Total Page:16
File Type:pdf, Size:1020Kb
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: <system.web> <securityPolicy> <trustLevel name="Full" policyFile="internal"/> </securityPolicy> </system.web> 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 Barcodes 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,