You are on page 1of 35

Quick PDF Library Developer Guide 7.

16 September 01, 2009


Introduction
Quick PDF Library is a powerful royalty-free PDF developer SDK - including over 500 functions for
use with Delphi, C, C#, C++, ASP, VB6, VB.NET, VBScript, PHP, PowerBASIC, and more, using the
ActiveX, DLL or Delphi version of the library.

It provides a comprehensive set of functions that allow you to create, render, print split, merge,
encrypt, modify and manipulate PDF form fields. It also provides advanced support for JavaScript.
Images can be added in BMP, TIFF, JPEG, PNG and EMF format. TrueType and Type1 fonts can be
embedded, and TrueType fonts can be subsetted allowing Unicode text to be drawn.

Quick PDF Library also includes a full built-in PDF rasterizer allowing PDFs to be rendered to the
screen or printer.

This developer guide is intended to provide you with the information you require to integrate Quick
PDF Library with your application.

High level description of features


Create, render and print PDFs
Secure, sign and protect PDFs
Create, fill and edit PDF forms
Split, merge, append and combine PDFs
Extract text and images from PDFs
Edit PDFs initial view and document properties
Add text, images and barcodes to PDFs
Advanced support for JavaScript, bookmarks, vector graphics
Direct access functionality (loads file from disk, not memory)

What is required?
You will need a computer of adequate speed. Quick PDF Library can be used by any Windows-based
machine in any compiler which supports Delphi, ActiveX, or DLLs.

Desktop
Windows 2000 Professional
Windows XP (32-bit)
Windows Vista (32-bit)
Windows 7 (32-bit)

Server
Windows Server 2000
Windows Server 2003 (32-bit)
Windows Server 2008 (32-bit)
64-bit
Compatible within 64-bit environment if the project is target to an x86 CPU. This requires targeting
the Visual Studio solution configuration for x86 deployment, and then modifying the .NET project
build configuration to target the x86 platform.

You can use Quick PDF Library within a 64-bit application by use of our TCP/IP bridge service
however; the library itself will still be operating as a 32-bit application.

We estimate a native 64-bit build to be complete mid-2010 in conjunction with the release of
Embarcadero -bit Delphi compiler.

Support
Every purchase of Quick PDF Library comes with 14 days free email technical support from the day
you register your copy, in addition to free access to standard support facilities (online help,
knowledge base, FAQs, code samples and the Quick PDF Library forums).

Premium support, which includes fast response times and priority bug fixes, as well as upgrade
insurance, is also available. To enquire about purchasing Premium Support, contact our sales team.

News, tips and upates


Keep up-to-date with the latest news, tips and updates for Quick PDF Library by subscribing to our
newsletter at http://visitor.constantcontact.com/d.jsp?m=1102444973294&p=oi

About Debenu
Debenu is one of the world's leading SOHO Document Management and PDF software vendors and
the company behind Quick PDF Library.

Headquartered in Melbourne, Australia, Debenu has grown both organically and through
acquisitions since it was founded in 2007 by Karl De Abrew, the founder and former CEO of Nitro
PDF Software, and Rowan Hanna.

Quick PDF Library is a key element of Debenu's Document Management suite which includes
Benubird Pro, Quick PDF Library, and Quick PDF Tools.

Debenu is also responsible for two industry leading blogs, 4x PDF Blog and Digital Documents, both
which target the world of electronic documents.

Legal note
The full end user license agreement for Quick PDF Library can be read online at
http://www.quickpdflibrary.com/products/quickpdf/license.php, but to give you a rough idea of
how you can and can't use Quick PDF Library, here are a few key points:
Per developer. Licenses for Quick PDF Library are sold on a per developer basis.
Royalty free. You can use Quick PDF Library in your applications without needing to pay any
royalty fees for distribution.
No limits on number of applicaons . We sell licenses based on the number of your
developers who will be using the library, not the number of applications your company
intends to build using the library.
Servers. Your license also covers use of the software on any server with the small provision
that access to Quick PDF Library by third parties must be via your own software.
No reselling. You are not allowed to resell Quick PDF Library or your license key, but you can
embed the software in your application, or distribute it with your system.
Compiled applicaons onl y. You are not permitted to create your own PDF software
libraries using Quick PDF Library.
Comprehensive Feature List
Quick PDF Library is a powerful PDF SDK offering a comprehensive range of PDF functionality.

PDF Creaon

Create PDFs programmatically from scratch

Generate PDF reports from databases

Create PDF documents on a Web server in real time

PDF Conversion

Convert TIFF images to PDF

Convert JPG, GIF, BMP and PNG to PDF

Convert WMF and EMF to PDF

Convert PDFs to text files

PDF Viewing / PDF Rendering

PDF to image rasterization BMP, JPEG, WMF, EMF, EPS, PNG and GIF)

View PDFs in your applications

PDF Prinng

Control Printing of PDFs programmatically

Printing options (Page Scaling, Auto Rotate Center, Title, Page Range and Copies)

Create custom printers (page size, copies, quality, color, duplex, collate, etc)

Utility functions dealing with printer setup

PDF Security

Digitally sign PDFs (digital signatures)

Encrypt and decrypt PDFs

