Amyuni PDF Creator for .NET
For PDF and XPS
Version 4.5 Professional
Quick Start Guide for Developers
Updated October 2010
AMYUNI Consultants AMYUNI Technologies
www.amyuni.com
Page | 2
Contents
Legal Information ...................................................................................................................................3
Acknowledgments ..................................................................................................................................3
Description of the Various Modules.......................................................................................................4
acPDFCreatorLib.Net.dll .....................................................................................................................4
acPDFCreator.Net.dll.......................................................................................................................... 4
xmllite.dll ............................................................................................................................................4
General Operation..................................................................................................................................5
Important Note for Version 4.5 ......................................................................................................5
New in Version 4.5..................................................................................................................................6
Adding the PDF Creator .NET Library to Your Application ..................................................................... 7
Inserting the PDF Creator Control into a Project.................................................................................... 9
Setting the Licensing Information ....................................................................................................10
PDF Creator .NET Library Architecture.................................................................................................12
Links to Support and Documentation:..................................................................................................13
Online Documentation: ....................................................................................................................13
Frequently Asked Questions:............................................................................................................13
Technical Notes: ............................................................................................................................... 13
User forum:.......................................................................................................................................13
Posting questions to our technical support staff: ............................................................................13
Page | 3
Legal Information
Information in this document is subject to change without notice and does not represent a
commitment on the part of AMYUNI. The software described in this document is provided under a
license agreement or nondisclosure agreement. The software may be used or copied only in
accordance with the terms of the agreement. It is against the law to copy the software on any
medium except as specifically allowed in the license or nondisclosure agreement.
The licensee may make one copy of the software for backup purposes. No part of this manual may
be reproduced or transmitted in any form or by any means, electronic or mechanical, including
photocopying, recording, or information storage and retrieval systems, for any purpose other than
the licensee’s personal use, without express written permission of AMYUNI.
Copyright 2001-2010, AMYUNI Consultants AMYUNI Technologies. All rights reserved.
Amyuni and the Amyuni logo are trademarks of Amyuni Technologies Inc.
Microsoft, the Microsoft logo, Microsoft Windows, Microsoft Windows NT and their logos are
trademarks of Microsoft Corporation.
All other trademarks are the property of their respective owners.
Acknowledgments
This software uses the deflate algorithm developed by Jean-loup Gailly ([email protected]) and Mark
Adler ([email protected]). This software is also based in part on the work of the
Independent JPEG Group and on parts of the FreeType library.
Page | 4
Description of the Various Modules
The Amyuni PDF Creator .NET product is composed of two modules that can be integrated and
distributed under the developer license agreement.
acPDFCreatorLib.Net.dll
This is the managed code library that contains all the classes needed to create and process PDF files.
This DLL should be copied to the main application’s directory. The namespace for all the classes in
this library is Amyuni.PDFCreator.
acPDFCreator.Net.dll
This DLL contains a visual .NET control that can be placed on a form to view, print or process PDF
files. This DLL also contains additional controls such as the status bar. The namespace for all the
classes in this library is Amyuni.PDFCreator.PDFCreator.
xmllite.dll
This module contains the XML parser needed to process XPS documents. This module is needed
only if XPS support is required and can be skipped otherwise.
Page | 5
General Operation
The Amyuni PDF Creator .NET was designed for three main purposes:
Viewing, editing, annotating and printing PDF documents
Creating and filling out PDF forms
Creating reports, forms and general documents directly in PDF, RTF. HTML, Excel, JPEG,
and TIFF formats
The library and controls that are part of the PDF Creator .NET can be integrated into most
development environments to provide the final user with advanced PDF document management
capabilities.
The PDF Creator control can be in one of four modes:
Design mode.
Run or Compiled mode.
Annotation mode.
Print preview mode.
When a blank document is first created, the control is in design mode. The user or developer can
add objects to the document, delete objects, modify object properties and do all editing operations
allowed by the PDF Creator control.
When an existing PDF document is opened, two things can happen:
1. The PDF document was generated by the PDF Creator and contains all design information
generated by the control. In this case, the document is opened in the same state as when it
was saved, i.e., either Design, Run, Annotate or PrintPreview modes.
2. The PDF document was generated by another tool such as the Amyuni PDF Converter. In this
case, the document is opened immediately in Run mode. The document can only be read or
printed and if the user has enough rights on the document, the user can switch the
document to annotation or design mode and edit it using the PDF Creator interface.
The documents created by the PDF Creator can contain fields with formulas or data coming from a
database. Compiling the document instructs the PDF Creator to compute those formulas and fetch
information from the database. Once compiled, the document switches to Run mode and only the
fields or objects defined as Editable can be modified in Run mode.
In Annotation mode, the contents of the original document cannot be modified; the user can only
add or modify PDF annotations such as Text, Line, Highlighter or Sticky note annotations.
Important Note for Version 4.5
Microsoft Visual C++ 2008 Redistributable Package (x86) should be installed on systems that
don’t have version 2008 when deploying their applications.
Page | 6
New in Version 4.5
Amyuni PDF Creator 4.5 is the result of more than a year of continual improvements over the
previous 4.0 release. With Windows 7 and 64-bit OS becoming the standards in the PC market, all
the aspects of running under these environments have been reviewed and optimized. Several
performance enhancements and rendering accuracy have been added to the product.
64-bit SDK improves performance and compatibility with 64-bit applications
Fully managed .NET assemblies enable integration with web form applications
Improved performance and reliability for processing very large PDF documents containing
heavy graphics
o Added support for PNG optimization in addition to the existing JPEG optimization
o New page caching algorithm keeps a defined number of pages in memory
Improved PDF Rendering Engine
o Automatically fix non GDI compliant fonts for improved text support
o Advanced drawing operations (shadings, gradients)
o Wider support for third-party tools
o Improved XPS Rendering Engine
Support for loading and saving PDF Actions and Destinations including Javascript
Support for loading and saving external search index files
JBIG2 compression of black and white images considerably reduces file size of scanned
documents
Support for multi-page TIFF images. New OCR module can be purchased separately as an
add-on to PDF Creator
Page | 7
Adding the PDF Creator .NET Library to Your Application
The first step to start using the PDF Creator library with your application is to reference the
acPDFCreatorLib.Net.dll assembly.
To add the new reference:
1. Open the solution explorer window
2. Right click on references and select Add new reference.
Figure 1: Adding a reference in the Solution Explorer Window
Figure 2: Microsoft Visual Studio Add Reference Dialog
This will result in having the DLL copied to your application’s executables directory.
Once the reference to the assembly is added, you can use it in any of your modules by adding:
Page | 8
using Amyuni.PDFCreator;
The assembly needs to be initialized before any object is referenced. The assembly also needs to be
uninitalized before exiting your application to free any internal resources used by the library.
Initialization is done by calling:
acPDFCreatorLib.Initialize ();
Before terminating the application, the developer should call:
acPDFCreatorLib.Terminate ();
Page | 9
Inserting the PDF Creator Control into a Project
This is specific to each development environment, but the procedure is very similar in all cases. The
PDF Creator component should be added to the components toolbox as follows:
1. Right-click Components”.
2. Select Add/Remove items.
Figure 3: Adding PDFCreator to the components toolbox
The Add .NET Framework Components dialog box appears as follows:
Figure 4: Selecting PDFCreator in the .NET Framework Components
Page | 10
Browse for acPDFCreatorLib.Net.dll. The control shows in the list of insertable .NET components as
PDFCreator. Once added to the toolbox, the component appears in the components toolbar and
can be inserted on a form:
Setting the Licensing Information
Before any operation can be done on the PDF Creator library or control, the library or the control
needs to be activated using the SetLicenseKey method as shown below.
A sample code for using the PDF Creator control to open a PDF file for viewing or editing:
// All Amyuni classes used here are defined in the Amyuni.PDFCreator namespace
// Initialize the Library
acPDFCreatorLib.Initialize ();
// Set the License key
acPDFCreatorLib.SetLicenseKey ("Amyuni Tech.", "07EFCD10001…7857EC1193FA”);
Amyuni.PDFCreator.PDFCreator pdfCreator;
PdfCreator = new Amyuni.PDFCreator.PDFCreator ();
//open a pdf document from file
System.IO.FileStream file1 = new System.IO.FileStream ("Page.pdf", FileMode.Open,
FileAccess.Read, FileShare.Read);
IacDocument document = pdfCreator.Document;
document.Open (file1, "");
//switch to design mode before adding objects to the document
document.ReportState = IacReportState.acReportStateDesign;
//create a rectangular frame to add to the document
IacPage page = document.GetPage (1);
Amyuni.PDFCreator.IacObject frame = page.CreateObject
(IacObjectType.acObjectTypeText,"Frame 1");
//position the frame
frame.AttributeByName ("Left").Value = 200;
frame.AttributeByName ("Top").Value = 600;
frame.AttributeByName ("Right").Value = 2000;
frame.AttributeByName ("Bottom").Value = 800;
frame.AttributeByName ("Text").Value = "Hello";
// save modified document to a new file (file2)
System.IO.FileStream file2 = new System.IO.FileStream ("test3.pdf",
FileMode.Create, FileAccess.Write, FileShare.Read);
document.Save (file2, IacFileSaveOption.acFileSaveView);
file2.Close ();
// terminate library to free resources
acPDFCreatorLib.Terminate ();
Page | 11
Here is the same sample in C# for using the PDF Creator library as opposed to the PDF Creator
control:
// initialize library and set license key
acPDFCreatorLib.Initialize ();
acPDFCreatorLib.SetLicenseKey ("Amyuni Tech.", "07EFCDAB0100...009EE2F79");
// Open a PDF document from file
System.IO.FileStream file1 = new System.IO.FileStream ("test.pdf", FileMode.Open,
FileAccess.Read, FileShare.Read);
IacDocument document = new IacDocument (null);
document.Open (file1, "");
// switch to design mode before adding objects to the document
document.ReportState = IacReportState.acReportStateDesign;
// create a rectangular frame to add to the document
Amyuni.PDFCreator.IacObject frame =
document.GetPage (2).CreateObject (IacObjectType.acObjectTypeText, "Frame 1");
// position the frame
frame.AttributeByName ("Left").Value = 200;
frame.AttributeByName ("Top").Value = 600;
frame.AttributeByName ("Right").Value = 2000;
frame.AttributeByName ("Bottom").Value = 800;
frame.AttributeByName ("Text").Value = "Hello";
// save modified document to a new file
System.IO.FileStream file2 = new System.IO.FileStream ("test3.pdf", FileMode.Create,
FileAccess.Write, FileShare.Read);
document.Save (file2, IacFileSaveOption.acFileSaveView);
// terminate library to free resources
acPDFCreatorLib.Terminate ();
Page | 12
PDF Creator .NET Library Architecture
The main entry point to the library is the IacDocument class. This class provides the developer the
methods needed to create a blank document, open an existing document, accessing various parts of
the document, saving IacDocument implements various interfaces:
IacPrint contains all the methods related to printing a document.
IacUndo contains methods related to undoing and redoing the latest operations.
IacImportExport contains the methods related to importing and exporting documents
from/to various formats.
IacDocument contains an array of pages, each represented by the IacPage class. Each page contains
an array of objects represented by the IacObject class. Any object contained in a page, such as text,
lines, images, annotations is represented by an IacObject object. IacObject contains a list of
attributes represented by the IacAttribute class. The developer communicates with objects by
reading or setting various object attributes. Here’s an example of changing the text for a specific
object:
IacAttribute text = object.AttributeByName (“Text”)
text.Value = "Change the text of this object"
IacDocument and IacPage are also derived from IacObject. This enables the developer to read and
write various attributes that are not directly available through the IacDocument or IacPage classes.
These attributes are detailed in the coming sections and include various things such as the
document title or subject.
IacPageFormat contains the entire page formatting information such as paper size and orientation.
Both IacDocument and IacPage contain a single instance of IacPageFormat. The instance contained
by IacDocument represents the default page format that is used when a new page is created. The
instance contained in IacPage represents the page format for each specific page.
Page | 13
Links to Support and Documentation:
If you have any questions or problems with our products, the following resources are available to
you through our web site:
Online Documentation:
http://www.amyuni.com/WebHelp/Developer_Documentation.htm#index.htm
Frequently Asked Questions:
http://www.amyuni.com/forum/viewforum.php?f=18
Technical Notes:
http://www.amyuni.com/en/resources/technicalnotes/
User forum:
http://www.amyuni.com/forum/index.php
Posting questions to our technical support staff:
http://www.amyuni.com/en/support/getsupport/
We also provide some additional tools that can be downloaded free of charge and used with the
PDF Creator product. These tools are available at:
http://www.amyuni.com/en/resources/freetools/