Encrypt PDFs with a fingerprint

Encryption level: 40-bit RC4, 128-bit RC4 and 128-bit AES

Control document permissions (allowing printing, copying, modification, etc)


Set or remove open passwords

PDF Forms (interacv e for ms )

Create, modify and fill PDF forms

Read values from PDF form fields

Form field support for text, pushbutton, checkboxes, radio buttons, choice, and signature

XFA support (fill and read values from XFA forms)

Advanced control of form field appearance

Flatten form fields in PDFs

Extensive support for JavaScript in form fields

PDF JavaScript

Add/Edit/Remove document level JavaScript

Add/Edit/Remove global level JavaScript

JavaScript support for form fields

JavaScript support for document events

PDF actions support for JavaScript (links, bookmarks, etc)

PDF Layers / PDF Oponal Cont ent Gr oups (OC Gs )

Create new layers (OCG)

Edit, move, combine and delete existing layers (OCG)

combine, encapsulate and edit content streams

PDF Extracon / Page Ext racon / Text Ext r acon

Extract single pages or page ranges from a document

Extract text from a document (without formatting)

Extract text from a document (font, color, size and position of each piece of text)

Extract all images from a document

PDF Color
RGB/CMYK/Gray color modes

Support for separation colors

Fonts

Standard fonts

CJK (Chinese Japanese Korean) fonts

Subsetted fonts

Control fonts in form fields

TrueType fonts

Type1 fonts

Powerful utility functions required for working with fonts

Vector graphics in PDF

Lines, arcs, Bezier curves, ellipses, rectangles, circles, rounded rectangles

Full control over color, shading, blend modes and transparency

Full support for graphics state (load state and save state)

Clipping regions

Support for adding Barcodes to documents

PDF Compression

Compress fonts

Compress images

Compress content

PDF Document Manipulaon

Extract ranges of pages from a document

Merge documents together in memory or on disk

Merge a list of documents together

Combine and appends PDFs together


Split PDFs into multiple documents

PDF Page Manipulaon

Create new blank pages

Insert pages, append pages, move pages, reorder pages, clone pages and rotate pages

Crop pages, split pages, delete pages, hide pages and extract pages

Set page thumbnail

Set Base URL

Split the text and graphics on the current page into two layers

Adjust page dimensions

Imposition support (merge several source pages into a master page)

PDF Document Properes

Document properties (filename, title, author, subject, keywords, pdf producer, pdf version, etc)

Initial view preferences (page layout, page mode, magnification)

Security information

Count pages in a document

Embed files in PDFs

Add files attachments to PDFs

Measurement and coordinate units

Set measurement units to be used in document

Get/Set Origin

Retrieve coordinates from text and images

GeoPDF support

PDF Bookmarks (outlines)

Create and modify bookmarks

Edit style of bookmarks


Set bookmark destination and action (JavaScript, Open File,etc)

Utility functions for working with bookmarks

Barcodes

Add barcodes (Code 39, EAN-13, Code128, PostNet, Interleaved 2of 5)

Annotaons and hot spot links (hyper l inks)

Add links to embedded files and external files

Add links to JavaScript, pages and websites

Get destination and named destinations

Add note annotations

Get/set contents of annotations

Utility functions for working with links and annotations

Images

Add images from a file or memory

Compress images

Draw images onto documents

Find images in documents

Retrieve image height and width

Retrieve image type

Count images, replace images and reverse images

Extract images to disk or memory

Utility functions for working with images

Text and HTML Text

Draw text on documents

Draw text boxes

Draw multiline and wrapped text boxes


Control over text size, font, color and position

Utility functions for working with text

Page layout

Precisely control the layout and style of new pages

Draw tables, shapes, text and images onto pages

Get page dimensions, page size and page content (text, images, objects)

Utility functions for working with the page layout

Direct Access

Direct access functionality can be used with large PDFs.Operations are carried out on the file on the
disk, instead of loading the file into memory.

Misc

Full Unicode support

Create list of files to be merged

Retrieve last error message

Save-to-stream and Load-from-stream support for web serving


Getting Started: ActiveX Edition
Installation
Copy the QuickPDFAX0715.dll file from the installation folder into a directory of your choice, for
example C:\Program Files\Quick PDF Library\ActiveX\

Registering the ActiveX DLL


Use the regsvr32 command to register Quick PDF Library ActiveX Edition. On XP, click Start | Run and
enter the command:

regsvr32 "C:\Program Files\Quick PDF


Library\ActiveX\QuickPDFAX0715.dll"

Replace the path in the above command with the folder you chose in step 1.

On Vista you need to open a command prompt with administrator privileges in order to run the
command.

Class name
The class name of this release of Quick PDF Library ActiveX Edition is:
QuickPDFAX0715.PDFLibrary

Instantiating the class


Use the CreateObject or equivalent function in your development environment to create the Quick
PDF Library object.

The first function you should call is the UnlockKey function, passing it your license key.

Here is a Visual Basic example:

Private Sub CommandButton1_Click()


Dim PDFLibrary As QuickPDFAX0715.PDFLibrary
Set PDFLibrary = CreateObject("QuickPDFAX0715.PDFLibrary")
If PDFLibrary.UnlockKey("your license key here") = 1 Then
Call PDFLibrary.DrawText(100, 500, "Hello from Visual Basic")
Call PDFLibrary.SaveToFile("C:\Docs\HelloFromVB.pdf")
End If
Set PDFLibrary = Nothing
End Sub
Getting Started: DLL Edition
Installation
Included with the single DLL file QuickPDFDLL0715.dll are various header/import files. They provide
an easier way to interface with Quick PDF Library. Technical details of the interface are provided
here.

Initializing/releasing the library


All functions in the DLL use the stdcall convention. The QuickPDFCreateLibrary function must be
called to initialize the library. An InstanceID will be returned which must be passed as the first
parameter to all the other functions.

When you are finished with the library, call QuickPDFReleaseLibrary to release all allocated memory.

Unlocking the library


Once you have an InstanceID, you should call the QuickPDFUnlockKey function, passing it your
license key, to unlock the library.

int InstanceID;
InstanceID = QuickPDFCreateLibrary();
if (QuickPDFUnlockKey(InstanceID, "your license key") == 1) {
QuickPDFDrawText(InstanceID, 100, 500, "Hello world");
QuickPDFSaveToFile(InstanceID, "C:\Docs\HelloFromDLL.pdf");
}
QuickPDFReleaseLibrary(InstanceID);

Sending strings to Quick PDF Library


All Quick PDF Library string parameters are defined as PChars, which are pointers to 8-bit null-
terminated strings.

If you need to send binary data to Quick PDF Library that may contain null characters, you can ask
Quick PDF Library to create a temporary buffer of a certain size.

Use the QuickPDFCreateBuffer and QuickPDFAddToBuffer functions to create the buffer and fill it
with data. The value returned by the QuickPDFCreateBuffer function can then be used for any Quick
PDF Library string parameter:

char * Buffer;
char * Content = ...; // pointer to the data
Buffer = QuickPDFCreateBuffer(10000);
QuickPDFAddToBuffer(InstanceID, Buffer, Content, 10000);
QuickPDFStoreCustomDataFromString(InstanceID,
"MyData", Buffer, 1, 0);
QuickPDFReleaseBuffer(InstanceID, Buffer);
Receiving strings from Quick PDF Library
Functions that return string data will return a PChar, a pointer to a null terminated string. The
memory for this string is contained within the Quick PDF Library instance.

The data in the string should be copied out immediately as the same memory will be used for
subsequent calls to the DLL.

Some functions may return data that contains null characters.

To get the length of the returned string, use the QuickPDFStringResultLength function:

char * Content;
int ContentLength;
Content = QuickPDFRetrieveCustomDataToString(InstanceID,
"MyData", 1);
ContentLength = QuickPDFStringResultLength(InstanceID);
// copy the data in Content now
Getting Started: Delphi Edition
Installation
Copy all the DCU and RES files from the relevant installation folder into a directory of your choice,
for example C:\Program Files\Quick PDF Library\Delphi\

Setting the path


You must tell Delphi where to look for the DCU files. You can either do this once by setting your
"Library Path", or you can set the "Search Path" of each of your projects individually.

To set your Library Path, use the Delphi menu:


Tools | Environment Options | Library | Library path

If you would prefer to set your project's Search Path, use the following Delphi menu:
Projects | Options | Directories/Conditionals | Search path

Class/unit name
The class name of Quick PDF Library Delphi Edition is "TQuickPDF" followed by the version number.
The unit name is the same but without the leading T. For example, in this release the full class name
is TQuickPDF0715 and the unit is QuickPDF0715.

Instantiating the class


Quick PDF Library is a class, not a component. The software does not get installed into the Delphi IDE
and you do not place a component onto a form. Instead, you create an instance of the component
whenever you need to, much like other VCL classes (for example TStringList or TFileStream).

Simply add the Quick PDF Library unit QuickPDF0715 to the uses clause, declare a variable of type
TQuickPDF0715, and call the Create class function.

When you are finished using the class, call the Free function, usually within a try...finally block.

The first function you should call is the UnlockKey function, passing it your license key.

Your irst Qui ck PDF Li br ary pr ogram


Start a new Delphi project. If your Delphi environment gives you the option, choose a VCL Forms
application.

Add a TButton, a TMemo and a TLabel component onto your form.

Add Quick PDF Library's unit (QuickPDF0715) to the uses clause of your form unit:

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, QuickPDF0715;
Double-click the TButton to add an OnClick event, and fill in the
following event code. Change the path in the SaveToFile function to
an existing folder on your computer.
procedure TForm1.Button1Click(Sender: TObject);
var
PDFLibrary: TQuickPDF0715;
UnlockResult: Integer;
begin
PDFLibrary := TQuickPDF0715.Create;
try
UnlockResult := PDFLibrary.UnlockKey(Edit1.Text);
Label1.Caption := PDFLibrary.LicenseInfo;
if UnlockResult = 1 then
begin
PDFLibrary.DrawText(100, 500, 'Hello from Delphi');
PDFLibrary.SaveToFile('C:\Docs\HelloFromDelphi.pdf');
end else
begin
ShowMessage('Invalid license key);
end;
finally
PDFLibrary.Free;
end;
end;

You can now run your program. Fill your Quick PDF Library license key into the edit box and then
click the button.

If the license key you put into Edit1 is valid, the call to the UnlockKey function will return the value 1
and a PDF will be created in the specified directory.
Getting Started: TCP Edition

Installation
During installation, the QuickPDFTCP0715.exe file will be copied into the directory you specify, for
example C:\Program Files\Quick PDF Library\TCP\

Run the following command to install the service:

"C:\Program Files\Quick PDF Library\TCP\QuickPDFTCP0715.exe"


/install

Setting the IP address and port


In the same directory you will find a settings file called QuickPDFTCP0715.ini. This file can be edited
to change the IP address and port that the TCP service listens on:

IPAddress=127.0.0.1
Port=10005
Starting the service

Run the following command to start the service:

net start QuickPDFTCPService0715

Using the C# class


A C# client is available in the [installation
folder]\TCP\Client\CSharp directory.

Here is an example program:

QuickPDFTCP0715.Client qp = new QuickPDFTCP0715.Client();


if (qp.Connect("127.0.0.1", 10005))
{
if (qp.UnlockKey("your license key here") == 1)
{
qp.DrawText(100, 500, "Hello from C# via TCP/IP");
qp.SaveToFile("C:\\test.pdf");
}
}
Note that all directories are relative to the server.

Using the C++ class


A C++ client is available in the [installation folder]\TCP\Client\CPlusPlus directory.

Here is an example program:

QuickPDFTCP0713 qp;
if (qp.Connect("127.0.0.1", 10005))
{
std::cout << "LibraryVersion = ";
std::cout << qp.LibraryVersion() << std::endl;
qp.UnlockKey("your license key here");
qp.DrawText(100, 500, "Hello from C++ via TCP/IP");
qp.SaveToFile("C:\\test.pdf");
}

Directories and paths


Note that all directories are relative to the server.
Samples
The following demonstrations are built using VBScript and the Quick PDF Library test framework.

Unlocking the library


Before you can start using Quick PDF Library you must first unlock the library. If you fail to unlock the
library then many of the library functions will not work.

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("YOUR KEY HERE");

In order to reduce any confusion, you should check the result of the UnlockKey function before
doing anything else. If the function returns a 0 then this means that the license key is missing,
expired or invalid, if the function returns a 1 then this means that the license key is valid and you will
be able to access the full functionality of the library.

PDF Creation
A blank document is automatically created when you instantiate Quick PDF Library.

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("YOUR KEY HERE");
QP.DrawText(100, 600, "Hello world");
QP.SaveToFile("Hello.pdf");

Convert images to PDF

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("YOUR KEY HERE");

// Load your image into memory


QP.AddImageFromFile("c:\\temp\\test.tif", 0);

// Get width, height of the image


lWidth = QP.ImageWidth();
lHeight = QP.ImageHeight();

// Reformat the size of the page in the selected document


QP.SetPageDimensions(lWidth, lHeight);

// Draw the image onto the page using the specified width/height
QP.DrawImage(0, lHeight, lWidth, lHeight);

// Store the updated PDF where you like


QP.SaveToFile("Hello.pdf");

Convert PDFs to text iles

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("YOUR KEY HERE");

strInputFilePath = "c:\\temp\\input.pdf";

// Iterate through each page in the PDF and append it to a text file
QP.LoadFromFile(strInputFilePath);
iNumPages = QP.PageCount(); // Calculate the number of pages

strText = "";
nPage = 0;
for(nPage = 1; nPage<=iNumPages; nPage++)
{
strText = strText + QP.ExtractFilePageText(strInputFilePath,
"", nPage, 0);
}

// Write all the data to a file


fso = new ActiveXObject("Scripting.FileSystemObject");
s = fso.CreateTextFile("C:\\temp\\output.txt", 1);
s.Writeline(strText);
s.Close();

PDF Viewing / PDF Rendering

PDF to image rasterization BMP, JPEG, WMF, EMF, EPS, PNG and GIF)

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("YOUR KEY HERE");

// Iterate through each page in the PDF and write to an image


strInputFilePath = "c:\\temp\\sample.pdf";
QP.LoadFromFile(strInputFilePath); // load a local file
iNumPages = QP.PageCount(); // Calculate the number of pages
nPage = 0;
strPageName = "";
for(nPage = 1; nPage<=iNumPages; nPage++)
{
strPageName = strInputFilePath + "." + nPage + ".jpg";
QP.RenderPageToFile(72, nPage, 1, strPageName);
}

View PDFs in your applications

PDF Printing

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");

QP.LoadFromFile("C:\\temp\\print_me.pdf"); // load a local file

// Configure print options


iPrintOptions = QP.PrintOptions(0, 0, "Printing Sample")

// Print the current document to the default printing using the


options as configured above
QP.PrintDocument(QP.GetDefaultPrinterName(), 1, 1, iPrintOptions);

Create custom printers (page size, copies, quality, color, duplex, collate, etc)

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("YOUR KEY HERE");

QP.LoadFromFile("C:\\temp\\print_me.pdf"); // load a local file

CustomPrinter = "";
CustomPrinter = QP.NewCustomPrinter("My printer");
QP.SetupCustomPrinter(CustomPrinter, 5, 2); // Medium quality
QP.SetupCustomPrinter(CustomPrinter, 6, 1); // Monochrome
QP.SetupCustomPrinter(CustomPrinter, 7, 3); // Horizontal Duplex

// Configure print options


iPrintOptions = QP.PrintOptions(0, 0, "Printing Sample");

// Print the current document to the default printing using the


options as configured above
QP.PrintDocument(CustomPrinter, 1, 1, iPrintOptions);

PDF Security

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("YOUR KEY HERE");

QP.LoadFromFile("C:\\temp\\secure_me.pdf"); // load a local file

// Create encode permissions


// Function QuickPDF0715.PDFLibrary::EncodePermissions(CanPrint As
Long,
// CanCopy As Long, CanChange As Long, CanAddNotes As Long,
// CanFillFields As Long, CanCopyAccess As Long,
// CanAssemble As Long, CanPrintFull As Long) As Long

EncodePermissions = QP.EncodePermissions(1, 0, 0, 0, 0, 0, 0, 0); //


Allow the user to print only

// Encrypting the document must be the last


// function called prior to saving
QP.Encrypt("locked_down", "", 1, EncodePermissions);
QP.SaveToFile("C:\\temp\\secured.pdf");

Digitally sign PDFs (digital signatures)

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("YOUR KEY HERE");

// Function QuickPDF0715.PDFLibrary::SignFile(InputFileName As
String,
// OpenPassword As String, SignatureFieldName As String,
// OutputFileName As String, PFXFileName As String,
// PFXPassword As String, Reason As String, Location As String,
// ContactInfo As String) As Long

QP.SignFile("C:\\temp\\sign_me.pdf","","signature_field","c:\\temp\\
signed.pdf","c:\\temp\\Quick PDF Library.p12",
"ithinknot", "A good reason", "Here", "Quick PDF Library");

Decrypt PDFs

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("YOUR KEY HERE");

QP.LoadFromFile("C:\\temp\\secured.pdf"); // load a local file

// Decrypt the document


QP.SetPassword("sesame");
QP.Decrypt();

// Extract information from the decrypted document


DocInformation = "";
DocInformation = DocInformation + "PDF Version: " +
QP.GetInformation(0) + "\n";
DocInformation = DocInformation + "Author: " + QP.GetInformation(1)
+ "\n";
DocInformation = DocInformation + "Title: " + QP.GetInformation(2) +
"\n";
DocInformation = DocInformation + "Subject: " + QP.GetInformation(3)
+ "\n";
DocInformation = DocInformation + "Keywords: " + QP.GetInformation(4)
+ "\n";
DocInformation = DocInformation + "Creator: " + QP.GetInformation(5)
+ "\n";
DocInformation = DocInformation + "Producer: " + QP.GetInformation(6)
+ "\n";
DocInformation = DocInformation + "Creation date: " +
QP.GetInformation(7) + "\n";
DocInformation = DocInformation + "Modification date: " +
QP.GetInformation(8) + "\n";

// Display the information to the user


var myMsgBox= new ActiveXObject("wscript.shell")
myMsgBox.Popup (DocInformation)

Encrypt PDFs with a ingerpr i nt


QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");

QP.LoadFromFile("C:\\temp\\secured.pdf"); // load a local file


FingerPrint = QP.GetEncryptionFingerprint();

QP.LoadFromFile("C:\\temp\\fingerprint_me"); // load a local file


QP.EncryptWithFingerprint(FingerPrint);

QP.SaveToFile("C:\\temp\\finger_printed.pdf");

PDF Forms (interactive forms)


Create, modify and fill PDF forms

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");

// Set the paper size


QP.SetPageSize("A4");

// Set the origin to the top-left corner


QP.SetOrigin(1);

// Set the measurement units to millimetres


QP.SetMeasurementUnits(1);

// Add the heading font


QP.AddStandardFont(5); // Helvetica bold
QP.SetTextSize(10);
QP.DrawText(10, 28, "Name:");
QP.DrawText(10, 48, "Surname:");

// Add the font to use for the form fields


FontID = QP.AddStandardFont(0); // Courier

QP.AddFormFont(FontID);

FieldIndex = QP.NewFormField("Name", 1);


QP.SetNeedAppearances(0);
QP.SetFormFieldBounds(FieldIndex, 10, 30, 50, 10);
QP.SetFormFieldFont(FieldIndex, QP.GetFormFontCount());
QP.SetFormFieldTextSize(FieldIndex, 12);
QP.SetFormFieldBorderColor(FieldIndex, 0.5, 0, 0);
QP.SetFormFieldBorderStyle(FieldIndex, 1, 0, 0, 0);
QP.SetFormFieldBackgroundColor(FieldIndex, 0.8, 0.8, 0.5);
QP.SetFormFieldValue(FieldIndex, "John");

FieldIndex = QP.NewFormField("Surname:", 1);


QP.SetNeedAppearances(0);
QP.SetFormFieldBounds(FieldIndex, 10, 50, 50, 10);
QP.SetFormFieldFont(FieldIndex, QP.GetFormFontCount());
QP.SetFormFieldTextSize(FieldIndex, 12);
QP.SetFormFieldBorderColor(FieldIndex, 0.5, 0, 0);
QP.SetFormFieldBorderStyle(FieldIndex, 1, 0, 0, 0);
QP.SetFormFieldBackgroundColor(FieldIndex, 0.8, 0.8, 0.5);
QP.SetFormFieldValue(FieldIndex, "Smith");

// Compress the contents of the file


QP.CompressContent();

// Save the file


QP.SaveToFile("Hello.pdf");

Read values from PDF form iel ds

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");
QP.LoadFromFile("Hello.pdf");
NumFields = QP.FormFieldCount();

strFieldValues = "";
for(i = 1; i <=NumFields; i++)
{
strFieldValues = strFieldValues + "Field " + i + ": " +
QP.GetFormFieldTitle(i) + " " + QP.GetFormFieldValue(i) + "\r";
}

var myMsgBox= new ActiveXObject("wscript.shell")


myMsgBox.Popup(strFieldValues);

Form field support for text, pushbutton, checkboxes, radio buttons, choice, and signature
XFA support (fill and read values from XFA forms)
Advanced control of form field appearance

Flatten form iel ds in PDF s

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");

QP.LoadFromFile("Hello.pdf");

FieldCount = QP.FormFieldCount();
FieldIndex = 1;
LoopNumber = 1;

for(LoopNumber = 1; LoopNumber <= FieldCount; LoopNumber++)


{
if(QP.FlattenFormField(FieldIndex) == 0)
{
FieldIndex = FieldIndex + 1;
}
}
QP.SaveToFile("Flat.pdf");
Preview.LoadFromFile("Flat.pdf");

Extensive support for JavaScript in form iel ds

PDF JavaScript

Add/Edit/Remove document level JavaScript

Add/Edit/Remove global level JavaScript

JavaScript support for form iel ds


QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");

// Set the paper size


QP.SetPageSize("A4");

// Set the origin to the top-left corner


QP.SetOrigin(1);

// Set the measurement units to millimetres


QP.SetMeasurementUnits(1);

// Add the heading font


QP.AddStandardFont(5); // Helvetica bold
QP.SetTextSize(10);

ButtonText = "Big JavaScript Button:";


ButtonWidth = QP.GetTextWidth(ButtonText);
ButtonLocation = (QP.PageWidth()/2) - (ButtonWidth/2);
QP.DrawText(ButtonLocation, 68, ButtonText);

// Add the font to use for the form fields


FontID = QP.AddStandardFont(0); // Courier

QP.AddFormFont(FontID);

FieldIndex = QP.NewFormField("JavaScript Button:", 2);


QP.SetNeedAppearances(0);
QP.SetFormFieldBounds(FieldIndex, ButtonLocation, 70, ButtonWidth,
10);
QP.SetFormFieldFont(FieldIndex, QP.GetFormFontCount());
QP.SetFormFieldTextSize(FieldIndex, 12);
QP.SetFormFieldBorderColor(FieldIndex, 0.5, 0, 0);
QP.SetFormFieldBorderStyle(FieldIndex, 1, 0, 0, 0);
QP.SetFormFieldBackgroundColor(FieldIndex, 0.3, 0.3, 0.5);
QP.SetFormFieldValue(FieldIndex, "");
QP.SetFormFieldHighlightMode(FieldIndex, 3);
QP.FormFieldJavaScriptAction(FieldIndex, "U", "app.alert('Quick PDF
Library rocks!')");

// Compress the contents of the file


QP.CompressContent();

// Save the file


QP.SaveToFile("Hello.pdf");

Preview.LoadFromFile("Hello.pdf");

JavaScript support for document events

PDF actions support for JavaScript (links, bookmarks, etc)

PDF Layers / PDF Optional Content Groups (OCGs)

Create new layers (OCG)

Edit, move, combine and delete existing layers (OCG)

Combine, encapsulate and edit content streams

PDF Extraction / Page Extraction / Text Extraction

Extract single pages or page ranges from a document


Extract text from a document (without formatting)

Extract text from a document (font, color, size and position of each piece of text)

Extract all images from a document

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");
strFileInputPath = "c:\\temp\\fun.pdf"
iFileID = QP.DAOpenFile(strFileInputPath, "");
iPageCount = QP.DAGetPageCount(iFileID);
iPageNum=0;

for (iPageNum = 1; iPageNum <= iPageCount; iPageNum++)


{
// Get a page reference that can used with other
// DA functions
iPageRef = QP.DAFindPage(iFileID, iPageNum); // Get page reference

// Get a list of images for the prescribed page reference


iImageListID = QP.DAGetPageImageList(iFileID, iPageRef);

// Retrieve the global list of images


iImageListCount = QP.DAGetImageListCount(iFileID, iImageListID);

// Function QuickPDF0715.PDFLibrary::DASaveImageDataToFile(
// FileHandle As Long, ImageListID As Long, ImageIndex As Long,
// ImageFileName As String) As Long

for (iImageListIndex = 1; iImageListIndex <= iImageListCount;


iImageListIndex++)
{
strFileOutputPath = "c:\\temp\\" + iImageListIndex + ".jpg";
QP.DASaveImageDataToFile(iFileID, iImageListID, iImageListCount,
strFileOutputPath);
}
QP.DACloseFile(iFileID);
}
PDF Color

RGB/CMYK/Gray color modes

Support for separation colors

Fonts

Standard fonts

CJK (Chinese Japanese Korean) fonts

Subsetted fonts

Control fonts in form iel ds

TrueType fonts

Type1 fonts

Powerful utility functions required for working with fonts

Vector graphics in PDF

Lines, arcs, Bezier curves, ellipses, rectangles, circles, rounded rectangles

Full control over color, shading, blend modes and transparency

Full support for graphics state (load state and save state)

Clipping regions

Support for adding Barcodes to documents

PDF Compression

Compress fonts

Compress images

Compress content

PDF Document Manipulation

Extract ranges of pages from a document

Merge documents together in memory or on disk

Merge a list of documents together

Combine and appends PDFs together

Split PDFs into multiple documents

PDF Page Manipulation


Create new blank pages

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");

for (x=1; x<=10; x++)


{
QP.NewPage();
for (y = 0; y <= 10; y++)
{
QP.SetTextColor(y / 10, 1- x / 10, 1 - y / 10);
QP.DrawText(100, 600 - y * 10, "Hello world");
}
}
QP.DeletePages(1,1);

QP.SaveToFile("Hello.pdf");

Insert pages, append pages, move pages, reorder pages, clone pages and rotate pages

Crop pages, split pages, delete pages, hide pages and extract pages

Set page thumbnail

Set Base URL

Split the text and graphics on the current page into two layers

Adjust page dimensions

Imposition support (merge several source pages into a master page)

Document properties (ilename , title, aut hor, subj ect, keywo rds , pdf pr oduc er, pdf versi on,
etc)
QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");

QP.LoadFromFile("C:\\temp\\show_info.pdf"); // load a local file

// Extract document properties


DocInformation = "";
DocInformation = DocInformation + "PDF Version: " +
QP.GetInformation(0) + "\n";
DocInformation = DocInformation + "Author: " + QP.GetInformation(1)
+ "\n";
DocInformation = DocInformation + "Title: " + QP.GetInformation(2) +
"\n";
DocInformation = DocInformation + "Subject: " + QP.GetInformation(3)
+ "\n";
DocInformation = DocInformation + "Keywords: " + QP.GetInformation(4)
+ "\n";
DocInformation = DocInformation + "Creator: " + QP.GetInformation(5)
+ "\n";
DocInformation = DocInformation + "Producer: " + QP.GetInformation(6)
+ "\n";
DocInformation = DocInformation + "Creation date: " +
QP.GetInformation(7) + "\n";
DocInformation = DocInformation + "Modification date: " +
QP.GetInformation(8) + "\n";

// Display the information to the user


var myMsgBox= new ActiveXObject("wscript.shell")
myMsgBox.Popup (DocInformation)

Initial view preferences (page layout, page mode, magniicat ion)

Security information

Count pages in a document

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");

strLoadDocument = "C:\\temp\\sample.pdf";
QP.LoadFromFile(strLoadDocument); // load a local file

// Extract information
NumPages = QP.PageCount();

// Display the information to the user


var myMsgBox= new ActiveXObject("wscript.shell");
myMsgBox.Popup (strLoadDocument + " has " + NumPages + " pages");
Embed iles in PDF s

Add iles attachments to PDFs

Measurement and coordinate units

Set measurement units to be used in document

Get/Set Origin

Retrieve coordinates from text and images

GeoPDF support

PDF Bookmarks (outlines)

Create and modify bookmarks

Edit style of bookmarks

Set bookmark destination and action (JavaScript, Open File,etc)

Utility functions for working with bookmarks

Barcodes

Add barcodes (Code 39, EAN-13, Code128, PostNet, Interleaved 2of 5)

Annotations and hotspot links (hyperlinks)

Add links to embedded iles and ext e rnal iles

Add links to JavaScript, pages and websites

Get destination and named destinations

Add note annotations

Get/set contents of annotations

Utility functions for working with links and annotations

Images

Add images from a ile or m


e mo ry

Compress images

Draw images onto documents

Find images in documents

Retrieve image height and width

Retrieve image type


Count images, replace images and reverse images

Extract images to disk or memory

Utility functions for working with images

Text and HTML Text

Draw text on documents

QP = new ActiveXObject("QuickPDFAX0716.PDFLibrary");
QP.UnlockKey("j15z13nf3jw8cs9n78ou6r37y");

QP.LoadFromFile("Hello.pdf");
NumPages = QP.PageCount();

for (x = 1; x <= NumPages; x++)


{
QP.SelectPage(x);
QP.SetOrigin(0); // Bottom left
PageText = "Page: " + x;
TextWidth = QP.GetTextWidth(PageText);
QP.DrawText((QP.PageWidth()/2)-TextWidth/2, 20, PageText);
}

QP.SaveToFile("Hello2.pdf");
Preview.LoadFromFile("Hello2.pdf");
Draw text boxes

Draw multiline and wrapped text boxes

Control over text size, font, color and position

Utility functions for working with text

Page layout

Precisely control the layout and style of new pages

Draw tables, shapes, text and images onto pages

Get page dimensions, page size and page content (text, images, objects)

Utility functions for working with the page layout

Direct Access

Direct access functionality can be used with large PDFs.Operations are carried out on the

Misc

Full Unicode support

Create list of iles to be m


e rged

Retrieve last error message

Save-to-stream and Load-from-stream support for web serving


Release History
Quick PDF Library is regularly updated with new features, bug fixes and general enhancements. Here
you can check to see if you're using the latest version.

The latest release of Quick PDF Library is version 7.15 and it can be downloaded from here:
http://www.quickpdflibrary.com/products/quickpdf/trial.php

Quick PDF Library 7.15 - August 6, 2009,

New Features and Improvements:


New! Unicode support for filenames
New! SetBaseURL function
New! GeoPDF support.
New! related functions: AddLGIDictToPage, GetPageLGIDictCount, GetPageLGIDictContent
and DeletePageLGIDict
New! ImportEMFFromFile function
New! SetAnnotStrProperty function
Renderer allows fonts to be direct objects as well as indirect objects
Improved font matching in renderer
Implemented Deflate on image data with predictor and BitsPerComponent = 4

Quick PDF Library 7.14 - June 9, 2009

New Features and Improvements:


New! GetCanvasDC and LoadFromCanvasDC functions
New! GetXFAFormFieldNames function
New! GetXFAFormFieldName function
New! GetXFAFormFieldCount function
New! GetFontObjectNumber function
New! SetAdvancePassword function
New! CreateTable function
New! SetTableColumnWidth function
New! SetTableRowHeight function
New! SetTableCellBorderColor function
New! SetTableCellBorderColorCMYK function
New! SetTableCellBorderWidth function
New! SetTableCellBackgroundColor function
New! SetTableCellBackgroundColorCMYK function
New! SetTableCellPadding function
New! SetTableCellAlignment function
New! SetTableCellContent function
New! SetTableCellTextColor function
New! SetTableCellTextColorCMYK function
New! SetTableCellTextSize function
New! SetTableBorderColor function
New! SetTableBorderColorCMYK function
New! SetTableBorderWidth function
New! MergeTableCells function
New! DrawTableRows function
New! GetTableLastDrawnRow function
New! GetTableCellStrProperty function
New! GetTableCellIntProperty function
New! GetTableCellDblProperty function
Delphi 2009 improvements
Updated the docs for the XFA functions
Fixed CFF font decoding bug
Bug fix for fonts with /Differences array and no /ToUnicode entry
Bug fix for non-embedded fonts with slightly different standard font names
Bug fix for matching fonts characters with capital letters

Quick PDF Library 7.13 - May 4, 2009

New Features and Improvements:


New! Delphi 2009 support
New! functionality for GetAnnotStrProperty and GetAnnotIntProperty to handle GoToR and
Launch annotations and speed improvements
New! EmbeddedFileCount function
New! GetEmbeddedFileStrProperty function
New! GetEmbeddedFileIntProperty function
New! GetEmbeddedFileContentToFile function
New! GetEmbeddedFileContentToString function
New! GetEmbeddedFileContentToStream function
New!GetNamedDestination function
Support for inverted JPEG palettes
Improvements to internal outline navigation
Internal support for name objects directly following the obj keyword
Bug fix and improvements to encryption fingerprint functions
Option to load images using GDI+ instead of internal image handling functions
Support for type 3 functions
Improvements to image decoding
Faster page location when page tree is a single array
Support for loading 8-bit alpha mask from PNG images
Better rendering of encrypted documents
Support for alternate ICC based color space in renderer
Support for W=4 in cross reference stream
Speed improvements to object decoding
Bug fix for text extraction with option 4 to return single words
Quick PDF Library 7.12 - March 20, 2009

New Features and Improvements:


Specifically targeted for ASP, C++, C#, Delphi, PowerBASIC, PowerBuilder and Visual Basic
Save-to-stream and Load-from-stream support for web serving
Advanced PDF rasterizer with RenderPageToDC and gradient support
Advanced PDF page combining, cloning, extraction, imposition and merging technology
Advanced PDF encryption, decryption (including 128-bit encryption) and digital signatures
TrueType font support (including font embedding)
Support for Japanese fonts and Turkish codepage (1254)
Comprehensive form field and JavaScript support
Built-in PDF barcode support
Advanced drawing, including circles and arcs
Rotated text, multi-line paragraph text, word-wrapped paragraph text
Outline and hypertext functions
Embedded image, file grouping and links

External help
Quick PDF Library Online Reference Guide -
http://www.quickpdflibrary.com/help/quickpdf/FunctionGroups.php
Quick PDF Library Knowledge Base http://www.quickpdflibrary.com/kb
Quick PDF Library Forum http://www.quickpdf.org
Quick PDF Blog - http://www.quickpdflibrary.com/blog/
Quick PDF Library Samples - http://www.quickpdflibrary.com/samples/index.php
End User License Agreement (EULA) -
http://www.quickpdflibrary.com/products/quickpdf/license.php
References
ISO 32000-1 (PDF 1.7)
Document management Portable document format Part 1: PDF 1.7, First Edition (July,
2008) (PDF, 8.6M) - http://www.adobe.com/devnet/pdf/pdf_reference.html

You might also like