ABCpdf™ Reference Guide

ABCpdf lets you dynamically create Adobe® PDF documents on the fly. Because it doesn't use any print drivers and goes Direct to PDF™, it's incredibly fast. WebSupergoo - sticking the web together.

ABCpdf .NET and ABCpdf ASP.

ABCpdf .NET includes a COM layer over the native .NET base - a layer which exactly mimics the interface of ABCpdf ASP. This means you can use one product for your .NET deployment and also for any legacy COM deployment.

Think of it as double value - ABCpdf .NET and ABCpdf ASP both in one package. Plus you get the advantages of the .NET architecture behind a COM front end - advantages like native x64 support and features like SVG import.

In this document, we try to avoid duplicating content that already exists in the ABCpdf .NET documentation. So we cover the specifics of the ASP / COM interface. However, for configuration issues and other similar discussions, you should refer to the ABCpdf .NET documentation.

© 2026 WebSupergoo

Every effort has been made to ensure that the information in this manual is accurate. However, WebSupergoo makes no guarantees about the accuracy or quality of this manual or any software it describes.

Apple®, Mac®, Macintosh®, QuickDraw®, and QuickTime® are trademarks of Apple Computer, Inc. Windows®, Windows NT®, Visual Basic® and Visual Studio® are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Adobe®, Acrobat®, Adobe PDF®, PostScript® and Photoshop® are trademarks of Adobe Systems Incorporated or its subsidiaries. Macromedia®, Flash™ and Macromedia Flash™ are trademarks or registered trademarks of Macromedia, Inc. in the United States and/or other countries. The use of these trademarks does not imply any sponsorship or endorsement by the owners of these trademarks.


What is ABCpdf?

Use ABCpdf to dynamically create Adobe PDF documents on the fly. You won't believe how simple - yet how powerful this tool truly is!

You can use ABCpdf from Visual Basic or any scripting language that supports the Microsoft ActiveX Scripting interfaces.

These include VBScript, classic VB, C#, and JScript.

ABCpdf .NET runs on Windows 2000, Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008.


Who is this document for?

This document is written as a guide to and reference material for the ABCpdf component. It assumes basic knowledge of Active Server Pages (ASP) and VBScript. It also assumes you know how to set up and configure Microsoft's Internet Information Services (IIS) Version 4.0 or later.


What do I need to use it?

ABCpdf .NET runs on Windows 2000, Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008.

We recommend your host machine has Internet Explorer 6 or later installed.

Finally, you'll need ABCpdf itself.


ASP Essentials

DLLs

ABCpdf .NET is made up of two components. This version additionally includes a type library for an ASP / COM interface.

ABCpdf14-32.dll/ABCpdf14-64.dll is the core engine. It incorporates our proprietary Direct to PDF technology and is designed for high-performance PDF manipulation in a multithreaded environment.

ABCpdf.dll is a .NET tier comprising the .NET visible interface and less speed-critical code. When the assembly is loaded, it locates and loads the core engine establishing a direct high speed link between the two components.

ABCpdf.tlb is the type library. This marshals parameters during calls to the COM object and also enables early binding and type checking at build time. For maximum forward compatibility, use late binding.

The .NET tier is placed in the GAC so that you can reference ABCpdf .NET from any of your projects. However, should you require, you can always copy both DLLs to the bin directory of your application. A second reference copy and the type library file are placed at the following location:

%ProgramFiles%\WebSupergoo\ABCpdf14 .NET\Common\

Reg

The ABCpdf COM classes and type library are automatically registered during installation.

All you need to create an ABCpdf document object from ASP is to use the following code:

Set doc = Server.CreateObject("ABCpdf14.Doc")

Example

This is a simple example page. All it does is to report the ABCpdf License information.

<html>
<body>

<%

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
Response.Write("License: " & theDoc.License & "<br>")

%>

</body>
</html>

Security

Active Server Pages operate under a restricted set of security permissions. It is quite common for the IIS user not to be able to create or write files.

So if you want to save a PDF file from your script, it is quite likely that you will need to adjust the permissions on your destination directory to allow write access for the IIS user (typically IUSR_MACHINENAME).


Simple Example

Intro

Creating a PDF document is a simple process. First, you create an ABCpdf Document object, and then you add your content to it. You can add text, images, and other kinds of graphics.

All content addition is done within the current Rect on the current Page. You can change the Page to draw on different pages and the Rect to draw in different areas. The default page is the first page, and the default drawing area is the entire page.

You may find it useful to use the FrameRect method during development. This frames the current rectangle on the current page so that the area you are about to draw on is outlined.

Every time you add an item of content, you will get an Object ID returned. You may wish to save these IDs and use them to query or change object properties at a later time.

Code

This example shows how to create a simple PDF.

First, we create an ABCpdf Doc object. Next, we set the font size and add some text to it. Finally, we save at a specified location.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96
theDoc.AddText "Hello World"
theDoc.Save "c:\mypdfs\simple.pdf"

Results

simple.pdf


Coordinate Spaces

General

ABCpdf uses the standard Adobe PDF coordinate space. The origin of this space is often at the bottom left of the document (depending on MediaBox and/or CropBox). Distances are measured up and to the right in points. Points are a traditional measure for print work - there are 72 points in an inch.

Please note that the bottom-up PDF coordinate space is different from the top-down coordinate system often used in Windows. It means that everything is based around the bottom left of objects - not the top left. If you wish to use a different coordinate system, you can use the document Units, TopDown or Transform to accomplish this.

ABCpdf uses the XPoint object to represent positions in space. It uses the XRect object to represent areas such as the current drawing area or the size of a page.

The Doc.Rect property is probably the most important property to be aware of. Virtually everything happens within the Doc.Rect. If you add text to a document, it is added within Doc.Rect. If you paint or frame a rectangle, it is done within Doc.Rect. If you add an image, it is scaled to fit exactly within Doc.Rect.

The default document size for ABCpdf is 612 by 792. This equates to a physical page size of 8.5 by 11 inches.

Example

The following example draws a rectangle with the bottom left corner positioned 100 points from the left of the page and 200 points up from the bottom. The width of the rectangle is 400 points, and the height is 500 points. We add a grid to show the positioning of the rectangle.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.AddGrid
theDoc.Color = "255 0 0"
theDoc.Width = 10
theDoc.Rect.Position 100, 200
theDoc.Rect.Width = 400
theDoc.Rect.Height = 500
theDoc.FrameRect
theDoc.Save "c:\mypdfs\coordinates.pdf"

coordinates.pdf


Examples

There are many code examples in the documentation. These cover common tasks like adding text, flowing text and adding images.

Every major object method or property has an accompanying code sample. So if you want to know how to use a method like AddText or AddImageFile, just look at the code sample.

Code samples also cover operations like rendering HTML pages, paged HTML renders, watermarking, appending PDF documents, and drawing pages from one PDF document into another.

For in-situ examples, you should look at the example ASP web site that comes installed with ABCpdf. This can be found within in a subdirectory of the "Program Files\WebSupergoo\ABCpdf .NET" folder for ASP and COM-related material.


Upgrading

Basics

ABCpdf 14 is a new version completely independent of the old. You can have both versions installed at the same time. When you want to take advantage of the new features, simply reference the new name.

Simply replace...

Set theDoc = Server.CreateObject("ABCpdf10.Doc")

with...

Set theDoc = Server.CreateObject("ABCpdf14.Doc")

Changes

ABCpdf is fully backward compatible. Although extensive changes have been made to the core engine, we check that these changes produce results that are compatible with previous versions.

Layout is very similar, but a few layout issues have been addressed which means that the new - correct - layout may be slightly different from the old layout.

This release of ABCpdf is based on the .NET branch of development. The COM interface provided by the ABCpdf ASP version 6 has been maintained to provide a smooth upgrade transition and support for existing users.

The HtmlRender event of ABCpdf ASP has been omitted. However, if this feature is important to your code, or you feel there are other features of ABCpdf .NET that should be exposed to COM, then please do let us know.


Core Objects

Adobe Portable Document Format (PDF) files are made of a number of objects. Objects may describe a page, a resource, a sequence of drawing operations, an image, or many other components as required by the document.

Every object has a unique Object ID and a characteristic Object Type. The root of the document hierarchy can be accessed using the Root property.

IDs are numbered from one upwards. The ID zero refers to the Empty Object which is an object required internally within ABCpdf. ID -1 refers to the document trailer.

You can use core information types to iterate through every object in your document. To get information about an object, you need to use the GetInfo method. To change properties of an object, you need to use the SetInfo method. All objects support the core properties listed below.

Additionally, Specific Objects support other types of properties in addition to the core properties listed below.

Core Object Information Types

Type Name GetInfo SetInfo Description
ID

The Object ID of the Object.

For any existing object, the code theDoc.GetInfo(theID, "ID") will always be equal to theID. Object IDs are unique.
Type

The Type of the Object.

This is a four character code that specifies the type of an object. Different object types have different properties.
Active

This property is included for historical reasons.

The value of this property is always 1.
Value

The content of the object as it will be inserted into the final PDF document.

Note that the content of an object may be large and it may contain unusual characters.

See the Object Paths section of this document for further details.
/Label

Any object in a PDF dictionary may be referenced by name.

Most PDF objects are dictionaries. Dictionaries contain a number of entries, each tagged with a unique name starting with a slash character. You can access any named entry by simply passing the unique name to the GetInfo or SetInfo method. Named entries are case-sensitive.

See the Object Paths section of this document for further details.
Count

The maximum Object ID in the document.

This property should only be used with Object ID 0.
License

The current license.

This property should only be used with Object ID 0.

Getting the license returns a description of the current license. Setting the license allows you to install an existing license key.

When setting the license you can use a license key as provided when you purchase. Or you can use a trial license key taken from the PDFSettings application. The trial license key can be useful for deploying on shared servers.
ABCpdfVersion

The current ABCpdf Version String

This property should only be used with Object ID 0.


Specific Objects

These information types are specific to particular types of object. See the Core Objects section for more detail.

Catalog Object

Type Name GetInfo SetInfo Description
Type

Always "cata".

Pages

The Object ID of the Pages Object.

The Pages object holds references to every page in the document.

Outlines

The Object ID of the Outline Object.

The Outline object holds the structure of the document.

Field Count

The number of fields in the document.

Field N

The Object ID of the field specified.

For example, if you want the Object ID of field number three, you would reference GetInfo(thePagesID, "Field 3").

Only leaf fields - those with a visible appearance on the page - are returned. Typically, these are Annotation objects.

Field Name

The Object ID of the named field.

For example, if you want the Object ID of the field with the full name 'address.town', you would reference GetInfo(thePagesID, "Field address.town").

The name may be enclosed in single or double quotes in cases where it is ambiguous whether you are referring to a field name or a number.

Note that the PDF specification does not require that full names be unique. The ID of the first matching field will be returned.

Only leaf fields - those with a visible appearance on the page - are returned. Typically, these are Annotation objects.

Field IDs

A comma delimited list of the Object IDs of all the fields in the document.

Scanning the field tree can be an expensive process. It can be quicker to get a list of all field IDs and use these as required.

Only leaf fields - those with a visible appearance on the page - are returned. Typically, these are Annotation objects.

Field Names

A comma delimited list of the full names of all the fields in the document.

Scanning the field tree can be an expensive process. It can be quicker to get a list of all field names and use these as required.

Only leaf fields - those with a visible appearance on the page - are returned. Typically, these are Annotation objects.

Pages Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "pags".
Page Count |  |  | The number of pages in the document.
Page N |  |  | The Object ID of the page specified. For example, if you want the Object ID of page number three, you would reference GetInfo(thePagesID, "Page 3").

Page Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "page".
Content Count |  |  | The number of objects displayed on the page.
Content N |  |  | The Object ID of the content object specified. For example, if you want the Object ID of the second object on the page, you would reference GetInfo(thePageID, "Content 2").
Annot Count |  |  | The number of annotations displayed on the page
Annot N |  |  | The Object ID of the annotation object specified. For example, if you want the Object ID of the second annotation on the page, you would reference GetInfo(thePageID, "Annot 2").
Rotate |  |  | The amount the page should be rotated when displayed. Page rotations are typically used to ensure that landscape pages appear the right way up when displayed. Page rotations are measured in degrees and may take the values 0, 90, 180 or 270.

Empty Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "empt".
Count |  |  | The number of objects in the document.

Outline Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "outl".

Font Object

Type Name GetInfo SetInfo Description
Type

Always "font".

FontBBox

The rect defining the font bounding box. The values are measured in 1000ths. It is the smallest rectangle enclosing all glyphs positioned at the origin.

Widths abc

The widths of the supplied characters.

For example, if you want the characters 'a' through to 'c', you would reference GetInfo(theFontID, "widths abc").

The widths are returned as a comma delimited list.

Width values are measured in 1000ths. So a character with a width of 600 drawn in 24 point text will appear 14.4 points wide.

LineSpacing

The preferred distance between text lines for the font. For OpenType fonts, the line spacing is calculated honoring the fsSelection bit 7 of the OS2 table. Only recent windows application do this; examples are WPF based applications or MS Word 2007 (equation editor only). For compatibility with older applications, you may need to calculate the line spacing differently:

Ascent - Descent - 1000

where ascent and descent are defined below. The -1000 is to exclude the font height.

The value is measured in 1000ths.

Ascent

The ascent of the font. For OpenType fonts, this is the usWinAscent value of the OS2 table.

The value is measured in 1000ths.

Descent

The descent of the font. For OpenType fonts, this is the usWinDescent value of the OS2 table with the sign changed.

The value is measured in 1000ths and is generally non-positive.

Ascender

The ascender of the font. For OpenType fonts, this is the sTypoAscender value of the OS2 table.

The value is measured in 1000ths.

Descender

The descender of the font. For OpenType fonts, this is the sTypoDescender value of the OS2 table.

The value is measured in 1000ths and is generally non-positive.

LineGap

The line gap of the font. For OpenType fonts, this is the sTypoLineGap value of the OS2 table.

The value is measured in 1000ths and is generally non-positive.

Bookmark Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "book".

Stream Object

Type Name GetInfo SetInfo Description
Type

Always "strm".

Stream

The raw data from the stream. This data may be compressed or otherwise encoded.

Compress

Compresses the stream if it is not already compressed.

Decompress

Decompresses the stream.

ClearDecompress

Clears the cached, decompressed data so that a re-read of the document is not required to release the memory.

The uncompressed data are retrieved from compressed streams during most operations, but the streams are still compressed. The uncompressed data are sometimes cached so that later operations (including the actual decompression of the streams) need not invoke the decompression algorithm.

PixMap Object

Type Name GetInfo SetInfo Description
Type

Always "jpeg" for historical reasons. However, this does not mean that the pixmap is necessarily in JPEG format.

Stream

The raw data from the stream. This data may be compressed or otherwise encoded.

Width

The natural pixel width of the pixmap.

Height

The natural pixel height of the pixmap.

Components

The number of color components the pixmap contains.

Grayscale images contain one component. RGB images contain three components. CMYK images contain four components.

ColorSpace

The Object ID of the Color Space for the pixmap.

Alpha

This allows you to assign a constant alpha value to the image.

The alpha value should range between 0 (fully transparent) and 255 (fully opaque). Values outside this range will result in the alpha constant being removed.

Chromakey

This allows you to assign a transparent color or color range to the image.

You need to specify two values for each component of the color. If all the components of a color fall within the specified ranges, then the color will not be displayed.

For example, to make pure white elements of an RGB transparent, you might specify SetInfo(theID, "Chromakey", "255 255 255 255 255 255"). If you wanted to include colors which were off-white, you might use SetInfo(theID, "Chromakey", "250 255 250 255 250 255").

Grayscale

This allows you to convert an RGB image to Grayscale. It can be useful for preparing soft masks.

Image Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "imag".
Rect |  |  | The rect defining the bounds of the visible content. This rectangle is encoded in PDF coordinates rather than any abstracted coordinate space.
Stream |  |  | The raw data from the stream. This data may be compressed or otherwise encoded.
XObject |  |  | The Object ID of the XObject (PixMap) containing the image data.

Text Object

Type Name GetInfo SetInfo Description
Type

Always "text".

Rect

The rect defining the bounds of the visible content.

This rectangle is encoded in PDF coordinates rather than any abstracted coordinate space.

Stream

The raw data from the stream. This data may be compressed or otherwise encoded.

EndPos

The insertion point for the next character after all the text in this object has been drawn.

Characters

The number of characters drawn.

Lines

The number of lines of text drawn.

Truncated

This property indicates if all the assigned text could be displayed. It takes the value "1" if the text had to be truncated and "0" if not.

Only text objects that have been truncated can be chained to using AddHtml. If you try to chain to a text object that is not truncated, you will get a zero ID returned.

Prev

The previous item in an HTML chain.

If the object is not part of a chain (or is at the head of the chain), you will get a zero ID returned.

Graphic Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "line".
Stream |  |  | The raw data from the stream. This data may be compressed or otherwise encoded.
Rect |  |  | The rect defining the bounds of the visible content. This rectangle is encoded in PDF coordinates rather than any abstracted coordinate space.

Grid Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "grid".
Stream |  |  | The raw data from the stream. This data may be compressed or otherwise encoded.
Rect |  |  | The rect defining the bounds of the visible content. This rectangle is encoded in PDF coordinates rather than any abstracted coordinate space.

Annotation Object

Type Name GetInfo SetInfo Description
Type

Always "anno".

Subtype

The type of annotation.

This may be 'Text', 'Link', 'Widget', or any of the many supported types listed in Section 8.4.5 of the Adobe PDF Specification.

Contents

The visible text of the annotation.

If the annotation subtype does not display text, then this field should contain an alternative description of the annotation contents.

Name

The full name of any form field associated with this annotation.

Note that the PDF specification does not require that full names be unique.

Page

The Page ID of the document page on which this annotation is located.

Rect

The rectangle which defines the position and area of the annotation on the page.

So to paint a rectangle over the top of an existing annotation, you could write the following.

d.Page = d.GetInfo(theID, "Page")
d.Rect = d.GetInfo(theID, "Rect")
d.FillRect

FieldType

The field type for any form field associated with this annotation.

The following field types are available:

  • "Pushbutton"
  • "Checkbox"
  • "Radio"
  • "Text"
  • "List"
  • "Combo"
  • "Signature"
  • "Unknown"

More details of these field types can be found in the Section 8.6.3 of the Adobe PDF Specification.

FieldValue

The field value for any form field associated with this annotation.

You may wish to assign or query the form field value using this property.

Checkboxes and Radio Buttons have a value which is either "Off" or the on-state of the control as specified in the FieldOptions.

Text fields have a free-text value.

Combo Boxes and List Boxes have values restricted to a set of selections as specified in the FieldOptions.

Pushbuttons and Signatures do not have a value.

FieldOptions

The field options for any form field associated with this annotation.

Typically, you assign a value using the FieldValue property. Some fields such as Text fields accept any value. Others such as Checkboxes and List Boxes accept only a limited range of options. The field options tells you what options are available for a particular field.

The unmarked state of a Checkbox or Radio Button is always "Off". The marked state varies and is available via this property.

The set of options for a Combo Box or List Box is available as a comma delimited set of strings which can be obtained via this property.

Pushbuttons, Signatures, and Text fields do not have options.

FT

The effective "/FT" value for any form field associated with this annotation.

This value may be defined in a parent object so the value may differ from the "/FT" value defined directly on this object.

Ff

The effective "/Ff" value for any form field associated with this annotation.

This value may be defined in a parent object so the value may differ from the "/Ff" value defined directly on this object.

DA

The effective "/DA" value for any form field associated with this annotation.

This value may be defined in a parent object so the value may differ from the "/DA" value defined directly on this object.

Q

The effective "/Q" value for any form field associated with this annotation.

This value may be defined in a parent object so the value may differ from the "/Q" value defined directly on this object.

View Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "wemf".
Stream |  |  | The raw data from the stream. This data may be compressed or otherwise encoded.
Rect |  |  | The rect defining the bounds of the visible content. This rectangle is encoded in PDF coordinates rather than any abstracted coordinate space.
Width |  |  | The width of the image in points.
Height |  |  | The height of the image in points.
ContentWidth |  |  | The total width of the HTML image. When adding HTML you only see one page at a time. This property allows you to find the width of the HTML before it is paged onto the PDF. This value is measured in pixels and is usually very close to ScrollWidth.
ContentHeight |  |  | The total height of the HTML image. When adding HTML you only see one page at a time. This property allows you to find the height of the HTML before it is paged onto the PDF. This value is measured in pixels and is usually very close to ScrollHeight.
ScrollWidth |  |  | The scroll width of the HTML image. It is the same scroll width value as retrieved using script inside HTML. This value is measured in pixels.
ScrollHeight |  |  | The scroll height of the HTML image. It is the same scroll height value as retrieved using script inside HTML. This value is measured in pixels.
PageOffset |  |  | The vertical offset from the top of the HTML image to the top of the current page. This value is measured in pixels.
PageWidth |  |  | The width of the portion of the HTML image which is being displayed. This value is measured in pixels.
PageHeight |  |  | The height of the portion of the HTML image which is being displayed. This value is measured in pixels.
Truncated |  |  | This property tells you if there are more pages of HTML to be displayed. It takes the value "1" if the HTML was truncated and "0" if not.
ItemCount |  |  | The number of visual content items present in this object.
ScriptReturn |  |  | Any return value from the OnLoadScript.
Text |  |  | The text visible on the view. Note that the text is in layout order not necessarily in reading order.
URL |  |  | The URL of the page which was rendered.

Gecko View Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "cact".
Stream |  |  | The raw data from the stream. This data may be compressed or otherwise encoded.

Graphics State Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "grst".

ColorSpace Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "cols".
Space |  |  | The type of color space.
Name |  |  | Any name associated with the color space. For example, the name of a spot color.
ICCProfile |  |  | The Object ID of any associated ICC Color Profile.

ICCProfile Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "iccp".
Stream |  |  | The raw data from the stream. This data may be compressed or otherwise encoded.

Object Stream Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "obst".
Stream |  |  | The raw data from the stream. This data may be compressed or otherwise encoded.

XRef Object

Type Name | GetInfo | SetInfo | Description
Type |  |  | Always "xref".
Stream |  |  | The raw data from the stream. This data may be compressed or otherwise encoded.


Object Paths

You can use the GetInfo and SetInfo methods to directly manipulate any PDF object in your document. However, this is not advisable unless you are reasonably familiar with the Adobe PDF Specification.

Under normal situations, ABCpdf ensures that your documents are internally consistent. Using the SetInfo method with Dictionaries, Values or Paths allows great flexibility in modifying documents but also allows you to create invalid or corrupt documents.

Dictionaries

If your object is a dictionary, you can specify a particular dictionary entry for replacement or insertion (dictionary entries always begin with a slash '/' character). So if you wanted to change the type of an annotation, you might use the following code:

theDoc.SetInfo theID, "/Subtype", "(Stamp)"

Values

Alternatively, you can use the 'Value' selector to specify a replacement for the entire object. However, if you do this, you must ensure that the type of your new object is the same as the type of your old one - you cannot replace a number with a string. For example.

theDoc.SetInfo theID, "Value", "<</Font /Helvetica /Size 10>>"

Paths

Specifications can be chained together to form complete paths. Dictionary entries are specified by preceding the entry name with a slash. Array items are specified using square brackets containing the index of the item you wish to reference (starting at zero).

For example, the code below would return the first item in the MediaBox array.

theDoc.GetInfo(theID, "/MediaBox[0]")

And the code below would return the count entry of the parent of the object.

theDoc.GetInfo(theID, "/Parent/Count")

References

Sometimes, you may wish to find a reference to a particular object. Sometimes, you may wish to skip through the reference and jump straight into the object itself.

You can do this using an asterisk to de-reference an object within a path. If the object is a reference, it will be de-referenced; if it is not, then the operator will be ignored.

For example, the code below might be used to return the content stream of the first page of a document.

theDoc.GetInfo(theDoc.Root, "/Pages*/Kids*[0]*/Contents")

SetInfo

You can use SetInfo to insert values specified by paths. You can specify the type of object to be inserted by appending an identifier to the path.

Object Type Description
:Bool

A boolean value.
:Name

A name value.
:Num

A numeric value
:Text

A string value.
:Ref

An indirect reference to an object.
:Rect

A rectangle. Internally rectangles are held as arrays of numbers but this provides a convenient shortcut.
:Del

This is a special entry. It does not insert an object. Instead it ensures that the object specified by the path is deleted.
:Text[Hex*NoBreak*Byte]

The asterisk is a delimiter. Each of "Hex", "NoBreak", and "Byte" is optional. For example, you can specify "/MyEntry:Text[Hex]".

"Hex" indicates that the text will be written in hexadecimal string to PDF content. "NoBreak" indicates that the (long) string is not broken into multiple lines when written to PDF content. "Byte" indicates that the text is not encoded in Unicode and the least significant octets of code point values of the characters are written as bytes to PDF content. You will not need to specify these output formats under normal uses.

Suppose you wanted to insert an annotation into the page annotations array. The following code will find the page entry named "/Annots" (or it will create it if it doesn't exist). It will then ensure that this entry references an array, and it will insert a reference atom at the beginning (item zero) of the array.

theDoc.SetInfo theDoc.Page, "/Annots[0]:Ref", theID

Alternatively, if you want to insert your annotation at the end of the array, just leave out the array index:

theDoc.SetInfo theDoc.Page, "/Annots[]:Ref", theID

You can also locate items in an array from the end. Use -1 for the last item, -2 for the second last item, and so on.

theDoc.GetInfo(theDoc.Page, "/Annots[-1]:Ref")

Insertions can be complex. The next example gets the entry called "/Font" which contains a dictionary. This dictionary includes an element called "/Names" which contains an array. The call inserts the Name object "/Helvetica" at the start of this array.

theDoc.SetInfo theID, "/Font/Names[0]:Name", "Helvetica"

GetInfo

You can use GetInfo to query values specified by paths. The format of the return value is exactly the same as would be output to your PDF file. You can specify an alternative format by appending an identifier to the string.

Format Name | Description
:ID | The Object ID associated with an object reference. Normally, object references are returned in an extended format (e.g. 23 0 R). However, if you are only interested in the Object ID, then you use this format specifier to get only the Object ID (e.g. 23).
:Obj | The object value. This is used to ensure that all indirect references are resolved before the value of the object is returned. This ensures you always get an object value rather than an object reference.
:Text | The text of a name or string. Names and strings may be encoded in a number of ways before output to PDF. The text format specifier ensures that the unencoded value is returned.
:Num | The value of a number. If the object referred to is not a number then no value is returned.
:Rect | The rect string for a rectangle object. Rects are typically represented as an array. By specifying the rect format, you will get a string value you can place directly into the XRect object.
:Count | The number of items in an array. The count specifier is a special directive which returns the number of items in an array rather than an item from that array.
:KeyCount | The number of items in a dictionary. The keycount specifier is a special directive which returns the number of items in a dictionary rather than an item from that dictionary.
:Keys | The keys for a dictionary. The keys specifier is a special directive which returns a comma delimited list of the names of the entries in the dictionary.

For example, the code below could return the rect of the page CropBox.

theDoc.GetInfo(theID, "/CropBox:Rect")


XML to PDF

When ABCpdf was designed, a conscious design decision was made not to make it XML based. While XML templates might be an obvious route to take, there are problems with this approach.

The key factor is that the creation of a PDF document is an interactive one. Often, you don't know how much text you're going to be adding until you're given the text. You may need to flow the text from one column to another, you may need to create a new page to hold any extra text, or you may choose to reduce the font size so that all your text fits. These are the kinds of decision that are very difficult to describe in terms of XML.

Although it is easy to create an XML based PDF generator using a product like ABCpdf, it is not possible to work the other way round. So you can produce template based documents using ABCpdf. If you were to want to implement interactive code using an XML based solution, this would be impossible.


Manual Installation

Under most circumstances, you will want to install ABCpdf using the standard installer and register it using the PDFSettings control panel.

Occasionally, you may wish to install ABCpdf manually. To do this, you will need the files listed below.

File Name
 Notes
ABCpdf.dll

The Assembly used by .NET.

The installer places this Assembly in the GAC to allow global access from any .NET application. It installs a second reference copy at the following location:

%ProgramFiles%\WebSupergoo\ABCpdf14 .NET\Common\

However, if you are installing manually, you can just place this file in the bin directory of your application.

ABCpdf14-32.dll

The ABCpdf core engine.

This DLL contains the core engine. It incorporates our proprietary Direct to PDF technology and is designed for high-performance PDF manipulation in a multithreaded environment. This DLL is placed into the system32 directory typically at:

%SystemRoot%\system32\

However, if you are installing manually, you can just place this file in the bin directory of your application.

ABCpdf14-64.dll

The same as ABCpdf14-32.dll but for 64-bit operating systems.

Please note that ABCpdf14-32.dll is required for 32-bit processes running under WOW64 on 64-bit operating systems.

ABCpdf.tlb

The COM type library for ABCpdf.

This file provides the necessary information for COM clients to locate and use ABCpdf. The script file 'register.bat' will generate and register the type library for you. It is by default installed to a sub-directory of the ABCpdf application folder, but may optionally be placed and executed in the same directory as ABCpdf.dll

ABCChrome (directory)

This is an optional component required for use of the ABCChrome HTML engine.

This folder should be placed in the bin directory (next to ABCpdf.dll).
ABCGecko.dll,
XULRunner (directory)

This is an optional component required for use of the Gecko HTML engine.

This DLL should be placed in the bin directory (next to ABCpdf.dll).

This DLL is the interface ABCpdf uses to access the Gecko HTML engine. However, it is not the engine itself. The engine is held in the XULRunner folder, which must be located in the same directory as ABCGecko.dll.

ABCGecko cannot function without the XULRunner folder in the same directory as ABCGecko.dll.

You can use a full license key as provided to you when you purchase, or you can use a trial license key copied from the PDFSettings application. To enter a license key, create a simple Visual Basic Application containing the following code.You will need write access to the registry to install a license key.

Set theSettings = CreateObject("ABCpdf14.XSettings")
' here we use a trial license key as copied from the PDFSettings application
If theSettings.InstallSystemLicense("cd9b5c07db69df2bf57c0a04d9bca58b10c44889c9fb197984e592f49addfce5ec5fe85d7b9205bc") Then
  MsgBox "New license: " & theSettings.License
Else
  MsgBox "License installation failed."
End If

Alternatively, you can install a license from within your Doc object.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' here we use a trial license key as copied from the PDFSettings application
theDoc.SetInfo 0, "License", "cd9b5c07db69df2bf57c0a04d9bca58b10c44889c9fb197984e592f49addfce5ec5fe85d7b9205bc"
Response.Write theDoc.GetInfo(0, "License")

Under some circumstances, you may wish to install a temporary license. Write access to the registry is not required when using this method, but the license which is installed is only temporary. It is available until the process unloads.

Set theSettings = CreateObject("ABCpdf14.XSettings")
If theSettings.InstallRedistributionLicense("change this text to your key") Then
  MsgBox "New license: " & theSettings.License
Else
  MsgBox "License installation failed."
End If


Fonts and Languages

Base

The base fonts are guaranteed to be available on all systems.

Using the base fonts in your PDF results in a small document which is guaranteed to render in the same way on all systems. However, the base fonts do not support complex languages such as Chinese and Japanese, and they do not support some characters used in Eastern Europe.

The following are the names of the base fonts.

  • Times-Roman
  • Times-Bold
  • Times-Italic
  • Times-BoldItalic
  • Helvetica
  • Helvetica-Bold
  • Helvetica-Oblique
  • Helvetica-BoldOblique
  • Courier
  • Courier-Bold
  • Courier-Oblique
  • Courier-BoldOblique
  • Symbol
  • ZapfDingbats

Use the AddFont method to reference these fonts.

Embed

Embedded TrueType or OpenType Unicode fonts are generally the most efficient and reliable way of adding complex language support to your PDF documents. However, you need to ensure that you have permission to embed and redistribute your chosen font.

ABCpdf includes options to try and protect you from inadvertently embedding copyrighted fonts. However, you should not rely on this protection. If you wish to embed fonts, it is vitally important that you think about the way these fonts will be used and that you understand the operations permitted by the copyright holder. Ultimately, you need to take responsibility for any fonts you embed in your PDF documents.

When embedding large fonts, you should generally choose to subset them. Not only does it produce smaller PDF documents, but it is also generally faster to embed a subset of a large font than to embed the entire font.

Use the Doc.EmbedFont method to embed fonts.

The table below shows the valid combinations of language and horizontal and vertical writing directions.

Language | Horizontal | Vertical | Notes
"Latin" |  |  | The default and most efficient encoding for Western languages.
"Unicode" |  |  | The setting you will most often want to use when embedding foreign character sets
"Korean" |  |  |
"Japanese" |  |  |
"ChineseS" |  |  | Simplified Chinese
"ChineseT" |  |  | Traditional Chinese

Refs

Referenced TrueType or OpenType fonts produce a smaller PDF document. However, for complex languages, you will need a recent version of Adobe Acrobat, and you will need to install the relevant language pack. Without these, you will not be able to view your documents and your viewer may report errors.

Use the Doc.AddFont method to reference fonts.

The table below shows the valid combinations of language and horizontal and vertical writing directions.

Language | Horizontal | Vertical | Notes
"Latin" |  |  | The default and most efficient encoding for Western languages.
"Unicode" |  |  |
"Korean" |  |  | Requires the relevant Adobe Acrobat Language Pack
"Japanese" |  |  | Requires the relevant Adobe Acrobat Language Pack
"ChineseS" |  |  | Simplified Chinese requires the relevant Adobe Acrobat Language Pack
"ChineseT" |  |  | Traditional Chinese requires the relevant Adobe Acrobat Language Pack

Type 1

Sometimes, typically when dealing with the Mac platform, you may need to add or embed Type 1 fonts. You can do this using Doc.EmbedFont or Doc.AddFont in exactly the same way as you would for any other font.

Type 1 fonts contain a limited set of characters. As such, the only language which is available is the "Latin" language.

Unlike TrueType fonts, you can reuse Type 1 fonts, previously been embedded in a PDF and read using the Doc.Read method.

To access a font which has been previously embedded in the document, search through the objects looking for objects of type 'font'. Assign the ID of the object to the Doc.Font property. Note that only standard (WinAnsiEncoding) Type 1 fonts are available in this way.

If you need to obtain the name of the font embedded in a PDF, use the following code to get the PostScript name of the font.

theDoc.GetInfo(theID, "/BaseFont:Name")

Issues

ABCpdf will allow you to use any valid TrueType or Type 1 (PostScript) font.

If you are having problems accessing a particular font, try disabling the ABCpdf font protection functionality. However, note that you should not embed and redistribute fonts unless you have permission to do so.

ABCpdf maintains a font cache. This means that for ABCpdf to pick up on a newly installed font, you will need to restart any processes that are using ABCpdf.

Alternatively, you can pass the path to your font file to the AddFont or EmbedFont method. This will automatically load the font file. Do not move the font file after doing this - ABCpdf relies on fonts staying in place.

Sometimes permissions are placed on individual font files which may restrict access from restricted permission accounts such as ASP or ASP.NET.

Occasionally, TrueType fonts are corrupt or non-standard. This can cause problems for ABCpdf (which will refuse to recognize them) or Acrobat (which will refuse to use a font embedded in the PDF). However, this type of problem is relatively infrequent and tends to be restricted to unusual fonts such as bar-codes.

If you hit a problem you think is related to a corrupt or non-standard font, please mail us the font and we'll see what we can suggest.


Fields and Forms

Basics

PDF allows the creation of interactive forms. Sometimes, you will hear these types of PDF referred to as electronic forms, eForms or AcroForms.

To a client, an eForm simply looks like a normal PDF containing text boxes, buttons and other interactive elements of the type you typically see on the web.

Indeed, eForms support elements almost identical to HTML forms. They also support mechanisms very similar or identical to HTML forms for content submission to a web server.

For more details, see the Adobe Web Site.

Fields

Most people coming to eForms will be coming from an HTML background. There are subtle differences between the PDF form model and the HTML form model that can cause confusion.

In HTML, a form is part of a web page. Each field in the HTML form has a visible appearance on the page (with the exception of hidden fields). So the concept of a field and what it looks like on the page is pretty much identical.

eForms separate the idea of a field from its visible representation.

Each page of the document owns a set of visible annotations. There are lots of different types of annotation, but the ones that are used in eForm fields are called widgets. A widget contains properties that allow a PDF reader to display it appropriately on the page.

Each document owns a tree structure of fields which spans the entire document. Each field has a name and also a full name (like a file path), which tells you how to get to that field from the top level of the tree. The leaves of the tree contain the visible widgets that you see on the pages. Note that PDF does not require that full names be unique.

So there are two independent sets of entities, each with its own features. The bits you see and which people normally call fields are in fact widgets.

Widgets don't have a name or identity as such - it's just that they may be associated with a field which has an identity. Similarly, a field doesn't exist at a location or on a page it is just that it is associated with a widget that exists at a particular location on a particular page.

ABCpdf hides these distinctions from you. When you ask for a field by name, it will return you the widget associated with that field. Given the widget, you can find out where it is physically located in terms of page numbers and page rectangles. Similarly, if you have a widget, you can ask it for a field name. Behind the scenes, ABCpdf finds the field associated with the widget and returns you the field name.

Why?

So why are eForms useful? There are a range of purposes to which eForms can be put. However, probably the most common purpose is to provide placeholders in template PDFs.

Suppose you have a template document you want to use within ABCpdf. Using Acrobat, you can insert form fields into the PDF at locations you want content to be inserted. Using ABCpdf, you can automatically detect the locations of those fields and enter content at those locations.

If later you want to shift your content a little, it's a simple matter to open the PDF in Acrobat and move the fields around.

See the eForm Example for details.

Creation

You can use Acrobat to edit forms using the Advanced Editing tools available under the Tools menu.

However, if you choose items from the Forms menu or toolbar, then you will probably find that you end up editing your form in Adobe Designer rather than Acrobat.

Adobe Designer is an application which comes with Acrobat Pro. It uses PDF as an output medium. However, the way that Designer operates means that forms created by Designer are fundamentally different from forms created by Acrobat.

For example, an Acrobat created form typically contains a background and then a set of fields. The fields operate separately from the background.

Adobe Designer-created forms do not make this distinction. They use a separate data store to specify the fields. The PDF content is merely the visible rendition of this field specification. The underlying field specification is made up of chunks of XML embedded in the PDF.

Because Designer documents are PDF documents, you can add content to them using standard ABCpdf methods of adding PDF content. However, if you then open them then in Designer, the content will most likely be deleted because Designer will recreate the PDF appearance using the separate field specification.

Equally, because the PDF output is merely the visible rendition of a separate field specification, the fields and background may be tied to each other. So you might use ABCpdf to delete a field and find that the border has been left behind.

If you want to modify forms, you will generally find it easier to work with Acrobat-created forms than Designer-created ones.


Image Handling

Basics

ABCpdf embeds images into the PDF at their original resolution. Images may be displayed at different sizes, but the underlying image is exactly the same. If your image looks grainy when you print, you'll need to find a higher resolution (bigger) image.

Suppose you have an image 300 pixels wide by 600 pixels high. If you wanted this image to print well at 300 dpi, then you would need to add it into a rectangle no larger than 1 inch by 2 inches. If you wanted to view it at a screen resolution of 75 dpi, you could place it into a rectangle up to 4 inches by 8 inches.

Modes

You can present images to ABCpdf in one of two ways.

You can operate in pass-through mode and add an image directly into your Doc object. Doc.AddImageFile and Doc.AddImageData operate in pass-through mode.

Alternatively, you can operate in indirect mode and draw your data into an Image object before adding the Image object to your document. The Doc.AddImageObject method defaults to indirect mode.

Indirect mode has a number of advantages over pass-through mode.

Because each image is fully decoded when it is presented to the Image object, image corruption can be caught at this stage. Corrupt images are not uncommon, and if you don't detect the corruption before the data is inserted, you may end up with a corrupt PDF.

Images are color-corrected, which means that color profiles do not need to be embedded and file size may be reduced.

Pass-through mode has advantages for some types of images.

Because the image may not have to be decompressed and re-compressed, using pass-through mode can be much faster than indirect mode. This is particularly true for scanned TIFF images.

Because the original image compression is maintained, there is no possibility of expansion due to re-compression.

Images are inserted in their native color space together with any color profiles - this guarantees fidelity of color reproduction.

Colors

Colors can be specified in a number of ways - most commonly in terms of RGB or CMYK values. These values are literal - RGB values relate directly to the brightness of the red, green and blue phosphors on a display - CMYK values relate directly to the amounts of Cyan, Magenta, Yellow and Black inks applied to a piece of paper.

These literal values do not always equate to the same perceived color. Monitors vary and an image displayed on one may look quite different to the same image displayed on another. Similarly a CMYK value applied with one printer to one type of paper may look quite different to a CMYK value applied with a different printer to a different type of paper.

The International Color Consortium (ICC) provides specifications to allow an independent definition of color. An ICC color profile is designed to complement your raw color data. So if you have a CMYK image, you also specify a color profile which tells you more about the intended destination of the image. This allows you to adjust the colors for your intended output medium.

In order to maintain flexibility and color fidelity, it is important to preserve both the raw image data and the ICC profile associated with it. This can only be done if you provide images in pass-through rather than direct mode.

ABCpdf will accept RGB TIFF, CMYK TIFF, LAB TIFF, Grayscale JPEG, RGB JPEG and CMYK JPEG direct. This means whatever colors you pass into ABCpdf will go direct into the PDF without any modification. Additionally, any ICC profile will be preserved and inserted appropriately so that the colors can be adjusted accurately for any output.

Comp

So what types of compression does the Image object use?

The Image object generally uses Flate compression. This is the same compression type as is used for PNG images. It is a lossless method which ensures that the quality of your original image is maintained.

However, if your source image is black-and-white, then ABCpdf will use CCITT G4 fax compression as this typically results in reduced file sizes for this type of image.


HTML Styled Text

Basics

ABCpdf allows a range of HTML support for use when inserting multi-styled text. This can make it much easier to design documents, and it can reduce the quantity of code required.

The HTML support offered here does not cover the entire HTML specification. It covers a limited range of the HTML specification as is required for styled text. It also extends the HTML specification to allow you to precisely control elements of style not covered by HTML.

Chars

ABCpdf lets you use Unicode text. So you can use HTML Styled Text with any language from English to Korean to Japanese.

Normal character entities are standard HTML and hence use the Latin 1 character set. For example, '&#153;' equates to the trademark sign.

For convenience, you can also specify hex and octal character entities. For example, '&#65;', '&#x0041;' and '&#o0101;' all equate to lower case 'a'. Hex and octal character entities are assumed to be expressed in the Unicode character set.

For most situations, this will make no difference. However, you should note that, above character 127, there are differences between the Latin 1 and the Unicode character set. For example, the trademark symbol, which is character 153 in Latin 1, is 8482 in Unicode.

If you require fine control over hyphenation, you can make use of the soft hyphen character - '&shy;'. This character is invisible and indicates a point at which a chunk of text may reasonably be broken.

Tags

You can add HTML to your documents using the AddHtml method. ABCpdf supports the following HTML tags and attributes.

  • <Head>
  • <Body>
  • <BR>
  • <P>
  • <H1> to <H6>
  • <List>
  • <UL>
  • <OL>
  • <LI>
  • <A>
  • <B>
  • <I>
  • <U>
  • <Strike>
  • <Sup>
  • <Sub>
  • <Font>
  • <StyleRun>
  • <BlockQuote>
  • <Pre>

<Head>

This tag is used to delimit the head of an HTML document. All content in the head is ignored.

This tag does not accept any attributes.

<Body>

This tag is used to mark the body of an HTML document. The body is a type of stylerun, and so it accepts the same attributes as a stylerun tag. It also accepts the following additional attributes.

Attribute Notes
link

The color for links (anchors) in subsequent content.

Colors are generally specified as RGB in hexadecimal notation (e.g. color="#FF0000") or as one of the sixteen standard color names (e.g. color=red").

You can specify grayscale colors by supplying only one component (e.g. color="#80") and CMYK colors by supplying four (e.g. color="#10203040"). CMYK component ranges between 0 and 100 inclusively so the hexadecimal representation is between 00 and 64.

The default link color is RGB blue.

<BR>

This tag is used to force a line break.

This tag does not accept any attributes.

<P>

This tag is used to mark up paragraphs. Paragraphs are types of styleruns, and so they accept the same attributes as stylerun tags. They also accept the following additional attributes.

Attribute Notes
align

The text alignment for the paragraph. If no value is specified, it is assumed that the text should be left aligned.

You can specify left aligned text (e.g. align=left), right aligned text (e.g. align=right), centered text (e.g. align=center) or justified text (e.g. align=justify).

Changing this attribute is identical to changing the Doc.HPos or XTextStyle.Justification properties.
break

The line breaking style for the paragraph. This attribute takes a comma delimited list of hints used to control how lines are broken when chaining from one text area to another.

You can specify that a paragraph should be kept with the next one by assigning the keepwithnext hint (e.g. break=keepwithnext). You can specify that there should be a break before a paragraph by specifying the breakbefore hint (e.g. break=breakbefore).

For details on chaining, see the AddHtml method.
spacebefore

Normally, paragraphs have vertical space before and afterwards the body text.

By setting this attribute to zero, you can remove vertical space before the paragraph.
spaceafter

Normally, paragraphs have vertical space before and afterwards the body text.

By setting this attribute to zero, you can remove vertical space after the paragraph.

<H1> to <H6>

This tag is used to mark header sections. Headers are types of paragraphs, and so they accept the same attributes as paragraph tags.

<List>

This tag is used to indicate a list of items. Each list item consists of a marker and some text. Markers may be bullet points, numbers or letters.

Lists are types of paragraphs, and so they accept the same attributes as paragraph tags. They also accept the following additional attributes.

Attribute Notes
itemindent

The indent of the item text from the left of the marker. This value is measured in the current units.

By altering this property, you can change the distance between the marker and the text.

The default is dynamically determined based on the type of marker and the size of the text.
markerindent

The indent of the left of the marker from the current left of the surrounding text. This value is measured in the current units.

By altering this property, you can alter the the indent distance for the markers in the list.

The default is dynamically determined based on the type of marker and the size of the text.
start

Specifies the starting number for the first item in the list.

This is only used when ordered markers are specified.

The default is one.
type

Specifies the type of marker to use. You can use either ordered markers or unordered markers.

Ordered markers increment for each item in the list. You can use numbers (type=1), lower case roman numerals (type=i), upper case roman numerals (type=I), lower case letters (type='a') or upper case letters (type=A).

Unordered markers are the same for each item in the list. You can specify bullet points (type=disk), hollow bullets (type=circle) or squares (type=square).

The default type is 'disk'.

<UL>

The UL tag is used to indicate an unordered list. Unordered lists are types of lists, and so they accept the same attributes as list tags. The default marker is the bullet point, but the marker will change as lists are nested within each other.

<OL>

The OL tag is used to indicate an ordered list. Ordered lists are types of lists, and so they accept the same attributes as list tags. The default marker type is numeric.

<LI>

This tag is used to indicate an item within a list. It accepts the following attributes.

Attribute | Notes
value | Specifies the number for this list item. Subsequent items are numbered incrementally from this new value.
type | Specifies the type of marker to use. You can use the same types as you find in the type attribute of the list tag.

<A>

The anchor tag is used to mark subsequent content as a hyperlink. Anchors are types of styleruns, and so they accept the same attributes as stylerun tags. They also accept the following additional attributes.

Attribute | Notes
href | The URL of the destination.

Hyperlinks normally appear as blue underlined text. You can override this style using the body link attribute or by using stylerun attributes in the body of your anchor tag.

<B>

This tag is used to apply a bold text style to subsequent content.

ABCpdf will attempt to reference an appropriate bold font. If it cannot locate one, it will generate a synthetic bold style using the XTextStyle.Bold property.

This tag does not accept any attributes.

<I>

This tag is used to apply an italic text style to subsequent content.

ABCpdf will attempt to reference an appropriate italic font. If it cannot locate one, it will generate a synthetic italic style using the XTextStyle.Italic property.

This tag does not accept any attributes.

<U>

This tag is used to apply an underline text style to subsequent content. The effect is identical to changing the XTextStyle.Underline property.

This tag does not accept any attributes.

<Strike>

This tag is used to apply an strike-through text style to subsequent content. The effect is identical to changing the XTextStyle.Strike property.

This tag does not accept any attributes.

<Sup>

This tag is used to indicate text to be rendered as superscript.

This tag does not accept any attributes.

<Sub>

This tag is used to indicate text to be rendered as subscript.

This tag does not accept any attributes.

<Font>

The font tag is used to change the current font style. Fonts are types of styleruns, and so they accept the same attributes as stylerun tags. They also accept the following additional attributes.

Attribute Notes
size

The font size for subsequent content.

You can set absolute font size by specifying an integer ranging from one to seven (e.g. size=6). Or you can specify a font size relative to the current base font size (e.g. size="+1").

For greater control over the size of text, you should use the fontsize attribute.
color

The color for subsequent content.

Colors are generally specified as RGB in hexadecimal notation (e.g. color="#FF0000") or as one of the sixteen standard color names (e.g. color=red").

You can specify grayscale colors by supplying only one component (e.g. color="#80") and CMYK colors by supplying four (e.g. color="#10203040"). CMYK component ranges between 0 and 100 inclusively so the hexadecimal representation is between 00 and 64.

You can specify an alpha value for your color by appending a slash and a hex value to the end of your color string (e.g. color="#10203040/C0").

You can specify that no color should be applied by using the special 'none' keyword (e.g. color="none"). This can be useful if you wish to specify your own color operators in your own low-level code.

This attribute sets both the stroke and fill colors.
color-stroke

The stroke color for subsequent content.

This attribute allows you to specify the stroke color independently from the fill color.
color-fill

The fill color for subsequent content.

This attribute allows you to specify the fill color independently from the stroke color.
csid

The color space for subsequent content.

This attribute takes an Object ID obtained from a previous call to AddColorSpaceFile or AddColorSpaceSpot.

This attribute sets both the stroke and fill color space.
csid-stroke

The stroke color space for subsequent content.

This attribute allows you to specify the stroke color space independently from the fill color space.
csid-fill

The fill color space for subsequent content.

This attribute allows you to specify the fill color space independently from the stroke color space.
face

The font typeface for subsequent content.

This value takes a comma delimited list of typeface names, listed in order of preference. Fonts are referenced rather than embedded.

For greater control over the way that fonts are added to your document, you should use the pid attribute.
embed

Whether to embed or reference fonts added via the face attribute.

For details, see the EmbedFont method. The default is false.
language

What language to use when embedding fonts added via the face attribute.

For details, see the EmbedFont method. The default is Latin.
protection

Whether to to apply font protection when embedding fonts added via the face attribute.

For details, see the EmbedFont method. The default is true.
font-family

The font family for subsequent content.

This value operates in the same way as the face attribute detailed above.
font-style

The font style.

This attribute can take the values oblique, italic or normal. Normal is the default.

NB. ABCpdf does not currently make a distinction between oblique and italic styles.
font-weight

The font weight.

This attribute can take the a value between 100 (lightest) and 900 (heaviest).

It can also take the following pre-defined values - normal, bold, bolder and lighter.

The default is normal - 400.

NB. ABCpdf cannot currently synthesize font weights of less than 400.
rendering-mode

The text rendering mode. Possible values are:

0 Fill text (default)
1 Stroke text.
2 Fill, then stroke text.
3 Neither fill nor stroke text (invisible).
4 Fill text and add to path for clipping.
5 Stroke text and add to path for clipping.
6 Fill, then stroke text and add to path for clipping.
7 Add text to path for clipping.

NB. The outline style is a more commonly used alternative to the rendering-mode.

<StyleRun>

The stylerun tag is used to change the current style. It accepts the following attributes.

Attribute Notes
pid

The font typeface for subsequent content.

This attribute takes an Object ID obtained from a previous call to AddFont or EmbedFont.
fontsize

The font size for subsequent content.

Changing this attribute is identical to changing the XTextStyle.Size property.
charspacing

The character spacing for subsequent content.

Changing this attribute is identical to changing the XTextStyle.CharSpacing property.
wordspacing

The word spacing for subsequent content.

Changing this attribute is identical to changing the XTextStyle.WordSpacing property.
justification

The justification for subsequent content.

Changing this attribute is identical to changing the XTextStyle.Justification property.
hpos

The horizontal positioning for subsequent content.

Changing this attribute is identical to changing the Doc.HPos property.
bold

Whether to apply a synthetic bold style to subsequent content.

Changing this attribute is identical to changing the XTextStyle.Bold property.
italic

Whether to apply a synthetic italic style subsequent content.

Changing this attribute is identical to changing the XTextStyle.Italic property.
underline

Whether to underline subsequent content.

Changing this attribute is identical to changing the XTextStyle.Underline property.
strike

Whether to apply a strike-through effect to subsequent content.

Changing this attribute is identical to changing the XTextStyle.Strike property.
strike2

Whether to apply a double strike-through effect to subsequent content.

Changing this attribute is identical to changing the XTextStyle.Strike2 property.
outline

Whether to outline subsequent content.

Changing this attribute is identical to changing the XTextStyle.Outline property.
linespacing

The line spacing for subsequent content.

Changing this attribute is identical to changing the XTextStyle.LineSpacing property.
paraspacing

The paragraph spacing for subsequent content.

Changing this attribute is identical to changing the XTextStyle.ParaSpacing property.
leftmargin

The left margin for subsequent content.

Changing this attribute is identical to changing the XTextStyle.LeftMargin property.
indent

The indent for subsequent content.

Changing this attribute is identical to changing the XTextStyle.Indent property.
fixedwidth

A fixed with for the style run.

Each style run has a width. The width is normally determined by the size of the characters in the text.

Under some situations, it can be useful to assign a fixed width to the entire style run. This can be used for aligning text and for bullet pointed lists.
textrise

The text rise for subsequent content.

Positive values shift the text upwards. Negative values shift it downwards. The textrise distance is measured in the current units.
annots

Annotations associated with subsequent content.

You can use a link annotation to insert a hyperlink (e.g. annots=​'link:http://www.google.com/').

You can use a goto annotation to insert a link to another page in the document (e.g. annots='goto:3'). The number indicates the page number. Note that the destination page must exist at the point at which the text is inserted.

You can use a text annotation to insert a textual note (e.g. annots='text:A note to be inserted').

You can use highlight, squiggly, underline, and strikeout annotations for text markup. (e.g. annots='highlight:some contents').

While other types of annotations have textual contents (that are specified after colon), link and goto annotations do not. However, you can still mark link and goto annotations with (non-displayed) textual contents using "contents:" so that you can later identify them easily with Doc.GetInfo (e.g. annots=​'link:http://www.google.com/​;contents:alternative description').
dir

The default reading direction.

Bi-directional text such as Hebrew or Arabic is laid out in the context of the default reading direction.

You can specify left to right paragraph direction (e.g. dir=ltr), right to left paragraph direction (e.g. dir=rtl), or use the default of none (e.g. dir=none).

When none is specified, the original ABCpdf left to right layout is preserved for compatibility with previous versions.
canbreakafter

Characters at which lines may be broken.

Normally, ABCpdf will only break lines after certain characters like spaces. You can indicate additional characters after which a break is acceptable using this parameter.

For example, to allow a break after hyphens or underscores, you might use canbreakafter='-_'.
breakengine

The default line breaking engine.

The line breaking engine determines at which points lines can be broken.

You can specify the Uniscribe line breaking engine (e.g. breakengine=uniscribe), the Unicode line breaking engine (e.g. breakengine=unicode), or use the default of auto (e.g. breakengine=auto).

When auto is specified, the Uniscribe engine is used for installations on Windows XP and 2003, and the Unicode engine is used for installations on Windows NT and 2000.
wrap

Whether lines should wrap. The default is true.

If wrapping is turned off (i.e. by setting this value to false), then lines of text extending outside the drawing area will be truncated.
transform

The transformation for text.

The format of this value is the same as that of XTransform.String. The default value is the identity. This attribute takes precedence over the rotate attribute. The numeric values can optionally be preceded by 'fixed' (e.g. transform='fixed 2 0 0 2 0 0'), which fixes the transformation origin.

The direction to which the rightward direction (the default primary advancement direction) is mapped is the primary advancement direction. The direction in which a new line is offset (i.e. the direction of the offset caused by starting a new line) is the secondary advancement direction.

When the origin is not fixed and the StyleRun is broken into pieces (because of nested tags or line breaks, for example), the transformation is applied to each piece individually. When the primary advancement direction is not horizontal, the effect is observably different as each piece starts at the original baseline.

When the origin is fixed, each piece (without its own transformation) appears as if it starts at where the previous piece ends because the transformation origin is fixed at the beginning of the StyleRun.

The secondary advancement direction is always perpendicular to the primary advancement direction regardless of skews in the transformation. (This is meaningful only in the context of multiple lines within a StyleRun with a fixed transformation.) In which of the two opposite directions the secondary advancement is depends on the direction to which the downward direction (the default secondary advancement direction) is mapped. This allows artificial styles that simulate oblique/italic without affecting the secondary advancement.

Decorations (underline and strike-through) are placed at the correct locations without distortion so they remain rectangular.
rotate

The rotation for text.

This value is measured in degrees anticlockwise. The default is zero. This attribute is ignored if the transform attribute is present. The numeric value can be preceded by 'fixed' (e.g. rotate='fixed 30'), which fixes the transformation origin as explained in the transform attribute.
ascender

The default size of the ascender.

The PDF specification defines text as drawn from a point anchored at the baseline of a letter. So to place a chunk of text inside a box, the text needs to be shifted downwards by the distance between the baseline and the top of the letter. This distance is typically known as the ascender height.

ABCpdf uses its own methods to determine the ascender height for fonts. However, using this attribute, you can override these methods and specify your own values. This can be useful for situations in which you are drawing text anchored at the baseline rather than the top of the glyphs.

The ascender value is measured in 1000ths of the font height. A typical value might be 800.

<BlockQuote>

This tag is used to indicate quotations. Block quotes are indented on the left and right relative to the surrounding text. The tag accepts the following attributes.

Attribute | Notes
leftindent | The left indent for the block of text. Distances are measured in the current units. The default is 36 points.
rightindent | The right indent for the block of text. Distances are measured in the current units. The default is 36 points.

<Pre>

This tag is used to indicate preformatted text. Spaces and line breaks are preserved.


Other Coordinate Spaces

Basics

ABCpdf uses the standard PDF coordinate space.

The origin of this space is at the bottom left of the document. Distances are measured up and to the right in points.

Windows often uses a top-down coordinate space. The difference between the bottom-up nature of PDF and the top-down nature of Windows can result in confusion. Using the AddGrid method in your code can be very helpful in resolving this type of issue.

Abstracting the coordinate space can make layout easier but removes you from the underlying page layout embedded into your PDF. For this reason, we would suggest you stick to the standard PDF coordinate space where practical.

If you wish to use a different coordinate system, you can use the document Units and TopDown properties or a Transform to accomplish this. There are subtle differences between these approaches.

Units

The document Units and TopDown properties allow you to use units of measurement like mm or cm. They also allow you to invert the coordinate system so that distances are measured down from the top rather than up from the bottom.

These properties enable an abstraction designed to make layout easier. However, the underlying units of measurement and page layout remain the same.

When you call a page layout operation like AddText or FrameRect, your abstracted coordinates are translated into PDF coordinates before the object is inserted into the document.

For most layout tasks, you can ignore the translation. However, if you are using low-level access to the PDF structure or if you are using Transforms, then you need to be aware of it.

Suppose you call FrameRect and then extract the raw content stream from the returned object. You must be aware that the base coordinates included in the stream are measured in the PDF coordinate space and not in your current coordinate system.

Document Transforms operate on the native PDF coordinate space. So when you specify a rotation around the origin, the origin specified is at the bottom left of the document - not the top.

XForm

Transforms are an inherent part of the PDF specification. They are not an abstraction imposed by ABCpdf but a set of drawing instructions inserted into the PDF document to modify the PDF drawing space. The fact that there is no abstraction can be very useful.

For example, suppose you impose a scale transform so you can specify your page layout in mm rather than points. You then call FrameRect and get the raw content stream from the returned object. The coordinates included in the stream are measured in mm rather than points.

However, transforms can be difficult to understand, and they are extremely literal.

Suppose you impose a transform to flip, scale and translate your coordinate space so that distances are measured in mm from the top left rather than points from the bottom left.

Many graphical objects - lines and rectangles - will appear correctly. However, the transform is literal, and the flip aspect means that any images and text you add will appear upside down.


Registry Keys

Some aspects of ABCpdf can be controlled on a global level using registry keys.

In general, you will not need to use these and you should take the relevant precautions if you decide to insert them.

Details of the registry keys available can be found in the ABCpdf .NET documentation.


Troubleshooting

Intro

We don't expect you to have any problems with our software, but if you do, we offer a full level of support as standard. If you need an extra level of security, we offer a Platinum Level Support program offering a priority channel through to our engineers.

Your first port of call should be to check out the FAQ on our website. If it doesn't cover your particular query, you can mail us email addresses listed there. We prefer queries via email as technical issues are often complicated and require some thought on our side as well as yours. However, if you need to telephone, then numbers are listed on our web site.

Common

Most bug reports relate to misunderstandings, so if you're reporting a bug, please do first check the documentation carefully. If you feel that an issue hasn't been explained well, please do tell us so we can correct it.

Most configuration problems relate to security settings. If you are operating under a restricted security account, please try running your code in a standard application while logged on as Administrator. It will only take you a few minutes to do this, and it will instantly tell you whether you have a security problem.

Because ABCpdf typically renders URLs from the server-side, the server itself may impose limits. For example, if your server has a video card with a limited range of colors, then certain graphics operations may be limited to that number of colors.

If you find anything that doesn't seem right, please say. We don't know unless you tell us.

Basics

Remember to tell us what Operating System you're on and what version of ABCpdf you're using. You can get the exact version of ABCpdf from the PDFSettings control panel. If you're using an older version of ABCpdf, we will be asking you whether the problem occurs using the current download so you may wish to check our downloads page.

If the problem involves URL rendering, please tell us exactly what version of Internet Explorer you have installed on your server. You can get the exact version of Internet Explorer from the About Internet Explorer menu item. If you're using an older version of Internet Explorer, we will be asking you whether the problem occurs using the current version.

Please give us a precise description of what's gone wrong. We like to see examples, so if you have reasonably sized input or output documents which illustrate your point, please do feel welcome to mail them to us.

If the problem relates to a particular resource which we may not have access to - maybe a font or an image - please do send these to us so we can find out what may be unusual about them. If you think we might like to see your code, please show it to us (but please don't send your entire project).

If something's working partially, please tell us what parts are working and what parts are not. If you have any theories or suspicions about what's going on, please do tell us. Also tell us about any unusual software or configuration that might be relevant.

Ideally

The fastest and most reliable way to resolve an issue is to provide a standalone code sample which demonstrates a problem. Please provide input and output resources and tell us what you think is wrong with your output.

A code sample should be small and should illustrate one particular problem. Please do not send us your entire project and please do not send us code we can't run because it's tied to your particular setup.

Please put a little bit of effort into defining exactly what the problem is. In the long run, this will save you time.

Once we have a standalone code example, we can tell you exactly why your code isn't doing what you think it should. If it's a problem with our software, we'll fix it or suggest a workaround. Even if the problem is outside our software, we are often able to suggest workarounds.


Corrupt Documents

Intro

Occasionally, people may supply you with corrupt or non-standard PDF documents.

When you write code to draw on these supplied documents, the drawing may appear in the wrong place or the wrong size or even not at all.

The most common cause of this type of issue is that the document MediaBox is non-standard. For example, designers using Adobe Illustrator can easily manipulate the page MediaBox to produce legal - but unusual - documents.

You should start by using AddGrid as this should give you an idea of the way in which your drawing is failing.

MediaBox

Most PDFs define page size using a MediaBox anchored at the origin. For example, "0 0 612 792".

However, it is not required that you do this, and some PDF documents define a MediaBox that is correct but unusual. For example, "-612 -792 0 0".

You can check whether this is the case by reporting the MediaBox property after the Read method has been called.

If you find this kind of non-standard MediaBox, you are probably drawing your content off the edge of the page.

You will need to adjust your drawing so that it occurs within the bounds of the document MediaBox.

CropBox

The MediaBox defines the area of a page - the actual media size. However, there are other measures as well.

The CropBox defines "the visible region of default user space. When the page is displayed or printed, its contents are to be clipped (cropped) to this rectangle and then imposed on the output medium".

When you display your PDF in Acrobat, what you see is the area of the page defined by the CropBox rather than the MediaBox.

Normally, CropBoxes and MediaBoxes are identical or practically identical. However, occasionally, you may find that they're not.

This may cause your output to appear in a different location from the one you are expecting.

Indeed, your PDF may also impose a TrimBox or a BleedBox. If you're curious about these, there are full details in the Adobe PDF Specification.


HTML / CSS Rendering

Intro

ABCpdf fully supports HTML and CSS.

You can render individual pages of HTML using the AddImageUrl method.

You can page HTML over multiple PDF pages using the AddImageUrl method in combination with the AddImageToChain method.

ABCpdf allows you to treat HTML like any other media so you can even page your HTML across multiple columns of multiple pages of your PDF.

Method

HTML was designed to specify the meaning of document content and leave the precise rendering and layout up to the browser. PDF was designed to specify the appearance of a document and ignore the meaning of the document content. HTML and PDF are fundamentally different.

HTML is being changed to allow greater control over the appearance of a document, and PDF is being changed to allow the meaning of a document to be better represented. However, the fact that the two specifications are based on diametrically opposing concepts does mean that it can be difficult to convert between the two.

ABCpdf uses the Microsoft Internet Explorer HTML engine to parse and preprocess the HTML for insertion into your PDF. This provides an extremely accurate rendition of the HTML.

However, this method is not suitable for every situation. Interaction with the rendering engine is only available via COM, and while ABCpdf takes great care to isolate itself from COM dependencies, rendering a page of HTML is not as fast as building an equivalent page using native ABCpdf rendering methods.

Cache

ABCpdf holds a cache of recently requested URLs, and it's only after five minutes or so that these pages expire from the cache.

This results in a considerable degree of optimization for many common operations. However, if you wish to bypass the cache, you can do so by setting the DisableCache parameter to true when you call AddImageUrl or AddImageHtml.

Occasionally, you may find that your page is being cached elsewhere. There are all kinds of places this can happen. For example, Windows sometimes caches individual page resources. Proxy servers may cache entire pages.

If you want to be totally sure that your URLs are rendered afresh each time, you need to vary the URL. For example:

http://www.microsoft.com/?dummy=1
http://www.microsoft.com/?dummy=2
http://www.microsoft.com/?dummy=3

These will all render the same page (www.microsoft.com), but because the URL is varying, you can be sure that they will be rendered afresh each time.

Caveats

You can render any page you can supply a URL for.

When you render a page, the page has to be reloaded by ABCpdf. This is because you - as a client - are looking at the page from your current machine. ABCpdf lives on the server and so it exists in a different session.

So you cannot generally rely on cookies, session state or form submission in your page. The page must be reliant only on the URL you supply.

If you have to rely on session state, you could use cookieless sessions (which will give you a URL for your session), or you could save the session information under a specific unique ID, then pass the ID via the URL, and pick up the information via your server-side code.

If you are using Authentication, you should provide a logon name and password in the ABCpdf HTML Options. Problems which appear to be related to SSL or HTTPS connections are often authentication issues simply solved by providing a user name and password.

Size

Screen resolution is typically 96 dpi. So when you view an HTML page on your monitor, Windows will display it at 96 dpi.

The disparity between the screen resolution and the PDF 72 dpi resolution means that HTML appears larger in print documents than it does on screen.

You will need to apply a scale of 72/96 (0.75) to compensate for this if you want both to appear the same size.

For example, if you are rendering a web page supplying a value of 800 for the Width parameter, you will need to set the width of your Rect to 600 if you want both to appear the same size.

DPI

PDF documents are predominantly vector-based. As such, they do not really have a dpi because they are resolution independent. The only portions of PDFs which are raster based are images.

Most elements of HTML - text, lines - are vector based. So they are resolution-independent.

The resolution at which images in your web pages are rendered is complicated. Suppose you have a 300 square image referenced by an image tag. If the width of your Doc.Rect is the same as the width you pass to AddImageUrl, then this will be rendered at 72 dpi. However, by changing the ratios between these two values, the image will be scaled and hence the resolution will be changed.

And... if your 300 square is in an img tag with a width and height of 150, then the default resolution will be doubled.

Breaks

ABCpdf uses a sophisticated set of heuristics to determine where to break pages. For greater control over page breaking, you can use the page-break-before, page-break-after and page-break-inside CSS styles.

You must ensure that the element to which you apply your page breaking style is visible. For example:

<div style="page-break-before:always">&nbsp;</div>

... will break, but ...

<div style="page-break-before:always"></div>

... will not.

Useful Tip. Debugging page break styles.

Sometimes, your page breaks don't work in they way you think they should. Because these kinds of tags are invisible, it's very difficult for you to know whether you've applied them correctly or not. One simple solution is to debug your HTML using a visible style.

For example, when you apply your "page-break-inside: avoid" style, apply a right border style at the same time. That way, you can see exactly where your elements are. If the borders don't appear in the right places, then you know there's something wrong with your HTML.

Snapshot

You may wish to take a snapshot of the current URL.

In many circumstances, you should be able to derive a URL for the current page using the value of the SERVER_NAME, URL and QUERY_STRING Server Variables. You should be able to derive a URL for the previous page using the HTTP_REFERER (sic) Server Variable.

When you perform this kind of operation, be careful not to recursively call ABCpdf. If you do this, then you will get into a hall-of-mirrors type situation, and the software will not be able to return you a sensible image.


Common Tasks

There are many code examples in the documentation. These cover common tasks like adding text, flowing text and adding images.

Every major object method or property has an accompanying code sample. So if you want to know how to use a method like AddText or AddImageFile, just look at the code sample.

Code samples also cover operations like rendering HTML pages, paged HTML renders, watermarking, appending PDF documents and drawing pages from one PDF document into another.

For in-site examples, you should look at the example web site that comes installed with ABCpdf.


Text Flow Example

This example shows how to flow text from one area to another. The techniques shown here are used to flow text between pages, but they could equally well be applied to flowing text between areas - such as columns - on the same page.

Setup

First, we'll set up some convenient variables including the text we want to display.

theID = 0
thePad = 10
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes..." ' truncated for clarity

Doc Obj

Next, we create an ABCpdf Doc object and give it our basic settings.

We enlarge the line width, increase the font size, enable justification and inset the drawing rectangle from the edges of the document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Width = 4
theDoc.FontSize = 32
theDoc.TextStyle.Justification = 1
theDoc.Rect.Inset 20, 20

Adding

We add our base text to the current page of the document. We then enter a loop, adding pages and chaining HTML boxes together until we run out of text to display.

theDoc.FrameRect
theID = theDoc.AddHtml(theText)
While theDoc.Chainable(theID)
  theDoc.Page = theDoc.AddPage()
  theDoc.FrameRect
  theID = theDoc.AddHtml("", theID)
Wend

Save

After adding all our text, we save the document to a specified location.

theDoc.Save "c:\mypdfs\textflow.pdf"

Results

textflow.pdf [Page 1]

textflow.pdf [Page 2]

textflow.pdf [Page 3]


Multistyle Example

This example shows how to create multistyled text.

Setup

We want to display all our proper names in bold so we enclose them in bold tags.

theText = "<b>Gallia</b> est omnis divisa in partes tres, quarum unam incolunt <b>Belgae</b>, aliam <b>Aquitani</b>, tertiam qui ipsorum lingua <b>Celtae</b>, nostra <b>Galli</b> appellantur."

Doc Obj

Next, we create an ABCpdf Doc object and give it some basic settings. Although we could pass our HTML styled text directly directly to the AddHtml function, we can take more control over the way that fonts are added to the PDF if we specify font IDs.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 72
theDoc.Rect.Inset 10, 10
theDoc.FrameRect
theFont1 = theDoc.EmbedFont("Verdana", "Latin", False, True)
theFont2 = theDoc.EmbedFont("Verdana Bold", "Latin", False, True)

Adding

We replace the bold tags with font tags that directly reference our chosen fonts and then add the HTML styled text to the current rectangle.

theText = "<font pid=" & theFont1 & ">" & theText & "</font>"
theText = Replace(theText, "<b>", "<font pid=" & theFont2 & ">")
theText = Replace(theText, "</b>", "</font>")
theDoc.AddHtml theText

Save

Finally, we save the document to a specified location.

theDoc.Save "c:\mypdfs\styles.pdf"

Results

styles.pdf


Image Example

This example shows how to create a simple PDF displaying an image.

Image

First, we create an ABCpdf Image object and we assign our image file.

Set theImg = Server.CreateObject("ABCpdf14.Image")
theImg.SetFile "c:\mypics\pic.jpg"

Doc

Next, we create an ABCpdf Doc object.

When we add our image, it will be scaled to fit the current rect so it is important that we adjust the rect to reflect the dimensions of our image. Here, we assume a one to one ratio between pixels and points, which will give us a 72 dpi result when printed.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Left = 100
theDoc.Rect.Bottom = 100
theDoc.Rect.Width = theImg.Width
theDoc.Rect.Height = theImg.Height
theDoc.AddImageObject theImg, False
theDoc.Save "c:\mypdfs\image.pdf"

Results

image.pdf


Deletion Example

This example shows how to delete pages from a PDF document.

Setup

First, we create an ABCpdf Doc object and read our source document. We store the number of pages we're going to delete - we're going to delete all but one.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypics\sample.pdf"
theCount = theDoc.PageCount - 1

Delete

We go around a loop deleting the second page each time.

For i = 1 to theCount
  theDoc.PageNumber = 2
  theDoc.Delete theDoc.Page
Next

Save

We add some text to the PDF so that we know how many pages we've deleted. Finally, we save the PDF.

theDoc.FontSize = 500
theDoc.Color = "255 0 0"
theDoc.HPos = 0.5
theDoc.VPos = 0.3
theDoc.AddText theCount
theDoc.Save "c:\mypdfs\deletion.pdf"

Results

deletion.pdf


Headers and Footers Example

This example shows one method of adding headers and footers.

Setup

First, we create an ABCpdf Doc object and define the content we're going to be adding.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes..." ' truncated for clarity

Content

We set up the style for our content.

We need to specify the Rect defining the area in which content will be inserted, a color (red) and a font size.

We add the text using the same method as employed in the Text Flow Example. We draw a frame round our content area each time so we can see how the text has been positioned.

theDoc.Rect = "100 200 500 600"
theDoc.Color = "255 0 0"
theDoc.FontSize = 24
theID = theDoc.AddHtml(theText)
theDoc.FrameRect
While theDoc.Chainable(theID)
  theDoc.Page = theDoc.AddPage()
  theID = theDoc.AddHtml("", theID)
  theDoc.FrameRect
Wend
theCount = theDoc.PageCount

Header

We set up the style for our header.

We need to specify the Rect defining the area in which the header will be inserted, a color (green) and a font size. We use the HPos and VPos parameters to center the text both horizontally and vertically.

We then iterate through the pages in the document adding headers as we go. We frame our headers so we can see the header area.

theDoc.Rect = "100 650 500 750"
theDoc.HPos = 0.5
theDoc.VPos = 0.5
theDoc.Color = "0 255 0"
theDoc.FontSize = 36
For i = 1 To theCount
  theDoc.PageNumber = i
  theDoc.AddText "De Bellum Gallicum"
  theDoc.FrameRect
Next

Footer

We set up the style for our footer.

We need to specify the Rect defining the area in which the footer will be inserted, a color (blue) and a font size. We use the HPos and VPos parameters to center the text vertically and align it to the right.

We then iterate through the pages in the document adding footers as we go. We frame our footers so we can see the footer area.

theDoc.Rect = "100 50 500 150"
theDoc.HPos = 1.0
theDoc.VPos = 0.5
theDoc.Color = "0 0 255"
theDoc.FontSize = 36
theCount = theDoc.PageCount
For i = 1 To theCount
  theDoc.PageNumber = i
  theDoc.AddText "Page " & i & " of " & theCount
  theDoc.FrameRect
Next

Save

Finally, we save the PDF.

theDoc.Save "c:\mypdfs\headerfooter.pdf"
theDoc.Clear

Results
headerfooter.pdf [Page 1] | headerfooter.pdf [Page 2]
headerfooter.pdf [Page 3] | headerfooter.pdf [Page 4]


Landscape Example

This example shows how to create a PDF document rotated by 90 degrees for a landscape rather than portrait view.

Setup

We start by creating a PDF document. We use two transforms to apply a generic 90 degree rotation around the center of the document and rotate the drawing rectangle by the same amount. After applying our rotation, we add some text to the page.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' apply a rotation transform
w = theDoc.MediaBox.Width
h = theDoc.MediaBox.Height
l = theDoc.MediaBox.Left
b = theDoc.MediaBox.Bottom
theDoc.Transform.Rotate 90, l, b
theDoc.Transform.Translate w, 0

' rotate our rectangle
theDoc.Rect.Width = h
theDoc.Rect.Height = w

' add some text
theDoc.Rect.Inset 50, 50
theDoc.FontSize = 96
theDoc.AddText "Landscape Orientation"

Rotate

Drawing the text rotated does not rotate the page itself. To change the default orientation of the document, we need to apply a rotation to the root page object. By doing this, we ensure that every page in the document is viewed rotated.

' adjust the default rotation and save
theID = theDoc.GetInfo(theDoc.Root, "Pages")
theDoc.SetInfo theID, "/Rotate", "90"
theDoc.Save "c:\mypdfs\landscape.pdf"

Results

landscape.pdf


Small Table Example

This example shows how to draw a single page table. ABCpdf does not provide table drawing routines itself so this example uses a Table Class to position the table elements.

Setup

We start by creating our document object and reading the data for our table. For the purposes of this example, we'll assume that our data is in a standard tab delimited format.

'... read the text
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(Server.MapPath("text6.txt"), 1)
theText = f.ReadAll()
Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' set up document
theDoc.FontSize = 16
theDoc.Rect.Inset 20, 20

Rotate

We create a new table object and focus on our document. Focusing tells the table what rectangle it can occupy (it takes the current document rectangle) and how many columns of data it should be prepared for.

Columns are assigned relative widths and expand horizontally to fit the table rectangle. Here, we're specifying five columns and assigning the first column double width. So if our rectangle width is 600, the first column will be 200 wide and the second and subsequent columns will be 100 wide.

Set theTable = New Table
' focus the table on the document
theTable.Focus theDoc, 5
' first column has double width
theTable.Width(0) = 2

Add

We iterate through the table data adding rows and columns as we go. The first column of each row we draw right aligned - the others we draw left aligned. We frame the first and last rows, and we shade alternating rows using a light gray color. Finally, we save the document.

theRows = Split(theText, vbCrLf)
For i = 0 To UBound(theRows)
  ' add in new row
  theTable.NextRow
  theCols = Split(theRows(i), vbTab)
  ' add in columns
  For j = 0 To UBound(theCols)
    ' all but first column right aligned
    theDoc.HPos = 0
    If j > 0 Then theDoc.HPos = 1
    ' add the content to the cell
    theTable.NextCell
    theTable.AddText theCols(j)
  Next
  ' underline first row
  ' underline and overline last row
  ' shade every other row
  theTable.SelectRow theTable.Row
  If i = 0 Then theTable.Frame False, True, False, False
  If i = UBound(theRows) Then theTable.Frame True, True, False, False
  If i Mod 2 = 1 Then theTable.Fill "220 220 220"
Next
theDoc.Flatten
theDoc.Save "c:\mypdfs\table1.pdf"

Results

Using the following input data:

Planet Distance From Sun (miles) Diameter (miles) Year Length (days) Day Length (days)
Mercury 36,000,000 3,030 88 58.00
Venus 67,000,000 7,520 225 225.00
Earth 93,000,000 7,925 365 1.00
Mars 142,000,000 4,210 687 1.00
Jupiter 484,000,000 88,730 4,344 0.40
Saturn 888,000,000 74,975 10,768 0.40
Uranus 1,800,000,000 31,760 30,660 0.70
Neptune 2,800,000,000 30,600 60,150 0.65
Pluto 3,600,000,000 1,410 90,520 0.25

We get the following output.

table1.pdf


Large Table Example

This example shows how to draw a multi-page table. ABCpdf does not provide table drawing routines itself so this example uses a Table Class to position the table elements.

Setup

We start by creating our document object and reading the data for our table. For the purposes of this example, we'll assume that our data is in a standard tab delimited format.

'... read the text
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(Server.MapPath("text7.txt"), 1)
theText = f.ReadAll()
Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' set up document
theDoc.FontSize = 12
theDoc.Rect.Inset 20, 20

Rotate

We create a new table object and focus on our document. Focusing tells the table what rectangle it can occupy (it takes the current document rectangle) and how many columns of data it should be prepared for.

Columns are assigned relative widths and expand horizontally to fit the table rectangle. Here, we're specifying six columns and a number of relative widths. Columns one and four are not assigned a width so they default to a relative width of one. Finally, we're padding the cells so there are gaps between the rows and columns.

Set theTable = New Table
' focus the table on the document
theTable.Focus theDoc, 6
' some columns extra width
theTable.Width(0) = 2
theTable.Width(2) = 3
theTable.Width(3) = 2
theTable.Width(5) = 4
' ensure columns are padded
theTable.Padding = 5

Add

We iterate through the table data adding rows and columns as we go.

Every time we add a row, we check to see whether we've reached the end of the page. When we get there, we check the last row we added to ensure that it wasn't truncated. If it was, then we delete it and prepare to insert it again. We add a new page, prepare to draw the table headers again and reset the row framing and row shading parameters.

We insert all our content into the current row, cell by cell. After we've inserted all our content into the row, we select it and add a frame or background shading as appropriate. Finally, we save the document.

theFrame = True
theShade = False
theRows = Split(theText, vbCrLf)
i = 0
Do
  ' add in new row - see if it fitted onto page
  If theTable.NextRow = False Then
    ' delete and draw last row again?
    If theTable.RowTruncated Then
      theTable.DeleteLastRow
      i = i - 1
    End If
    ' insert headers
    i = i - 1
    If i >= 0 Then theRows(i) = theRows(0)
    ' frame row and reset shading
    theFrame = True
    theShade = False
    ' add new page to table
    theDoc.Flatten
    theTable.NewPage
  End If
  ' get next row
  If i < 0 Or i > UBound(theRows) Then Exit Do
  theRow = theRows(i)
  i = i + 1
  ' add all the cells into a row
  theCols = Split(theRow, vbTab)
  For j = 0 To UBound(theCols)
    theTable.NextCell
    theTable.AddText theCols(j)
  Next
  ' underline first row & shade every other row
  theTable.SelectRow theTable.Row
  If theFrame = True Then theTable.Frame False, True, False, False
  If theShade Then theTable.Fill "200 200 220"
  theFrame = False
  theShade = Not theShade
Loop
theDoc.Flatten
theDoc.Save "c:\mypdfs\table2.pdf"

Results

Using a large quantity of input data, we get the following output.

table2.pdf [Page 1]

table2.pdf [Page 2] | table2.pdf [Page 3]
table2.pdf [Page 4] | table2.pdf [Page 5]


Table Class Example

This page details the Table class, which is used in both the Small Table Example and the Large Table Examples. It can be incorporated into ASP as an include file or compiled as a VB class for faster execution.

Overview

The Table class provides starter code which is designed to be short, simple to understand and simple to extend. You can insert it raw into your projects. However, we would advise modifying it to fit your purposes and adding code that promotes better - but more verbose - programming practices.

The purpose of the table class is to divide up your selection rectangle into rows and cells. When you add a new row, the table class works out the largest rectangle that the row could occupy and allows you to draw cells within that row. As each cell is filled, the table keeps track of the height of the cell content so that, at the end of the row, it can shrink the row vertically to fit the content.

Because each cell extends down to the bottom of the page and the row is only shrunk-to-fit when a new row is added, you should be careful about using properties like Doc.VPos in conjunction with this class.

Code

Class Table ' only needed in ASP

Private mDoc
Private mInitialLayerCount
Private mRect
Private mRectTop
Private mRectLeft
Private mRectWidth
Private mRectHeight
Private mRowTop
Private mRowBottom
Private mHeights()
Private mXPos
Private mYPos
Private mColumns
Private mWidths()
Private mObjects
Private mTruncated
Public RowHeightMin
Public RowHeightMax
Public Padding

' Focus on the document and assign the relevant number of columns
Public Sub Focus(inDoc, inColumns)
  Set mDoc = inDoc
  SetRect mDoc.Rect
  SetColumns inColumns
End Sub

' Add a new page, reset the table rect and move to the first row
Public Sub NewPage()
  mDoc.Page = mDoc.AddPage
  SetRect mRect
  NextRow
End Sub

' Assign a new table rectangle and reset the current table position
Public Sub SetRect(inRect)
  mDoc.Rect = inRect
  mInitialLayerCount = mDoc.LayerCount
  mRect = mDoc.Rect
  mRectTop = mDoc.Rect.Top
  mRectLeft = mDoc.Rect.Left
  mRectWidth = mDoc.Rect.Width
  mRectHeight = mDoc.Rect.Height
  mRowTop = mDoc.Rect.Top
  mRowBottom = mDoc.Rect.Top
  ReDim mHeights(0)
  mYPos = -1
  mXPos = -1
End Sub

' Change the number of columns in the table
Public Sub SetColumns(inNum)
  Dim i
  If inNum > 0 Then
    ReDim Preserve mWidths(inNum - 1)
    For i = (mColumns - 1) To (inNum - 1)
      If i >= 0 Then mWidths(i) = 1
    Next
    mColumns = inNum
  End If
End Sub

' Get the current row - a zero based index
Public Property Get Row()
  Row = mYPos
End Property

' Get the current column - a zero based index
Public Property Get Column()
  Column = mXPos
End Property

' Find out if the last row we added was truncated
Public Property Get RowTruncated()
  RowTruncated = mTruncated
End Property

' Change a column width
Public Property Let Width(i, inWidth)
  If i >= 0 And i <= UBound(mWidths) Then mWidths(i) = inWidth
End Property

' Move to the next column in the current row
Public Sub NextCell()
  mXPos = mXPos + 1
  If mXPos >= mColumns Then mXPos = mColumns - 1
  If mXPos < 0 Then mXPos = 0
  SelectCurrentCell mXPos
End Sub

' Move to the next row - return false if the next row would not fit
Public Function NextRow()
  Dim theBottom
  mRowTop = mRowTop - GetRowHeight(mYPos)
  mDoc.Rect = mRect
  mRowBottom = mRowTop
  mDoc.Rect.Top = mRowTop
  If RowHeightMax > 0 Then
    theBottom = mRowTop - RowHeightMax
    If mDoc.Rect.Bottom < theBottom Then mDoc.Rect.Bottom = theBottom
  End If
  NextRow = (mDoc.Rect.Height > RowHeightMin + (2 * Padding))
  If NextRow Then
    mYPos = mYPos + 1
    mXPos = -1
    mObjects = ""
    mTruncated = False
  End If
End Function

' Add text to the currently selected area
Public Function AddText(inText)
  Dim theRect
  Dim thePos
  theRect = mDoc.Rect
  mDoc.Rect.Inset Padding, Padding
  AddText = AddToRow(mDoc.AddText(inText))
  If mTruncated = False Then
    Dim theDrawn
    theDrawn = mDoc.GetInfo(AddText, "Characters")
    If theDrawn = "" Then theDrawn = 0
    If CInt(theDrawn) < Len(inText) Then
      mTruncated = True
    End If
  End If
  thePos = mDoc.Pos.Y - mDoc.FontSize
  If thePos < mRowBottom Then mRowBottom = thePos
  mDoc.Rect = theRect
End Function

' Select the entire table area
Public Sub SelectTable()
  mDoc.Rect = mRect
End Sub

' Select a cell in the current row using a zero based index
Public Sub SelectCell(inIndex)
  GetRowHeight mYPos ' fix the current row height
  SelectCells inIndex, mYPos, inIndex, mYPos
End Sub

' Select a row on the current page using a zero based index
Public Sub SelectRow(inIndex)
  GetRowHeight mYPos ' fix the current row height
  SelectCells 0, inIndex, mColumns - 1, inIndex
End Sub

' Select a column on the current page using a zero based index
Public Sub SelectColumn(inIndex)
  GetRowHeight mYPos ' fix the current row height
  SelectCells inIndex, 0, inIndex, UBound(mHeights) - 1
End Sub

' Select a rectangular area of cells on the current page
Public Sub SelectCells(inX1, inY1, inX2, inY2)
  Dim theTop, theLeft, theTemp, i
  ' check inputs
  If inX1 > inX2 Then
    theTemp = inX1
    inX1 = inX2
    inX2 = theTemp
  End If
  If inY1 > inY2 Then
    theTemp = inX1
    inY1 = inY2
    inY2 = theTemp
  End If
  GetRowHeight mYPos ' fix the current row height
  If inY1 >= UBound(mHeights) Then inY1 = UBound(mHeights) - 1
  If inY2 >= UBound(mHeights) Then inY2 = UBound(mHeights) - 1
  If inY1 < 0 Then Exit Sub
  ' select the cells
  mDoc.Rect = mRect
  theTop = mDoc.Rect.Top
  SelectCurrentCell inX1
  theLeft = mDoc.Rect.Left
  SelectCurrentCell inX2
  mDoc.Rect.Top = theTop
  mDoc.Rect.Bottom = theTop
  mDoc.Rect.Left = theLeft
  For i = 0 To inY2
    mDoc.Rect.Bottom = mDoc.Rect.Bottom - mHeights(i)
    If inY1 > i Then mDoc.Rect.Top = mDoc.Rect.Top - mHeights(i)
  Next
End Sub

' Draw borders round the current selection
Public Sub Frame(inTop, inBott, inLeft, inRight)
  If inTop Then AddToRow mDoc.AddLine(mDoc.Rect.Left, mDoc.Rect.Top, mDoc.Rect.Right, mDoc.Rect.Top)
  If inBott Then AddToRow mDoc.AddLine(mDoc.Rect.Left, mDoc.Rect.Bottom, mDoc.Rect.Right, mDoc.Rect.Bottom)
  If inLeft Then AddToRow mDoc.AddLine(mDoc.Rect.Left, mDoc.Rect.Top, mDoc.Rect.Left, mDoc.Rect.Bottom)
  If inRight Then AddToRow mDoc.AddLine(mDoc.Rect.Right, mDoc.Rect.Top, mDoc.Rect.Right, mDoc.Rect.Bottom)
End Sub

' Color the background of the current selection
Public Sub Fill(inColor)
  Dim theLayer, theColor
  theLayer = mDoc.Layer
  theColor = mDoc.Color
  mDoc.Layer = mDoc.LayerCount - mInitialLayerCount + 1
  mDoc.Color = inColor
  AddToRow mDoc.FillRect
  mDoc.Color = theColor
  mDoc.Layer = theLayer
End Sub

' Get the current row height based on the cell contents drawn so far
Private Function GetRowHeight(inRow)
  If UBound(mHeights) <= inRow Then
    ' establish and store current row height
    Dim theHeight
    ReDim Preserve mHeights(inRow + 1)
    mRowBottom = mRowBottom - Padding
    If mRowBottom < mRectTop - mRectHeight Then mRowBottom = mRectTop - mRectHeight
    theHeight = mRowTop - mRowBottom
    If inRow > 0 And theHeight < RowHeightMin Then theHeight = RowHeightMin
    If RowHeightMax > 0 And theHeight > RowHeightMax Then theHeight = RowHeightMax
    mHeights(inRow) = theHeight
  End If
  GetRowHeight = 0
  If inRow >= 0 Then GetRowHeight = mHeights(inRow)
End Function

' Select the current cell
Private Sub SelectCurrentCell(inIndex)
  Dim thePos, theWidth, theTotal, i
  If inIndex >= 0 And inIndex < mColumns Then
    ' get the x offset and width of the cell
    For i = 0 To UBound(mWidths)
      theTotal = theTotal + mWidths(i)
      If i < inIndex Then thePos = thePos + mWidths(i)
    Next
    thePos = thePos * (mRectWidth / theTotal)
    theWidth = mWidths(inIndex) * (mRectWidth / theTotal)
    ' position the cell
    mDoc.Rect.Top = mRowTop
    mDoc.Rect.Left = mRectLeft + thePos
    mDoc.Rect.Width = theWidth
  End If
End Sub

' Add to our list of objects drawn as part of the current row
Private Function AddToRow(inID)
  mObjects = mObjects &"," &inID
  AddToRow = inID
End Function

' Delete all the objects drawn as part of the current row
Public Sub DeleteLastRow()
  Dim theArray
  Dim i
  theArray = Split(mObjects, ",")
  For i = 0 To UBound(theArray)
    If theArray(i) <> "" Then mDoc.Delete CInt(theArray(i))
  Next
  mObjects = ""
End Sub

End Class ' only needed in ASP


Unicode Example

This example shows how to add complex scripts such as Chinese, Japanese and Korean. Here, we choose to embed and subset our font to ensure our document renders correctly on all platforms.

Setup

First, we create an ABCpdf Doc object and set the font size.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 32

Read

We read in our Japanese text from a Unicode text file.

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\mypdfs\Japanese2.txt", 1, False, -1)
theText = f.ReadAll

Add

Because we want to ensure that our document renders correctly on all platforms, we're going to embed our font in Unicode format. We specify a left-to-right writing direction, and we choose to subset our font.

Please note when embedding fonts, you must ensure you have permission to embed and redistribute the embedded font as part of your PDF.

theDoc.Page = theDoc.AddPage()
theDoc.Font = theDoc.EmbedFont("MS PGothic", "Unicode", False, True)
theDoc.AddText "Japanese" & theText

Add

Just to show how it works, we'll also render a page in vertical writing mode.

theDoc.Page = theDoc.AddPage()
theDoc.Font = theDoc.EmbedFont("MS PGothic", "Unicode", True, True)
theDoc.AddText "Japanese" & theText

Save

Finally, we save at a specified location.

theDoc.Save "c:\mypdfs\unicode.pdf"

Results

We get the following output.

unicode.pdf [Page 1]
unicode.pdf [Page 2]


Paged HTML Example

This example shows how to import an HTML page into a multi-page PDF document.

Setup

We first create a Doc object and inset the edges a little so that the HTML will appear in the middle of the page.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 72, 144

Page

We add the first page and indicate that we will be adding more pages by telling the Doc object that this is page one. We save the returned ID as this will be used to add subsequent pages.

theDoc.Page = theDoc.AddPage()
theURL = "http://www.yahoo.com/"
theID = theDoc.AddImageUrl(theURL)

Chain

We now chain subsequent pages together. We stop when we reach a page which wasn't truncated.

Do
  theDoc.FrameRect ' add a black border
  If Not theDoc.Chainable(theID) Then Exit Do
  theDoc.Page = theDoc.AddPage()
  theID = theDoc.AddImageToChain(theID)
Loop

Flatten

After adding the pages, we can flatten them. We can't do this until after the pages have been added because flattening will invalidate our previous ID and break the chain.

For i = 1 To theDoc.PageCount
  theDoc.PageNumber = i
  theDoc.Flatten
Next

Save

Finally, we save.

theDoc.Save "c:\mypdfs\pagedhtml.pdf"

Results

We get the following output.

pagedhtml.pdf [Page 1]
pagedhtml.pdf [Page 2]


Doc Properties Example

This example shows how to insert document properties. Document properties can be viewed from Acrobat Reader and most commonly provide information on the document Title and Author.

This example requires some knowledge of the Adobe PDF Specification. Section 9.2.1 of the document details the way in which document properties are stored. Section 3.8.2 of the document details the way that dates are specified within PDF documents.

Src

First, we create an ABCpdf Doc object and add some simple content.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Page = theDoc.AddPage()
theDoc.AddText "My first document..."

Dest

Looking at the Adobe PDF Specification, we can see that the document properties we want to change are referenced from an entry called "/Info" in the document trailer. So our first step is to create a new PDF dictionary and reference it from the this entry.

theID = theDoc.AddObject("<< >>")
theDoc.SetInfo -1, "/Info:Ref", theID

Add

Now, we have to insert our summary information into the object we've just added. Dates are generally specified as strings in the format "D:YYYYMMDD" but for our purposes we'll just include the year.

theDoc.SetInfo theID, "/Title:Text", "ABCpdf"
theDoc.SetInfo theID, "/Author:Text", "WebSupergoo"
theDoc.SetInfo theID, "/Subject:Text", "ABCpdf Documentation"
theDoc.SetInfo theID, "/Keywords:Text", "ABCpdf,PDF,Docs"
theDoc.SetInfo theID, "/Creator:Text", "WebSupergoo"
theDoc.SetInfo theID, "/Producer:Text", "WebSupergoo"
theDoc.SetInfo theID, "/CreationDate:Text", "D:2003"
theDoc.SetInfo theID, "/ModDate:Text", "D:2003"
theDoc.SetInfo theID, "/Trapped:Name", "False"

Save

Finally, we save.

theDoc.Save "c:\mypdfs\docprops.pdf"


eForm Fields Example

This example shows how to change the values of eForm fields. In this example, we simply set the contents of each field in a form with the name of that field.

Src

First, we create an ABCpdf Doc object and read in our template form.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypdfs\form.pdf"

Add

We iterate through each of the top-level fields. For each field, we set the value of the field to be equal to the value of the name.

For Each theField in theDoc.Form.Fields
  theField.Value = theField.Name
Next

Save

Finally, we save.

theDoc.Save "c:\mypdfs\eformfields.pdf"

Results

Given the following document.

form.pdf

This is the kind of output you might expect.

eformfields.pdf


eForm Placeholder Example

This example shows how to use eForm fields as placeholders for the insertion of text. In this example, we simply replace each of the fields in a form with the name of that field.

Src

First, we create an ABCpdf Doc object and read in our template form.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypdfs\form.pdf"
theDoc.Font = theDoc.AddFont("Helvetica-Bold")
theDoc.FontSize = 16
theDoc.Rect.Pin = 1 ' top left

Add

We iterate through each of the fields. For each field, we focus on the field. We then color the rectangle light gray and draw the name of the field in dark red.

For Each theField in theDoc.Form.Fields
  theField.Focus
  theDoc.Color = "240 240 255"
  theDoc.FillRect
  theDoc.Rect.Height = 16
  theDoc.Color = "220 0 0"
  theDoc.AddText theField.Name
  theDoc.Delete theField.ID
Next

Save

Finally, we save.

theDoc.Save "c:\mypdfs\eform.pdf"

Results

Given the following document.

form.pdf

This is the kind of output you might expect.

eform.pdf


eForm Stamp Example

This example shows how to stamp eForm fields into a document so that the values are indelibly marked.

Src

First, we create an ABCpdf Doc object and read in our template form.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypdfs\form.pdf"

Add

We set the values of selected fields, and then we stamp all field values into the document.

theDoc.Form("Day") = "23"
theDoc.Form("Month") = "February"
theDoc.Form("Year") = "2005"
theDoc.Form("State") = "Arizona"
theDoc.Form.Stamp

Save

Finally, we save.

theDoc.Save "c:\mypdfs\eformstamp.pdf"

Results

Given the following document.

form.pdf

This is the kind of output you might expect.

eformstamp.pdf


eForm FDF Example

This example shows how to extract Unicode annotation values from an eForm FDF file.

Src

First, we create an ABCpdf Doc object and read in our FDF file.

Set theFDF = Server.CreateObject("ABCpdf14.Doc")
theFDF.Read "c:\mypdfs\form.fdf"

Dest

We find out how many items there are in the FDF file and prepare to iterate through them.

theValues = ""
theLastID = CInt(theFDF.GetInfo(0, "Count"))

Add

We go through each item. We check to see whether it is an annotation. If it is, we check to see if the annotation type is text. If we have found a text annotation, we extract the content and add the value to our list.

For i = 0 To theLastID
  theType = theFDF.GetInfo(i, "Type")
  If theType = "anno" Then
    If theFDF.GetInfo(i, "SubType") = "Text" Then
      theCont = theFDF.GetInfo(i, "Contents")
      theValues = theValues & theCont & vbCrLf & vbCrLf
    End If
  End If
Next

Save

Finally, we add the Unicode text to a new document and save it.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Font = theDoc.EmbedFont("Arial", "Unicode", False, True)
theDoc.FontSize = 96
theDoc.Rect.Inset 10, 10
theDoc.AddText theValues
theDoc.Save "c:\mypdfs\fdf.pdf"

Results

This is the kind of PDF you might expect to produce.

fdf.pdf


Advanced Graphics Example

Intro

Virtually all the drawing operations you will require are achievable using methods such as FrameRect, FillRect, AddLine and AddArc.

However, occasionally, you may require more sophisticated control over your drawing operations. In these situations, you need direct access to the PDF Content Stream.

Content

Page content is defined by the page Content Stream. The Content Stream is a sequence of descriptions of graphics objects to be placed on the page. ABCpdf allows you to create or modify these content streams allowing you access to the full power of PDF drawing operators.

It was intentionally decided not to encapsulate this type of drawing within an API. Ultimately, all Content Stream creation involves simple string manipulation operations. We felt that by distancing you from the Content Stream, we would be limiting you and offering little in the way of advantage. It is trivial to generate your own Content Stream API if this is what you want.

To insert a content stream, you need to insert a layer using an operation such as FrameRect, FillRect or AddLine and then replace the default content stream with your own. See the examples below for details.

Here, we describe how to perform common tasks. We do not cover the entire range of possible operators and functions. For full details, you should see the Adobe PDF Specification.

Paths

A path object is a shape made up of straight lines, rectangles and Bézier curves. It may intersect itself and may have disconnected sections and holes. After the path has been defined, it may be painted, filled, used for clipping or a combination of these operations.

Each path consists of one or more subpaths. Each subpath consists of one or more connected segments. Subpaths may be open or closed. When a subpath is closed, the start of the path is connected to the end.

All paths are located in the standard Adobe PDF coordinate space. The following is a list of standard path construction operators.

Name | Parameters | Operator | Description
Move | x y | m | Begin a new subpath by moving to the coordinates specified.
Line | x y | l | Add a straight line from the current location to the coordinates specified.
Rect | x y w h | re | Add a rectangular subpath with the lower left corner at (x, y) with width w and height h.
Bézier | x1 y1 x2 y2 x3 y3 | c | Add a Bézier curve from the current location to the coordinates specified (x3, y3) using the other coordinates (x1, y1) and (x2, y2) as control points.
Close | h | Close the current subpath joining the start to the end.
Stroke | S | Paint a line along the current path using the current stroke color.
Fill f

Fill the current path using the current fill color.

This fill method uses the nonzero winding number rule. There are other PDF operators to allow the use of the even-odd rule but these are not generally useful.
Clip W n

Intersect the path with the current clipping path to establish a new clipping path.

This actually comprises two operators rather than one, but they are almost invariably used in this combination.

State

The graphics state defines the parameters within which the PDF operators work. For example, the graphics state defines the current line width, which will be used whenever a line is drawn. It also defines the current non-stroking color, which will be used whenever a path is filled.

You can push copies of the graphics state onto a stack and then restore them later. This can be very useful for doing and undoing graphics state operations.

Name | Parameters | Operator | Description
Save State | q | Push a copy of the current graphics state onto the stack.
Restore State | Q | Restore the current graphics state from the top of the stack.
Line Width | v | w | Set the width to be used when stroking lines.
Set Gray | w | G | Set the gray level to use for stroking operations.The component ranges between 0.0 and 1.0 (black and white respectively).
Set Gray | w | g | The same as G but for non-stroking operations.
Set RGB | r g b | RG | Set the RGB color to use for stroking operations. Each component ranges between 0.0 and 1.0.
Set RGB | r g b | rg | The same as RG but for non-stroking operations.
Set CMYK | c m y k | K | Set the CMYK color to use for stroking operations. Each component ranges between 0.0 and 1.0.
Set CMYK | c m y k | k | The same as K but for non-stroking operations.
Transform a b c d e f cm

Concatenate matrix with the current transform matrix. Common transforms include:

  • Translation: A matrix of the form [1 0 0 1 tx ty] shifts the coordinate system by tx horizontally and ty vertically.
  • Scaling: A matrix of the form [sx 0 0 sy 0 0] scales the coordinate system by a factor of sx horizontally and sy vertically pinned at the origin.
  • Rotation: A matrix of the form [cos(ra) sin(ra) -sin(ra) cos(ra) 0 0] rotates the coordinate system by the angle ra anti-clockwise around the origin.
  • Skew: A matrix of the form [1 tan(ra) tan(ra) 1 0 0] skews the x and y axes by the angle ra.
Line Cap v J

The line cap for the ends of any lines to be stroked. Possible values are:

  1. Butt. The stroke is square at the end of the path and does not project beyond the end of the path.
  2. Round. A semicircle is added at the end of the path projecting beyond the endpoints.
  3. Projecting Square. The stroke is square but projects a distance of half the line width beyond the ends of the path.
Line Join v j

The line join for the shape of joints between connected segments of a path. Possible values are:

  1. Miter. The outer edges for the two segments are extended until they meet. This is the same way that wooden segments are joined to make a picture frame. If the segments meet at an overly steep angle, a bevel join is used, instead. The precise cut-off point is called the Miter Limit (see below).
  2. Round. A pie slice is added to the junction of the two segments to produce a rounded corner.
  3. Bevel. The two segments are finished with butt caps and any notch between the two is filled in.
Miter Limit v M

The maximum length of mitered line joins for paths.

The miter limit is expressed in terms of the ratio of the thickness of the line to the thickness of the join.

For example, a value of 1.5 will allow the width of the line at the join to be up to one and a half times the thickness of the width of an individual line segment.
Line Dash | a p | d | The dash pattern to use for stroked lines. The parameters include a - an array for the pattern and p - the phase of the dash.

Stroke

Paths can be stroked (drawn) using the current stroking color.

For example, you might wish to draw a star.

gr = ""
gr = gr & "q " ' save state
gr = gr & "30 w " ' line width
gr = gr & "2 j " ' line join
gr = gr & "124 158 m " ' move
gr = gr & "300 700 l " ' line
gr = gr & "476 158 l " ' line
gr = gr & "15 493 l " ' line
gr = gr & "585 493 l " ' line
gr = gr & "h " ' close
gr = gr & "S " ' stroke
gr = gr & "Q" ' restore state

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.SetInfo theDoc.FrameRect(), "stream", gr
theDoc.Save "c:\mypdfs\adv_star_draw.pdf"

adv_star_draw.pdf

Fill

Paths can be filled with the current non-stroking color.

For example, you might wish to construct a filled star.

gr = ""
gr = gr & "q " ' save state
gr = gr & "124 158 m " ' move
gr = gr & "300 700 l " ' line
gr = gr & "476 158 l " ' line
gr = gr & "15 493 l " ' line
gr = gr & "585 493 l " ' line
gr = gr & "h " ' close
gr = gr & "f " ' fill
gr = gr & "Q" ' restore state

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.SetInfo theDoc.FrameRect(), "stream", gr
theDoc.Save "c:\mypdfs\adv_star_fill.pdf"

adv_star_fill.pdf

Bézier

Paths can contain curved segments.

Curved segments are specified as cubic Bézier curves. These provide a flexible and practical way to draw curves and curved paths.

Each segment is defined by four points. The first point and the final point define the ends of the segment. The second and third points define the control points. The line is pulled towards the first control point as it leaves the start, and it is pulled towards the second control point as it arrives at the end.

The easiest way to illustrate this is with an example. Note that in this example the Bézier curve takes relatively little code to define. Most of the code is related to illustrating how the control points affect the shape of the curve.

gr = ""
gr = gr & "q " ' save state
gr = gr & "30 w " ' line width
gr = gr & "100 100 m " ' move
gr = gr & "200 700 400 600 500 300 c " ' Bezier
gr = gr & "S " ' stroke
gr = gr & "Q" ' restore state

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' annotate Bezier curve in red
theDoc.Color = "255 0 0"
theDoc.Width = 20
theDoc.FontSize = 30
theDoc.Pos = "100 100"
theDoc.AddText "p0 (current point)"
theDoc.Pos = "200 700"
theDoc.Pos.Y = theDoc.Pos.Y + theDoc.FontSize
theDoc.AddText "p1 (x1, y1)"
theDoc.Pos = "400 600"
theDoc.Pos.Y = theDoc.Pos.Y + theDoc.FontSize
theDoc.AddText "p2 (x2, y2)"
theDoc.Pos = "500 300"
theDoc.Pos.X = theDoc.Pos.X - theDoc.FontSize
theDoc.AddText "p3 (x3, y3)"
theDoc.AddLine 100, 100, 200, 700
theDoc.AddLine 400, 600, 500, 300
' add Bezier curve
theDoc.SetInfo theDoc.FrameRect(), "stream", gr
theDoc.Save "c:\mypdfs\adv_bezier.pdf"

adv_bezier.pdf

Clip

You can use a path to define a clipping area.

The graphics state holds a clipping path that restricts the areas on the page which can be painted on. Marks falling within the clipping area will be displayed, and those falling outside will not.

The default clipping path is the entire page. You can intersect the current clipping path with a new path using the clipping path operators.

You cannot expand a clipping path. Instead, you must save the graphics state before applying your clipping path and then restore the graphics state after you have finished using it.

Here we fill a rectangle clipped by our star shape.

gr = ""
gr = gr & "q " ' save state
gr = gr & "124 158 m " ' move
gr = gr & "300 700 l " ' line
gr = gr & "476 158 l " ' line
gr = gr & "15 493 l " ' line
gr = gr & "585 493 l " ' line
gr = gr & "W n " ' clip
gr = gr & "100 200 400 400 re " ' rect
gr = gr & "f " ' fill
gr = gr & "Q" ' restore state

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.SetInfo theDoc.FrameRect(), "stream", gr
theDoc.Save "c:\mypdfs\adv_star_clip.pdf"

adv_star_clip.pdf

Caps

You can define the way that the end points of your paths are capped.

The following options are available:

Butt. The stroke is square at the end of the path and does not project beyond the end of the path.

Round. A semicircle is added at the end of the path projecting beyond the endpoints.

Projecting Square. The stroke is square but projects a distance of half the line width beyond the ends of the path.

This example shows how different line caps are drawn. Note that the line cap themselves take relatively little code to define. Most of the code is related to annotating the drawing so that you can see how the caps relate to the end points.

gr = ""
gr = gr & "100 w " ' line width
gr = gr & "0 J " ' butt cap
gr = gr & "100 600 m " ' move
gr = gr & "500 600 l " ' line
gr = gr & "S " ' stroke
gr = gr & "1 J " ' round cap
gr = gr & "100 400 m " ' move
gr = gr & "500 400 l " ' line
gr = gr & "S " ' stroke
gr = gr & "2 J " ' square cap
gr = gr & "100 200 m " ' move
gr = gr & "500 200 l " ' line
gr = gr & "S " ' stroke

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' add capped lines
theDoc.SetInfo theDoc.FrameRect(), "stream", gr
' annotate capped lines
theDoc.FontSize = 48
theDoc.Pos = "50 720"
theDoc.AddText "0 - Butt Cap"
theDoc.Pos = "50 520"
theDoc.AddText "1 - Round Cap"
theDoc.Pos = "50 320"
theDoc.AddText "2 - Projecting Square Cap"
theDoc.Width = 20
theDoc.Color = "255 255 255"
theDoc.AddLine 100, 200, 500, 200
theDoc.Rect = "80 180 120 220"
theDoc.FillRect 20, 20
theDoc.Rect = "480 180 520 220"
theDoc.FillRect 20, 20
theDoc.AddLine 100, 400, 500, 400
theDoc.Rect = "80 380 120 420"
theDoc.FillRect 20, 20
theDoc.Rect = "480 380 520 420"
theDoc.FillRect 20, 20
theDoc.AddLine 100, 600, 500, 600
theDoc.Rect = "80 580 120 620"
theDoc.FillRect 20, 20
theDoc.Rect = "480 580 520 620"
theDoc.FillRect 20, 20
theDoc.Save "c:\mypdfs\adv_linecap.pdf"

adv_linecap.pdf

Joins

You can define the way that your line segments are joined.

The following options are available:

Miter. The outer edges for the two segments are extended until they meet. This is the same way that wooden segments are joined to make a picture frame. If the segments meet at an overly steep angle, a bevel join is used, instead. The precise cut-off point is called the Miter Limit.

Round. A pie slice is added to the junction of the two segments to produce a rounded corner.

Bevel. The two segments are finished with butt caps, and any notch between the two is filled in.

This example shows how different line joins are drawn. Note that the line joins themselves take relatively little code to define. Most of the code is related to annotating the drawing.

gr = ""
gr = gr & "50 w " ' line width
gr = gr & "0 j " ' miter join
gr = gr & "300 500 m " ' move
gr = gr & "400 700 l " ' line
gr = gr & "500 500 l " ' line
gr = gr & "S " ' stroke
gr = gr & "1 j " ' round join
gr = gr & "300 300 m " ' move
gr = gr & "400 500 l " ' line
gr = gr & "500 300 l " ' line
gr = gr & "S " ' stroke
gr = gr & "2 j " ' bevel join
gr = gr & "300 100 m " ' move
gr = gr & "400 300 l " ' line
gr = gr & "500 100 l " ' line
gr = gr & "S " ' stroke

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' add capped lines
theDoc.SetInfo theDoc.FrameRect(), "stream", gr
' annotate capped lines
theDoc.FontSize = 48
theDoc.Pos = "50 720"
theDoc.AddText "0 - Miter"
theDoc.Pos = "50 520"
theDoc.AddText "1 - Round "
theDoc.Pos = "50 320"
theDoc.AddText "2 - Bevel"
theDoc.Width = 10
theDoc.Color = "255 255 255"
theDoc.AddLine 300, 500, 400, 700
theDoc.AddLine 400, 700, 500, 500
theDoc.Rect = "390 690 410 710"
theDoc.FillRect 10, 10
theDoc.AddLine 300, 300, 400, 500
theDoc.AddLine 400, 500, 500, 300
theDoc.Rect = "390 490 410 510"
theDoc.FillRect 10, 10
theDoc.AddLine 300, 100, 400, 300
theDoc.AddLine 400, 300, 500, 100
theDoc.Rect = "390 290 410 310"
theDoc.FillRect 10, 10
theDoc.Save "c:\mypdfs\adv_linejoin.pdf"

adv_linejoin.pdf

Dash

You can define dashed lines.

The dash pattern is specified by a dash array and a dash phase. The dash array specifies the length of dashes and gaps. The dash phase specifies the distance into the array at which the line dashes should start.

When the lengths in the array are exhausted, the dash pattern starts again at the beginning. You can use an empty array and zero phase to specify a solid line

Dashed lines can be applied to any kind of path including straight lines and curves. Each subpath in a path is treated separately - the dash phase starts at the beginning again.

This example shows how different line dash patterns are drawn.

gr = ""
gr = gr & "q " ' save state
gr = gr & "20 w " ' line width
gr = gr & "[ ] 0 d " ' dash pattern
gr = gr & "100 700 m " ' move
gr = gr & "500 700 l " ' line
gr = gr & "S " ' stroke
gr = gr & "[ 90 ] 0 d " ' dash pattern
gr = gr & "100 500 m " ' move
gr = gr & "500 500 l " ' line
gr = gr & "S " ' stroke
gr = gr & "[ 60 ] 30 d " ' dash pattern
gr = gr & "100 300 m " ' move
gr = gr & "500 300 l " ' line
gr = gr & "S " ' stroke
gr = gr & "[ 60 30 ] 0 d " ' dash pattern
gr = gr & "100 100 m " ' move
gr = gr & "500 100 l " ' line
gr = gr & "S " ' stroke
gr = gr & "Q" ' restore state

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' annotate dashed lines
theDoc.FontSize = 36
theDoc.Pos = "50 760"
theDoc.AddText "[ ] 0 - no dashes"
theDoc.Pos = "50 560"
theDoc.AddText "[ 90 ] 0 - 90 on, 90 off..."
theDoc.Pos = "50 360"
theDoc.AddText "[ 60 ] 30 - 30 on, 60 off, 60 on..."
theDoc.Pos = "50 160"
theDoc.AddText "[ 60 30 ] 0 - 60 on, 30 off, 60 on..."
' add dashed lines
theDoc.SetInfo theDoc.FrameRect(), "stream", gr
theDoc.Save "c:\mypdfs\adv_dashes.pdf"

adv_dashes.pdf

XForms

You can define transforms which affect the world space.

A transform allows you to translate, scale, rotate, or skew objects. Multiple transforms can be concatenated so that you can perform a combination of these operations.

A transform is defined by six numbers. Common transforms include:

Translation: A matrix of the form [1 0 0 1 tx ty] shifts the coordinate system by tx horizontally and ty vertically.

Scaling: A matrix of the form [sx 0 0 sy 0 0] scales the coordinate system by a factor of sx horizontally and sy vertically pinned at the origin.

Rotation: A matrix of the form [cos(ra) sin(ra) -sin(ra) cos(ra) 0 0] rotates the coordinate system by the angle ra anticlockwise around the origin.

Skew: A matrix of the form [1 tan(ra) tan(ra) 1 0 0] skews the x and y axes by the angle ra.

This example shows how to apply a 45 degree rotation to a drawing of a star.

star = ""
star = star & "124 158 m " ' move
star = star & "300 700 l " ' line
star = star & "476 158 l " ' line
star = star & "15 493 l " ' line
star = star & "585 493 l " ' line
star = star & "h " ' close
star = star & "S " ' stroke
gr = ""
gr = gr & "q " ' save state
gr = gr & "30 w " ' line width
gr = gr & "2 j " ' line join
gr = gr & star ' add star
gr = gr & "1 0 0 RG " ' set color red
gr = gr & "0.7 0.7 -0.7 0.7 0 0 cm " ' rotate 45 degrees
gr = gr & star ' add star
gr = gr & "Q" ' restore state

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.SetInfo theDoc.FrameRect(), "stream", gr
theDoc.Save "c:\mypdfs\adv_star_rotate.pdf"

adv_star_rotate.pdf


PDF Rendering Example

This example shows how to render a PDF document.

Read

We create an ABCpdf Doc object and read our source PDF.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypdfs\spaceshuttle.pdf"

Prefs

We specify our base rendering settings.

theDoc.Rendering.DotsPerInch = 36

Save

Finally, we save the first four pages of the document in png format.

For i = 1 To 4
  theDoc.PageNumber = i
  theDoc.Rect = theDoc.CropBox
  theDoc.Rendering.Save "c:\mypdfs\shuttle_p" & i & ".png"
Next

Results

shuttle_p1.gif

shuttle_p2.png

shuttle_p3.png

shuttle_p4.png


ComFactory Object

Allows the creation of objects in the same application domain. The methods of this class do nothing more than creating objects so all methods are thread-safe. The ComFactory object can be obtained from the ComFactory property of every other classes.

If ABCpdf is installed as a COM+ application and the COM+ application pool is configured to have a pooling size greater than one, objects created with CreateObject may not be in the same application domain, depending on which application(s) in the application pool is/are chosen to execute the calls to CreateObject. When an object is passed as a parameter to a method, it must be in the same application domain as the invoked object for the invoked object to access the content of the parameter.

In such cases, use the same ComFactory object or the ComFactory object from the ComFactory property of an existing object to ensure that newly created objects are in the same application domain.

Method | Description
CreateDoc | Creates a Doc object.
CreateImage | Creates an Image object.
CreateXColor | Creates an XColor object.
CreateXPoint | Creates an XPoint object.
CreateXRect | Creates an XRect object.
CreateXSaveTemplateData | Creates an XSaveTemplateData object.
CreateXSettings | Creates an XSettings object.
CreateXTextStyle | Creates an XTextStyle object.
CreateXTransform | Creates an XTransform object.

Property | Default | Description
none |


CreateDoc Function

Creates a Doc object.

Syntax

Set Doc = ComFactory.CreateDoc()

Params
Name | Type | Description
Doc | Doc | The newly created Doc object.

Notes

Use this method to create a Doc object in the application domain of the ComFactory object.

Example

None.


CreateImage Function

Creates an Image object.

Syntax

Set Image = ComFactory.CreateImage()

Params
Name | Type | Description
Image | XImage | The newly created Image object.

Notes

Use this method to create an Image object in the application domain of the ComFactory object.

Example

None.


CreateXColor Function

Creates an XColor object.

Syntax

Set XColor = ComFactory.CreateXColor()

Params
Name | Type | Description
XColor | XColor | The newly created XColor object.

Notes

Use this method to create an XColor object in the application domain of the ComFactory object.

Example

None.


CreateXPoint Function

Creates an XPoint object.

Syntax

Set XPoint = ComFactory.CreateXPoint()

Params
Name | Type | Description
XPoint | XPoint | The newly created XPoint object.

Notes

Use this method to create an XPoint object in the application domain of the ComFactory object.

Example

None.


CreateXRect Function

Creates an XRect object.

Syntax

Set XRect = ComFactory.CreateXRect()

Params
Name | Type | Description
XRect | XRect | The newly created XRect object.

Notes

Use this method to create an XRect object in the application domain of the ComFactory object.

Example

None.


CreateXSaveTemplateData Function

Creates an XSaveTemplateData object.

Syntax

Set XSaveTemplateData = ComFactory.CreateXSaveTemplateData()

Params
Name | Type | Description
XSaveTemplateData | XSaveTemplateData | The newly created XSaveTemplateData object.

Notes

Use this method to create an XSaveTemplateData object in the application domain of the ComFactory object.

Example

None.


CreateXSettings Function

Creates an XSettings object.

Syntax

Set XSettings = ComFactory.CreateXSettings()

Params
Name | Type | Description
XSettings | XSettings | The newly created XSettings object.

Notes

Use this method to create an XSettings object in the application domain of the ComFactory object.

Example

None.


CreateXTextStyle Function

Creates an XTextStyle object.

Syntax

Set XTextStyle = ComFactory.CreateXTextStyle()

Params
Name | Type | Description
XTextStyle | XTextStyle | The newly created XTextStyle object.

Notes

Use this method to create an XTextStyle object in the application domain of the ComFactory object.

Example

None.


CreateXTransform Function

Creates an XTransform object.

Syntax

Set XTransform = ComFactory.CreateXTransform()

Params
Name | Type | Description
XTransform | XTransform | The newly created XTransform object.

Notes

Use this method to create an XTransform object in the application domain of the ComFactory object.

Example

None.


Doc Object

This is the top-level object that represents a PDF document.

Method | Description
AddArc | Adds an arc to the current page.
AddBookmark | Adds a bookmark pointing to the current page.
AddColorSpaceFile | Adds an ICC-based color space to the document..
AddColorSpaceSpot | Adds a separation color space to the document.
AddFont | Adds a font reference to the document.
AddGrid | Adds a visible grid to the current page.
AddHtml | Adds a block of HTML styled text to the current page
AddImage | Adds an image to the current page.
AddImageCopy | Adds a copy of an existing image to the current page.
AddImageData | Extracts an image from a chunk of data and adds it to the current page.
AddImageDoc | Draws a page from one PDF document onto the current page of this document.
AddImageFile | Extracts an image from a file and adds it to the current page.
AddImageHtml | Renders a web page specified as HTML.
AddImageObject | Gets an image from an Image object and adds it to the current page.
AddImageToChain | Adds a new page from a paged HTML or PostScript render.
AddImageUrl | Renders a web page specified by URL.
AddLine | Adds a line to the current page.
AddObject | Adds a native PDF object to the document.
AddOval | Adds an oval to the current page.
AddPage | Adds a page to the current document.
AddPie | Adds a pie slice to the current page.
AddPoly | Adds a polygon to the current page.
AddText | Adds a block of text to the current page.
Append | Appends a PDF to the end of the document.
Chainable | Determines whether an object is chainable.
Clear | Clears the document.
Delete | Deletes an object previously added to the document.
EmbedFont | Embeds a font into the document.
FillRect | Adds a painted rectangle to the current page.
Flatten | Flattens and compresses the current page.
FrameRect | Adds a rectangular frame to the current page.
GetData | Saves a document to memory.
GetInfo | Gets information about an object.
GetText | Extracts content from the current page in a specified format.
Read | Reads an existing PDF.
RemapPages | Remaps pages for reordering, copying and deletion.
Save | Saves the document as PDF.
SetInfo | Sets information about an object.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
Bookmark | No | The top-level bookmark for the document.
Color | No | The color used for drawing.
ColorSpace | No | The current color space.
CropBox | No | The current document visible page size.
Encryption | No | The current encryption settings.
Font | No | The font used for drawing text.
Form | No | The document eForm.
FontSize | No | The line height for drawing text.
HPos | No | The horizontal positioning of text.
HtmlOptions | No | The HTML and URL rendering options and control.
Layer | No | The insertion position for new content.
LayerCount | No | The number of layers on the current page.
License | No | The current installed license.
MediaBox | No | The default size for new pages.
Options | No | The current state options.
Page | No | The current page for drawing operations.
PageCount | No | The number of pages in the document.
PageNumber | No | The page number of the current page.
Pos | No | The current position for drawing operations.
Rect | No | The current area for drawing operations.
Rendering | No | The rendering options and control.
Root | No | The root catalog object.
SaveOptions | No | The save options and control.
TextStyle | No | The current style for text drawing.
TopDown | No | The gradient of the vertical coordinate.
Transform | No | The current transformation for drawing.
Units | No | The current measurement units.
VPos | No | The vertical positioning of text.
Width | No | The current line width for drawing operations.

Event | Description
HtmlRender | An event sent out during html rendering.


AddArc Method

Adds an arc to the current page.

Syntax

GraphicID = Doc.AddArc(AngleStart, AngleEnd, CenterX, CenterY, RadiusX, RadiusY [, Filled])

Params
Name | Type | Description
AngleStart | Double | The start angle of the arc in degrees.
AngleEnd | Double | The end angle of the arc in degrees.
CenterX | Double | The horizontal coordinate of the center of the arc.
CenterY | Double | The vertical coordinate of the center of the arc.
RadiusX | Double | The horizontal radius of the arc.
RadiusY | Double | The vertical radius of the arc.
Filled | Boolean | Whether to fill the arc rather than simply drawing it (optional).
GraphicID | Long | The Object ID of the newly added Graphic object.

Notes

Adds an arc to the current page. The arc is drawn in the current color at the current width and with the current options.

The arc is positioned at the center coordinates and can have distinct horizontal and vertical radii. Drawing starts at the start angle, and the arc is swept out until the end angle is reached. Angles are measured anti-clockwise with zero at three o'clock.

The AddArc method returns the Object ID of the newly added Graphic object.

Example

The following code adds an arc to a document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Width = 24
theDoc.Color = "120 0 0"
theDoc.AddArc 0, 270, 300, 400, 200, 300
theDoc.Save "c:\mypdfs\docaddarc.pdf"

docaddarc.pdf


AddBookmark Method

Adds a bookmark pointing to the current page.

Syntax

BookmarkID = Doc.AddBookmark(Path, Open)

Params
Name | Type | Description
Path | String | The path to the bookmark.
Open | Boolean | Whether the bookmark should be displayed open (expanded) or closed (collapsed).
BookmarkID | Long | The Object ID of the newly added Bookmark object.

Notes

Adds a bookmark which points to the current page.

Bookmarks are specified as paths in much the same way as file paths. Headings and subheadings are separated by a backslash character. For example:

"1. Introduction\1.1 Aim and Methods\1.1.3 Diagrams"

When a bookmark is added, intermediate headings and subheadings will be created if they do not already exist.

To add multiple bookmarks all referring to the same page, simply call the AddBookmark method multiple times.

This method returns the Object ID of the newly added Bookmark object.

Example

The following code adds a sequence of pages with a nested sequence of bookmarks. The image shows the appearance of the document outline. Note that none of the subject pages is visible because the chapter pages have been added in the collapsed state.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 64
For i = 1 To 3
  theDoc.Page = theDoc.AddPage()
  theSection = i & " Section"
  theDoc.AddText theSection
  theDoc.AddBookmark theSection, True
  For j = 1 To 5
    theDoc.Page = theDoc.AddPage()
    theChapter = theSection & "\" & j & " Chapter"
    theDoc.AddText theChapter
    theDoc.AddBookmark theChapter, False
    For k = 1 To 6
      theDoc.Page = theDoc.AddPage()
      theSubject = theChapter & "\" & k & " Subject"
      theDoc.AddText theSubject
      theDoc.AddBookmark theSubject, True
    Next
  Next
Next
theDoc.Save "c:\mypdfs\docaddbookmark.pdf"

docaddbookmark.pdf


AddColorSpaceFile Method

Adds an ICC-based color space to the document.

Syntax

ColorSpaceID = Doc.AddColorSpaceFile(Path)

Params
Name | Type | Description
Path | String | The path to the ICC color space file.
ColorSpaceID | Long | The Object ID of the newly added ColorSpace object.

Notes

Adds an ICC-based color space to the document returning the ID of the newly added object.

ICC Color Spaces allow the precise representation of colors in a device independent way. The ICC format is defined by the International Color Consortium (http://www.color.org/).

ABCpdf will allow you to add ICC profiles in the Gray, RGB, CMYK or Lab color spaces. This method will throw an error if the file is inaccessible or invalid.

The current color space is defined by the ColorSpace property. The current color is defined by the Color property. The ColorSpace is used when the Color is of a matching type. If the color type does not match, then the default - device - color space is used.

For example, you add a CMYK color space and assign it to the ColorSpace property. All CMYK Colors you use will be defined in terms of this color space. However, RGB and Grayscale colors will continue to be defined in terms of the default - device - color spaces.

Example

In this example we add some CMYK text defined in an ICC-based color space.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur."
theDoc.Rect.Inset 20, 40
theDoc.FontSize = 96
theDoc.ColorSpace = theDoc.AddColorSpaceFile("c:\mypics\cmyk.icc")
theDoc.Color = "200 20 20 20"
theDoc.AddText theText
theDoc.Save "c:\mypdfs\docaddcolorspacefile.pdf"

docaddcolorspacefile.pdf


AddColorSpaceSpot Method

Adds a separation color space to the document.

Syntax

ColorSpaceID = Doc.AddColorSpaceSpot(Name, Color)

Params
Name | Type | Description
Name | String | The name of the color.
Color | String | The display representation of the color. This should be supplied in the same format as the XColor.String uses.
ColorSpaceID | Long | The Object ID of the newly added ColorSpace object.

Notes

Adds a separation color space to the document returning the ID of the newly added object.

Separation color spaces allow you to add spot colors or isolate the use of individual colorants. A separation color space represents a particular colorant and allows you to specify the amount of that colorant that is applied.

For example, you might define a separation color space called Gold with a display representation of CMYK yellow. You might then draw some text with different amounts of Gold. When viewing the output on a standard monitor, the display representation of the color would be used. However, when printed - using appropriate software and an appropriate printer - the name of the color might be used to select a gold colored ink.

The current color space is defined by the ColorSpace property. The current color is defined by the Color property. Because separations represent a scalar property, you should use single-component - grayscale - colors to specify the amount of spot colorant to use.

There are two special color spaces:

'All' refers collectively to all colorants on an output device. It can be useful for printing registration marks.

'None' indicates no colorant and will never produce any visible output.

Example

In this example, we define a colorant called Gold and add some text using varying amounts of our colorant.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 20,20
theDoc.FontSize = 300
theDoc.ColorSpace = theDoc.AddColorSpaceSpot("GOLD", "0 0 100 0")
For i = 1 To 10
  theDoc.Color.Gray = 255 / i
  theDoc.AddText theDoc.Color.Gray
  theDoc.Rect.Move 25, -50
Next
theDoc.Save "c:\mypdfs\docaddcolorspacespot.pdf"

docaddcolorspacespot.pdf


AddFont Method

Adds a font reference to the document.

Syntax

FontID = Doc.AddFont(FontName [,Language[, Vertical]])

Params
Name | Type | Description
FontName | String | The name of the font typeface.
Language | String | The language type to use (optional). See the Fonts and Languages section for details on language types. The default language type is Latin.
Vertical | Boolean | Whether the text direction should be vertical (optional). See the Fonts and Languages section for details on writing directions. The default is false to indicate standard left-to-right layout.
FontID | Long | The Object ID of the newly added Font object.

Notes

Adds a font to the document.

The font name and a description of the font style are held within the document. However, the actual font itself is not added to the document. If you wish to embed a font, you should use the EmbedFont method.

When a client opens the PDF, Acrobat will attempt to find the exact same font on the client system. If the exact font is not available, then a substitute font will be chosen using the font description to determine the best match.

The following fonts are guaranteed to be available on every system.

  • Times-Roman
  • Times-Bold
  • Times-Italic
  • Times-BoldItalic
  • Helvetica
  • Helvetica-Bold
  • Helvetica-Oblique
  • Helvetica-BoldOblique
  • Courier
  • Courier-Bold
  • Courier-Oblique
  • Courier-BoldOblique
  • Symbol
  • ZapfDingbats

Additionally, you can add any TrueType, OpenType or Type 1 font that you have installed on your system. The name you should use is the one referenced in your fonts folder. For example.

  • Arial
  • Arial Black
  • Arial Black Italic
  • ...
  • Book Antiqua
  • Book Antiqua Bold
  • Book Antiqua Bold Italic
  • Book Antiqua Italic
  • ...
  • Venetian301BT
  • Venetian301BT Bold
  • ...

The AddFont method returns the Object ID of the newly added Font object. Typically, you will want to assign this return value to the document Font property using code of the form.

theDoc.Font = theDoc.AddFont("Courier")

If the specified font could not be found, then you will get an Object ID of zero returned. You may wish to check for this possibility. Otherwise, a default font will be used.

Fonts are cached so newly added fonts will not be available to ABCpdf until the application is restarted. If you need to dynamically load a font, you can pass this method a path to your font file. This will add the font to the cache and make it available for use. You should not move, rename or delete a font file which has been dynamically loaded using this technique.

Example

The following code adds two pieces of text to a document. The first piece is in Times-Roman, and the second in Helvetica-Bold.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 48
theFont = "Times-Roman "
theDoc.Font = theDoc.AddFont(theFont)
theDoc.AddText theFont
theFont = "Helvetica-Bold"
theDoc.Font = theDoc.AddFont(theFont)
theDoc.AddText theFont
theDoc.Save "c:\mypdfs\docaddfont.pdf"

docaddfont.pdf


AddGrid Method

Adds a visible grid to the current page.

Syntax

GridID = Doc.AddGrid()

Params
Name | Type | Description
GridID | Long | The Object ID of the newly added Grid object.

Notes

Adds a visible grid to the current page. The grid shows locations on the page and the effect of the current transform. It is designed to help with object positioning during development.

Example

The following code modifies the page transform and then adds a grid to show how the transform has affected the page.

Set theDoc = CreateObject("ABCpdf14.Doc")
theDoc.Page = theDoc.AddPage
theDoc.Transform.Rotate 20, 100, 100
theDoc.AddGrid
theDoc.Save "c:\mypdfs\docaddgrid.pdf"

docaddgrid.pdf


AddHtml Method

Adds a block of HTML styled text to the current page.

Syntax

TextID = Doc.AddHtml(Text [, ChainID])

Params
Name | Type | Description
Text | String | The HTML to be added to the page.
ChainID | Long | The Object ID of a previously added text block. If this parameter is supplied, then the contents of the Text parameter are ignored.
TextID | Long | The Object ID of the newly added Text object.

Notes

Adds a block of HTML styled text to the current page.

This method works in a manner similar to the AddText method, but it allows you to add multi-styled text by inserting simple HTML tags. A listing of supported tags is given in the HTML Styled Text section of the documentation.

You can chain together multiple HTML blocks so that text flows from one to the next. To do this, you need to first add a block of HTML. Then add multiple new HTML blocks each time passing in the ID obtained from the previous call.

When no more text is available, the AddHtml method will return zero. Alternatively, you can query the Truncated property of the Text object before adding a new item to the chain.

This method returns the Object ID of the newly added Text object. If no text could be added, then zero is returned. This will happen if a zero length string was supplied or if the rectangle was too small for even one character to be displayed.

Typically, you will get a return value of zero if your text was too large to fit in your Rect or if the Pos was at the end of the Rect.

Text styles for the entire HTML content are determined at the point at which the first item in a text chain is created. This means that varying document styles will not affect the way in which subsequent items in the chain are displayed.

For an example of chaining, see the Text Flow Example.

Note that there is no requirement that blocks be organized in a linear chain. That means that you can use the same ID as the ChainID parameter to multiple calls to this method. If you wish, you can create trees of HTML blocks, flowing text from a chain head through multiple display areas on your document.

Example

The following code adds some HTML styled text to a document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 72
theDoc.AddHtml "<b>Gallia</b> est omnis divisa in partes tres, quarum unam incolunt <b>Belgae</b>, aliam <b>Aquitani</b>, tertiam qui ipsorum lingua <b>Celtae</b>, nostra <b>Galli</b> appellantur."
theDoc.Save "c:\mypdfs\docaddhtml.pdf"

docAddHtml.pdf


AddImage Method

Adds an image to the current page.

Syntax

ImageID = Doc.AddImage(ImageSpec [, Frame [, SrcRect]])

Params
Name | Type | Description
ImageSpec | Object | The image to be added to the page.
Frame | Long | Some image formats support multiple frames or pages. You can specify the frame you want added using this optional argument. The default is one to indicate the first frame.
SrcRect | String | Some image formats support source rectangles. You can specify the portion of the image you want drawn using this optional argument. The default value is the rectangle encompassing the entire image.
ImageID | Long | The ID of the newly added Image object.

Notes

Adds an image to the current page returning the ID of the newly added object.

This method attempts to make a sensible decision as to which of the following methods to call dependent on the content of the ImageSpec.

  • AddImageFile
  • AddImageData
  • AddImageCopy
  • AddImageUrl
  • AddImageHtml
  • AddImageToChain
  • AddImageDoc
  • AddImageObject

This method is provided for backward compatibility. You should call the appropriate method directly rather than working via this method.

Example

None.


AddImageCopy Method

Adds a copy of an existing image to the current page.

Syntax

ImageID = Doc.AddImageCopy(ID)

Params
Name | Type | Description
ID | Long | The ID of an existing Image object.
ImageID | Long | The ID of the newly added Image object.

Notes

Adds a copy of an image which has already been inserted elsewhere in the document.

You can use this facility to add commonly used graphics such as watermarks. The raw image data is inserted only once, which means that PDF size is greatly reduced.

This method only works with raster or bitmap images. So your ID must have been obtained from a previous call to AddImageFile, AddImageData or AddImageObject.

The image is scaled to fill the current Rect. It is transformed using the current Transform.

If the width or height of the current rectangle is zero, the image is auto-sized. If you are working in TopDown mode, the image is positioned with its top left pinned at the location indicated by the rectangle. If you are not in TopDown mode, the bottom left of the image is pinned at the location indicated by the rectangle. In both cases, the natural dimensions of the supplied image are used to determine the displayed width and height resulting in a 72-dpi output.

Example

This example shows how to read an existing PDF document and insert a background image into every page.

We start by reading our template PDF document and finding out core information we will need to reference each page.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypics\sample.pdf"
theCount = theDoc.PageCount

We cycle through the pages inserting images as we go.

We set the layer property to ensure that the image gets added in the background rather than on top of existing content.

The first time, we add an image file. Subsequent times, we reference the image ID. This means that we embed only one copy of the image data and simply reference that data from each page.

Finally, we save the modified PDF.

For i = 1 To theCount
  theDoc.PageNumber = i
  theDoc.Layer = theDoc.LayerCount + 1
  If i = 1 Then
    theID = theDoc.AddImageFile("c:\mypics\light.jpg", 1)
  Else
    theDoc.AddImageCopy theID
  End If
Next
theDoc.Save "c:\mypdfs\watermark.pdf"

Given the following document.

sample.pdf [Page 1] | sample.pdf [Page 2]
sample.pdf [Page 3] | sample.pdf [Page 4]

And the following image.

This is the kind of output you might expect.

watermark.pdf [Page 1] | watermark.pdf [Page 2]
watermark.pdf [Page 3] | watermark.pdf [Page 4]


AddImageData Method

Extracts an image from a chunk of data and adds it to the current page.

Syntax

ImageID = Doc.AddImageData(Data, Frame)

Params
Name | Type | Description
Data | Array of Bytes | The data containing the image in a format such as JPEG or TIFF.
Frame | Long | Some image formats support multiple frames or pages. The first frame is frame one.
ImageID | Long | The ID of the newly added Image object.

Notes

Extracts an image from a chunk of data and adds it to the current page returning the ID of the newly added object.

This method is essentially the same as AddImageFile, but it allows you to add images specified as raw data rather than as a file path.

Example

None.


AddImageDoc Method

Draws a page from one PDF document onto the current page of this document.

Syntax

ID = Doc.AddImageDoc(Source, Page , SrcRect)

Params
Name | Type | Description
Source | Doc | The source document.
Page | Long | The page number of the source page you want drawn. Use one to indicate the first page.
SrcRect String

The portion of the page you want drawn. Use an empty string to specify the rectangle encompassing the entire page.

The format of this string should be the same as that obtained via the XRect.String property.
ID | Long | The ID of an implementation-dependent object.

Notes

Draws a page from one PDF document onto the current page of this document.

The page is scaled to fill the current Rect. It is transformed using the current Transform.

If the width or height of the current rectangle is zero, the image is auto-sized. If you are working in TopDown mode, the image is positioned with its top left pinned at the location indicated by the rectangle. If you are not in TopDown mode, the bottom left of the image is pinned at the location indicated by the rectangle. In both cases, the natural dimensions of the supplied image are used to determine the displayed width and height resulting in a 72-dpi output.

Example

This example shows how to draw one PDF into another. It takes a PDF document and creates a 'four-up' summary document by drawing four pages on each page of the new document.

First, we create an ABCpdf Doc object and read in our source document.

Set theSrc = Server.CreateObject("ABCpdf14.Doc")
theSrc.Read "c:\mypdfs\spaceshuttle.pdf"
theCount = theSrc.PageCount

Next, we create a destination Doc object and set the MediaBox so that the page size will match that of the source document. We change the rect so that it occupies a quarter of the page with room to accommodate a small margin.

Set theDst = CreateObject("ABCpdf14.Doc")
theDst.MediaBox = theSrc.MediaBox
theDst.Rect = theDst.MediaBox
theDst.Rect.Magnify 0.5, 0.5
theDst.Rect.Inset 10, 10
theX = theDst.MediaBox.Width / 2
theY = theDst.MediaBox.Height / 2

We go through every page in the source document drawing a framed copy of each page at a different position on our four-up document. After every fourth page, we add a new page into our destination document.

For i = 1 To theCount
  theItem = i Mod 4
  If theItem = 1 Then
    theDst.Page = theDst.AddPage()
    theDst.Rect.Position 10, theY + 10
  ElseIf theItem = 2 Then
    theDst.Rect.Position theX + 10, theY + 10
  ElseIf theItem = 3 Then
    theDst.Rect.Position 10, 10
  ElseIf theItem = 0 Then
    theDst.Rect.Position theX + 10, 10
  End If
  theDst.AddImageDoc theSrc, i, ""
  theDst.FrameRect
Next

Finally, we save.

theDst.Save "c:\mypdfs\fourup.pdf"

We get the following output.

fourup.pdf [Page 1]
fourup.pdf [Page 2]


AddImageFile Method

Extracts an image from a file and adds it to the current page.

Syntax

ImageID = Doc.AddImageFile(Path, Frame)

Params
Name | Type | Description
Path | String | The path to the image file.
Frame | Long | Some image formats support multiple frames or pages. The first frame is frame one.
ImageID | Long | The Object ID of the newly added Image object.

Notes

Adds an image to the current page returning the ID of the newly added object.

Images embedded using this method are always inserted using pass-through mode. Pass-through mode is faster than indirect mode. It allows the preservation of compression settings, native color spaces and ICC color profiles. It allows vector graphics to be maintained in vector format. However, it supports a limited range of image formats - JPEG, JPEG 2000, TIFF, EMF, WMF, PS (PostScript) or EPS (Encapsulated PostScript).

Note that not all EMF or WMF files can be represented in terms of PDF vectors. If this is the case, you should look at using the Image object to convert these objects prior to embedding.

The image is scaled to fill the current Rect. It is transformed using the current Transform.

If the width or height of the current rectangle is zero, the image is auto-sized. If you are working in TopDown mode, the image is positioned with its top left pinned at the location indicated by the rectangle. If you are not in TopDown mode, the bottom left of the image is pinned at the location indicated by the rectangle. In both cases, the natural dimensions of the supplied image are used to determine the displayed width and height resulting in a 72-dpi output.

Transparency. Occasionally, you may find that you need to invert the transparency of your image. To do this, you can assign a decode array using the ID returned from this method.

To invert the transparency:

theDoc.SetInfo theDoc.GetInfo(theID, "XObject"), "/SMask*/Decode", "[1 0]"

A similar technique can be used for inverting or altering color levels on the image itself.

To invert an RGB image:

theDoc.SetInfo theDoc.GetInfo(theID, "XObject"), "/Decode", "[1 0 1 0 1 0]"

Example

The following code adds an image to the current page positioned at the bottom left. The width and height of the image are automatically inferred from the file supplied.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect = "0 0 0 0"
theDoc.AddImageFile "c:\mypics\mypic.jpg", 1
theDoc.Save "c:\mypdfs\docaddimage.pdf"

docaddimage.pdf


AddImageHtml Method

Renders a web page specified as HTML.

Syntax

ImageID = Doc.AddImageHtml(Html [, Paged[, Width[, DisableCache]]])

Params
Name | Type | Description
Html | String | The HTML to be rendered.
Paged | Boolean | Allows you to override the default XHtmlOptions.Paged property (optional).
Width | Long | Allows you to override the default XHtmlOptions.BrowserWidth property (optional).
DisableCache | Boolean | Allows you to override and disable the page cache (optional). See the XHtmlOptions.PageCacheEnabled property for details.
ImageID | Long | The ID of the newly added View object.

Notes

This method is essentially the same as the AddImageUrl method, but it allows you to use raw HTML rather than having to specify a URL.

ABCpdf saves this HTML into a temporary file and renders the file using a 'file://' protocol specifier. So this is a convenience method - it doesn't offer any performance enhancements.

Sometimes the IIS users don't have full access to the temp directory. This is determined by the system setup you have on your machine. If this is the case, you will get errors returned.

So if you are working from ASP, you may find that you need to enable access to the temp directory for the ASPNET user, the IUSR_MACHINENAME user or the IWAM_MACHINENAME user.

Styles and Images. HTML does not exist within a file, and so it does not have a location.

External stylesheets and images are often referenced via relative URLs. Because the HTML has no location, it is impossible to resolve these relative reference.

So you need to provide your stylesheet and image links as absolute references. Or you may be able to use the HTML BASE element to specify an appropriate base location. Or you can save your HTML to file in an appropriate location and then use AddImageUrl.

Example

None.


AddImageObject Method

Gets an image from an Image object and adds it to the current page.

Syntax

ImageID = Doc.AddImageObject(Image, Transparent)

Params
Name | Type | Description
Image | XImage | The image to be added to the page.
Transparent | Boolean | Whether transparency information should be preserved.
ImageID | Long | The ID of the newly added Image object.

Notes

Gets an image from an Image object and adds it to the current page returning the ID of the newly added object.

Adds the Selection of the current Frame returning the ID of the newly added object.

Images embedded using this method are always inserted using indirect mode. Indirect mode is not as fast as pass-through mode. However, it allows greater flexibility and the use of many different image formats.

If the Transparent parameter is set to true, then any transparency information will be preserved. This allows you to add formats such as transparent GIF, PNG with alpha channel, or images with masks set using the Image.SetMask method.

The image is scaled to fill the current Rect. It is transformed using the current Transform.

If the width or height of the current rectangle is zero, the image is auto-sized. If you are working in TopDown mode, the image is positioned with its top left pinned at the location indicated by the rectangle. If you are not in TopDown mode, the bottom left of the image is pinned at the location indicated by the rectangle. In both cases, the natural dimensions of the supplied image are used to determine the displayed width and height resulting in a 72-dpi output.

Example

The following code adds a transparent GIF against a gray background.

Set theImg = Server.CreateObject("ABCpdf14.Image")
theImg.SetFile "c:\mypics\mypic.gif"
Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Color = "200 200 200"
theDoc.FillRect
theDoc.Rect = "0 0 0 0"
theDoc.AddImageObject theImg, True
theDoc.Save "c:\mypdfs\docaddimageobject.pdf"

docaddimageobject.pdf


AddImageToChain Method

Adds a new page from a paged HTML or PostScript render.

Syntax

ImageID = Doc.AddImageToChain(ID)

Params
Name | Type | Description
ID | Long | The ID of the previous object in the chain.
ImageID | Long | The ID of the newly added object.

Notes

Some web pages are too large to fit on one PDF page.

To split a web page across multiple PDF pages, you need to call AddImageUrl or AddImageHtml to render the first page. The ID returned from these calls represents the head of the chain.

To add subsequent pages to the chain, you need to make calls to AddImageToChain passing in the previous image from the chain each time.

As well as using chaining to split web pages across multiple PDF pages, you can also use it to split your web pages across multiple columns within a page. You can even split your chain to generate multiple copies of the same page.

More information can be found in the HTML / CSS Rendering section of the documentation.

Similarly, some PostScript (PS) files contain more than one page of content.

To split a PS file across multiple PDF pages, you need to call AddImageFile or AddImageData to render the first page. The ID returned from these calls represents the head of the chain.

To add subsequent pages to the chain, you need to make calls to AddImageToChain passing in the previous image from the chain each time.

Example

This example shows how to import an HTML page into a multi-page PDF document.

We first create a Doc object and inset the edges a little so that the HTML will appear in the middle of the page.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 72, 144

We add the first page and indicate that we will be adding more pages by telling the Doc object that this is page one. We save the returned ID as this will be used to add subsequent pages.

theURL = "http://www.yahoo.com/"
theID = theDoc.AddImageUrl(theURL)

We now chain subsequent pages together. We stop when we reach a page which wasn't truncated.

Do
  theDoc.FrameRect
  If Not theDoc.Chainable(theID) Then Exit Do
  theDoc.Page = theDoc.AddPage()
  theID = theDoc.AddImageToChain(theID)
Loop

After adding the pages, we can flatten them. We can't do this until after the pages have been added because flattening will invalidate our previous ID and break the chain.

For i = 1 To theDoc.PageCount
  theDoc.PageNumber = i
  theDoc.Flatten
Next

Finally, we save.

theDoc.Save "c:\mypdfs\pagedhtml.pdf"

We get the following output.

pagedhtml.pdf [Page 1]
pagedhtml.pdf [Page 2]


AddImageUrl Method

Renders a web page specified by URL.

Syntax

ImageID = Doc.AddImageUrl(Url [, Paged[, Width[, DisableCache]]])

Params
Name | Type | Description
Url | String | The URL for the page to be rendered.
Paged | Boolean | Allows you to override the default XHtmlOptions.Paged property (optional).
Width | Long | Allows you to override the default XHtmlOptions.BrowserWidth property (optional).
DisableCache | Boolean | Allows you to override and disable the page cache (optional). See the XHtmlOptions.PageCacheEnabled property for details.
ImageID | Long | The ID of the newly added View object.

Notes

This method adds a web page to a document.

The page is added in accordance with the current XHtmlOptions settings. As a convenience, you can override the more commonly used settings as detailed above.

Only the first page of the document is drawn. Subsequent pages can be drawn using the AddImageToChain method.

The web page is scaled to fill the current Rect. It is transformed using the current Transform.

Caching. Sometimes, you may find that pages appear to be cached.

If you are using AddImageUrl, it is possible that the URL is in some way being cached. So the PDF may be changing, but the content within it may be staying the same. See the HTML / CSS Rendering section of the documentation for details.

Alternatively, it is possible that the PDF itself is being cached. Most commonly, this can happen if you're streaming the PDF direct to the browser and you have certain IIS settings (like Expire Content) disabled.

Your first step should be to narrow down the problem. Why not save the PDF to disk at the same time as sending it to the client? That way you can establish whether the PDF itself is being cached or whether the content is in some way being cached (resulting in the same PDF being created again and again).

If the PDF is being cached, you will need to look at your IIS settings. ABCpdf is not doing the caching (and indeed, it cannot cache the PDF in this way); it will be something which is happening either in IIS/ASP or on an intervening proxy server or on the client.

Example

We create an ABCpdf Doc object, add our URL and save. That's it!

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.AddImageUrl "http://www.google.com/"
theDoc.Save "c:\mypdfs\htmlimport.pdf"

We get the following output.

htmlimport.pdf

For an example of how to use paged HTML, see the AddImageToChain method.


AddLine Method

Adds a line to the current page.

Syntax

GraphicID = Doc.AddLine(X1, Y1, X2, Y2)

Params
Name | Type | Description
X1 | Double | The horizontal coordinate of the start point.
X2 | Double | The horizontal coordinate of the end point.
Y1 | Double | The vertical coordinate of the start point.
Y2 | Double | The vertical coordinate of the end point.
GraphicID | Long | The Object ID of the newly added Graphic object.

Notes

Adds a line to the current page. The line is drawn in the current color at the current width and with the current options.

The AddLine method returns the Object ID of the newly added Graphic object.

Example

The following code adds two horizontal lines to a document. The first is blue, and the second is green.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Width = 24
theDoc.Color = "0 0 255"
theDoc.AddLine -50, 100, 999, 100
theDoc.Color = "0 255 0"
theDoc.AddLine -50, 400, 999, 400
theDoc.Save "c:\mypdfs\docaddline.pdf"

docaddline.pdf


AddObject Method

Adds a native PDF object to the document.

Syntax

ObjID = Doc.AddObject(Text)

Params
Name | Type | Description
Text | String | The raw native object to be added.
ObjID | Long | The Object ID of the newly added object.

Notes

You will not normally need to use this feature. However, it can be useful if you wish to add objects which are defined in the PDF specification but not supported by ABCpdf.

Be aware that the text you pass to this method must be in native PDF format. This means that unusual characters in text strings must be appropriately escaped. For full details of the way that PDF objects are represented, you should see the Adobe PDF Specification.

Your newly added object needs to be referenced from somewhere in the PDF document. If you do not reference your object, it will be orphaned and will be deleted when the document is saved.

Example

The following code adds a document information section to an existing PDF document. First, it adds an empty dictionary and references it from the document trailer. Then, it adds an Author, Title and Subject before saving.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypdfs\sample.pdf"
theID = theDoc.AddObject("<<>>")
theDoc.SetInfo -1, "/Info", theID & " 0 R"
theDoc.SetInfo theID, "/Author", "(Arthur Dent)"
theDoc.SetInfo theID, "/Title", "(Musings on Life)"
theDoc.SetInfo theID, "/Subject", "(Philosophy)"
theDoc.Save "c:\mypdfs\docaddobject.pdf"


AddOval Method

Adds an oval to the current page.

Syntax

GraphicID = Doc.AddOval(Filled)

Params
Name | Type | Description
Filled | Boolean | Whether to fill the oval rather than simply outline it.
GraphicID | Long | The Object ID of the newly added Graphic object.

Notes

Adds an oval to the current page. The oval is drawn in the current color at the current width and with the current options. It is scaled to fill the current rectangle. The oval may be outlined or filled.

The AddOval method returns the Object ID of the newly added Graphic object.

Example

The following code adds two ovals to a document. The outline oval is semi-transparent.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Width = 80
theDoc.Rect.Inset 50, 50
theDoc.Color = "255 0 0"
theDoc.AddOval True
theDoc.Color = "0 255 0 a128"
theDoc.AddOval False
theDoc.Save "c:\mypdfs\docaddoval.pdf"

docaddoval.pdf


AddPage Method

Adds a page to the current document.

Syntax

PageID = Doc.AddPage([PageNum])

Params
Name | Type | Description
PageNum | Long | The page insertion location (optional). By default, pages are added at the end of the document.
PageID | Long | The Object ID of the newly added Page object.

Notes

Adds a page to the current document.

The AddPage method returns the Object ID of the newly added Page object. Typically, you will want to assign this return value to the document Page property using code of the form.

theDoc.Page = theDoc.AddPage()

Pages are added at the end of the document. However, you can use the PageNum parameter to insert pages at other locations. The following code inserts a page at the start of a document.

theDoc.Page = theDoc.AddPage(1)

Any existing page and all subsequent pages will be shifted towards the end of the document to make room for the insertion.

Example

The following code adds three pages to a document. Each page is marked with the page number and page Object ID.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96 ' big text
theDoc.HPos = 0.5 ' centered
theDoc.VPos = 0.5 ' ...
For i = 1 To 3
  theDoc.Page = theDoc.AddPage()
  txt = "Page " & i & ", ID="
  txt = txt & theDoc.Page
  theDoc.AddText txt
Next
theDoc.Save "c:\mypdfs\docaddpage.pdf"

docaddpage.pdf


AddPie Method

Adds a pie slice to the current page.

Syntax

GraphicID = Doc.AddPie(AngleStart, AngleEnd, Filled)

Params
Name | Type | Description
AngleStart | Double | The start angle of the pie slice in degrees.
AngleEnd | Double | The end angle of the pie slice in degrees.
Filled | Boolean | Whether to fill the pie slice rather than simply outline it.
GraphicID | Long | The Object ID of the newly added Graphic object.

Notes

Adds a pie slice to the current page. The slice is drawn in the current color at the current width and with the current options.

The pie slice represents a segment of the oval which would fill the current rectangle. Drawing starts at the start angle, and the arc is swept out until the end angle is reached. Angles are measured anti-clockwise with zero at three o'clock. The slice may be outlined or filled depending on the values passed to the method.

The AddPie function returns the Object ID of the newly added Graphic object.

Example

The following code adds two pie slices to a document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Width = 80
theDoc.Rect.Inset 50, 50
theDoc.Color = "255 0 0"
theDoc.AddPie 0, 90, True
theDoc.Color = "0 255 0"
theDoc.AddPie 180, 270, False
theDoc.Save "c:\mypdfs\docaddpie.pdf"

docaddpie.pdf


AddPoly Method

Adds a polygon to the current page.

Syntax

GraphicID = Doc.AddPoly(Points, Filled)

Params
Name | Type | Description
Points | String | The coordinates of the vertices of the polygon.
Filled | Boolean | Whether to fill the polygon rather than simply outline it.
GraphicID | Long | The Object ID of the newly added Graphic object.

Notes

Adds a polygon to the current page. The polygon is drawn in the current color at the current width and with the current options. The polygon may be outlined or filled.

The points string is a sequence of numbers representing the coordinates of the polygon. The string should be of the format "x1 y1 x2 y2 ... xN yN". The numbers may be delimited with spaces, commas or semicolons. If the first point is equal to the last then the path is closed before outlining.

The AddPoly method returns the Object ID of the newly added Graphic object.

Example

The following code adds a transparent green outlined star over the top of a red filled star.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Width = 80
theDoc.Color = "255 0 0"
theDoc.AddPoly "124 158 300 700 476 158 15 493 585 493 124 158", True
theDoc.Color = "0 255 0 a128"
theDoc.AddPoly "124 158 300 700 476 158 15 493 585 493 124 158", False
theDoc.Save "c:\mypdfs\docaddpoly.pdf"

docaddpoly.pdf


AddText Method

Adds a block of text to the current page.

Syntax

TextID = Doc.AddText(Text)

Params
Name | Type | Description
Text | String | The text to be added to the page.
TextID | Long | The Object ID of the newly added Text Object.

Notes

Adds a block of single styled text to the current page.

For adding multi-styled text or for chaining text from one page to another, you should use the AddHtml method, which is used for adding HTML styled text.

The text is in the current style, size and color and starts at the location specified in the current position. If the text is long, it will will wrap and extend downwards until it fills the current rectangle. Text positioning in the rectangle is determined by the horizontal and vertical positioning.

The AddText method returns the Object ID of the newly added Text object. If no text could be added, then zero is returned. This will happen if a zero length string is supplied or if the rectangle is too small for even one character to be displayed.

Typically, you will get a return value of zero if your text was too large to fit in your Rect or if the Pos was at the end of the Rect. So if you are expecting text to be displayed and are seeing a return value of zero, check your text size, check your Rect is where you think it is by framing it using FrameRect, and ensure your Pos is set at the top left of the Rect.

Text is drawn word-wrapped within the current rectangle with the first character at the location specified by the Pos property. Normally, the Pos property reflects the top left position of the current rectangle. However, if you need to alter the position at which text drawing starts, you can modify the Pos property after changing the Rect. When the text has been drawn, the Pos will be updated to reflect the next text insertion point.

Character positioning is specified from the top left of the character. The FontSize determines the total line height, and the character baseline is 80% of the way down from the top of the line.

Example

The following code adds a number of chunks of text to a document. Each chunk is in a different style. This sample makes use of the fact that the Pos is updated to point to the next text insertion point after adding a piece of text. However, note that when inserting muti-styled text, it is generally more efficient to use the AddHtml method.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Page = theDoc.AddPage()
theDoc.FontSize = 48
theF1 = theDoc.AddFont("Times-Roman")
theF2 = theDoc.AddFont("Times-Bold")
theDoc.Font = theF1
theDoc.AddText "Gallia est omnis "
theDoc.Font = theF2
theDoc.AddText "tertiam Galli appellantur "
theDoc.Font = theF1
theDoc.AddText "divisa in partes tres, "
theDoc.Font = theF2
theDoc.AddText "quarum unam incolunt "
theDoc.Font = theF1
theDoc.AddText "Belgae, aliam Aquitani. "
theDoc.Font = theF2
theDoc.AddText "tertiam Galli appellantur"
theDoc.Save "c:\mypdfs\docaddtext.pdf"

docaddtext.pdf


Append Method

Appends a PDF to the end of the document.

Syntax

Doc.Append Doc

Params
Name | Type | Description
Doc | Doc | The document to add to the end of this one.

Notes

Use this method to append one PDF to the end of another one.

Individual pages from one PDF can be drawn into another using the AddImageDoc method.

If you are inserting a number of pages, it is much faster to use the Append method than to draw pages individually. It also has the advantage of maintaining other information such as bookmarks.

Example

The following code snippet illustrates how one might join two PDF documents together.

Set theDoc1 = Server.CreateObject("ABCpdf14.Doc")
theDoc1.FontSize = 192
theDoc1.HPos = 0.5
theDoc1.VPos = 0.5
theDoc1.AddText("Hello")
Set theDoc2 = Server.CreateObject("ABCpdf14.Doc")
theDoc2.FontSize = 192
theDoc2.HPos = 0.5
theDoc2.VPos = 0.5
theDoc2.AddText("World")
theDoc1.Append theDoc2
theDoc1.Save "c:\mypdfs\docjoin.pdf"

docjoin.pdf [Page 1]

docjoin.pdf [Page 2]


Chainable Method

Determines whether an object is chainable.

Syntax

Truth = Doc.Chainable(ID)

Params
Name | Type | Description
ID | Long | The Object ID of the object to be tested.
Truth | Boolean | Whether the object is chainable.

Notes

Use this method to determine whether an object is chainable.

Some objects can be chained. A chunk of text may be chained from page to page on the output PDF. Similarly, a web page may be chained from page to page.

This method allows you to determine whether the object you have added is chainable or whether it is at the end of the chain.

Only text, PostScript images and web pages can be chainable. So your ID should have been obtained from a previous call to one of the AddImage family of calls or from AddHtml.

Example

See the AddImageToChain method.


Clear Method

Clears the document.

Syntax

Doc.Clear

Params
Name | Type | Description
n/a | n/a | n/a

Notes

Use this method to release resources and return the document to a just-created state.

Example

None.


Delete Method

Deletes an object previously added to the document.

Syntax

Doc.Delete ID

Params
Name | Type | Description
ID | Long | The Object ID of the object to be deleted.

Notes

Use this method to delete an object previously added to the document.

Deletion is most commonly applied to pages to remove them from the document. For example, to delete the current page, you might use the following code:

theDoc.Delete theDoc.Page

Example

The following code snippet illustrates how one might add an image and then delete it if the image color space is CMYK.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theID1 = theDoc.AddImageFile("c:\mypics\mypic.jpg", 1)
theID2 = theDoc.GetInfo(theID1, "XObject")
theComps = theDoc.GetInfo(theID2, "Components")
If theComps = 4 Then theDoc.Delete(theID1)
theDoc.Save "c:\mypdfs\docdelete.pdf"

docdelete.pdf


EmbedFont Method

Embeds a font into the document.

Syntax

FontID = Doc.EmbedFont(FontName [,Language[, Vertical[, Subset[, Force]]]])

Params
Name | Type | Description
FontName | String | The name of the font typeface.
Language | String | The language type to use (optional). See the Fonts and Languages section for details on language types. The default language type is Latin.
Vertical | Boolean | Whether the text direction should be vertical (optional). See the Fonts and Languages section for details on writing directions. The default is false to indicate standard left-to-right layout.
Subset | Boolean | Whether to subset the font (optional). See the Fonts and Languages section for details on subsetting. The default is false to indicate that the font should not be subsetted.
Force | Boolean | Whether to override permissions on the font (optional). Fonts often contain embedded licensing information. By default, ABCpdf will prevent you from embedding fonts which indicate that embedding is not permitted. You can force the font to be embedded by passing true for this value.
FontID | Long | The Object ID of the newly added Font object.

Notes

Embeds a font into the document.

The font name, a description of the font style and the the font glyph descriptions themselves are placed into the document. This ensures that the document will always display perfectly on every system and that font substitutions will never need to be made.

There are a number of reasons you may not wish to embed fonts and, instead, use the AddFont method. Embedding fonts can increase the size of your PDF considerably. Additionally, by distributing a PDF with an embedded font, you are actually redistributing the font itself. You should check with your font supplier or legal department that you have permission to do this.

For information on how to specify font names, see the AddFont method.

The EmbedFont method returns the Object ID of the newly added Font object. Typically, you will want to assign this return value to the document Font property using code of the form.

theDoc.Font = theDoc.AddFont("Courier")

If the specified font could not be found, then you will get an Object ID of zero returned. You may wish to check for this possibility. Otherwise, a default font will be used.

Fonts are cached so newly added fonts will not be available to ABCpdf until the application is restarted. If you need to dynamically load a font, you can pass this method a path to your font file. This will add the font to the cache and make it available for use. You should not move, rename or delete a font file which has been dynamically loaded using this technique.

Example

The following code embeds the font 'Comic Sans MS' into the document and then adds some text.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 216
theFont = "Comic Sans MS"
theDoc.Font = theDoc.EmbedFont(theFont)
theDoc.AddText theFont
theDoc.Save "c:\mypdfs\docembedfont.pdf"

docembedfont.pdf


FillRect Method

Adds a painted rectangle to the current page.

Syntax

GraphicID = Doc.FillRect([RadiusX, [RadiusY]])

Params
Name | Type | Description
RadiusX | Double | The horizontal radius to use for rounded corners (optional).
RadiusY | Double | The vertical radius to use for rounded corners (optional).
GraphicID | Long | The Object ID of the newly added Graphic object.

Notes

Adds a painted rectangle to the current page. The rectangle location and size is determined by the current rectangle, the fill color is determined by the current color and any options are determined by the current options.

By specifying values for the horizontal and vertical radius parameters, you can draw rectangles with rounded corners. The values refer to the radii of the ellipse used to draw the corners.

By setting the horizontal radius parameter to half the width of the rect and the vertical radius parameter to half the height of the rect, you can draw filled ovals and circles.

The FillRect method returns the Object ID of the newly added Graphic object.

Example

The following code adds a blue filled rectangle to a document. The frame is inset from the edges of the document by 200 points horizontally and 100 points vertically.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 200, 100
theDoc.Color.Blue = 255
theDoc.FillRect
theDoc.Save "c:\mypdfs\docfillrect.pdf"

docfillrect.pdf


Flatten Method

Flattens and compresses the current page.

Syntax

ObjectID = Doc.Flatten()

Params
Name | Type | Description
ObjectID | Long | The Object ID of the compressed page contents.

Notes

Objects added to a page are stored as individual layers. Calling this method combines all layers on the current page and then re-compresses the layer data.

For pages that contain only a few layers, the reduction in size will be minimal. However, for pages which contain complex tables with many items, flattening can reduce the size of the output PDF by a factor of five or more.

Note that flattening will delete all the items currently on the page and replace them with a new compressed item. This means that Object IDs previously obtained from calls such as AddText or FrameRect will no longer be valid.

Example

See the Small Table Example and Large Table Example.


FrameRect Method

Adds a rectangular frame to the current page.

Syntax

GraphicID = Doc.FrameRect([RadiusX [, RadiusY [, Inside]]])

Params
Name | Type | Description
RadiusX | Double | The horizontal radius to use for rounded corners (optional).
RadiusY | Double | The vertical radius to use for rounded corners (optional).
Inside | Boolean | Whether to draw the frame inside the rectangle (optional).
GraphicID | Long | The Object ID of the newly added Graphic object.

Notes

Adds a rectangular frame to the current page. The frame location and size is determined by the current rectangle, the line color is determined by the current color, the line width is determined by the current width and any options are determined by the current options.

By specifying values for the horizontal and vertical radius parameters, you can draw rectangles with rounded corners. The values refers to the radii of the ellipse used to draw the corners.

By setting the horizontal radius parameter to half the width of the rect and the vertical radius parameter to half the height of the rect, you can draw ovals and circles.

By default, frames are drawn round the outside of the current rectangle. This allows you to add content and then frame it ensuring that the frame and the content do not overlap. However, sometimes you may wish to draw the frame round the inside of the rectangle. You can do this by setting the Inside parameter to true.

The FrameRect method returns the Object ID of the newly added Graphic object.

Example

The following code adds a black frame to a document. The frame is inset from the edges of the document by 50 points horizontally and 100 points vertically.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 50, 100
theDoc.FrameRect
theDoc.Save "c:\mypdfs\docframerect.pdf"

docframerect.pdf


GetData Method

Saves a document to memory.

Syntax

Data = Doc.GetData()

Params
Name | Type | Description
Data | Array of Bytes | The PDF document as an array of bytes.

Notes

Normally, you will want to save your documents using the Save method. However, sometimes, you will need to obtain your PDF as raw data rather than in file format. The GetData method allows you to do this.

You may wish to write a PDF direct to a client browser rather than going through an intermediate file. The data you obtain using GetData can be written directly to an HTTP stream using Response.BinaryWrite. Similarly, you may wish to obtain raw data for insertion into a database.

PDFs and Internet Explorer. The combination of Internet Explorer and Acrobat is not always trouble-free - particularly under https or using older versions of Internet Explorer. It can be difficult to know exactly where the problem lies because there is an interaction of the Operating System, Internet Explorer and Acrobat. Any of these can be the cause.

Sometimes, Internet Explorer may get 'stuck' on a particular content type and insist on displaying your PDF as HTML. In this case, you will see random text starting with %PDF. Sometimes, this can happen if you stream PDF data to a window which was previously displaying HTML.

Sometimes, server-side debugging results in extra data being inserted into the content stream. While this may not matter for HTML, it will corrupt binary documents like PDF.

Sometimes, your code may inadvertently insert extra data into the content stream. Again, this will corrupt the PDF. Error messages are a common cause of this kind of corruption.

HTTP compression may result in PDF streams being compressed before they are returned to the browser. While browsers are able to deal with this type of compression, Acrobat may not be able to. You can see whether this type of compression is being used by examining the headers returned to the browser using a tool like IEWatch. If you are using IIS 6 compression, you can disable it on a page-by-page basis using the IIS Metabase Explorer from the IIS 6 resource kit.

For testing purposes, you may wish to change the content-disposition from 'inline' to 'attachment'. This will allow you to download the data rather than viewing it in your browser. You can then check the downloaded document using Acrobat or a hex editor.

Alternatively, if the problem is that PDFs seem to be cached, you may wish to check the 'Enable Content Expiration' checkbox you will find under the Web Site Properties.

We would suggest two steps:

  1. Your first step should be to eliminate ABCpdf as the cause. Why not save the PDF to disk at the same time as sending it to the client? That way you can establish that the PDF is fine. If you want to take it further, you can then read the PDF data from disk and stream it direct to the client.
  2. The example site streams PDF data direct to the client. So install the example site into a new virtual directory, and establish whether the same issue exists for the example site. If it works, then it's simply a matter of moving your current code base and the example site code base towards each other until you find the cause of the problem.

Example

The following code illustrates how one might add text to a PDF and then write it direct to the client browser. This code is an entire Active Server Page - hello.asp.

<% @Language="VBScript" EnableSessionState=FALSE %>

<%
Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96
theDoc.AddText "Hello World"
theData = theDoc.GetData()
Response.ContentType = "application/pdf"
Response.AddHeader "content-length", UBound(theData) - LBound(theData) + 1
Response.AddHeader "content-disposition", "inline; filename=MyPDF.PDF"
Response.BinaryWrite theData
%>

hello.asp


GetInfo Method

Gets information about an object.

Syntax

Info = Doc.GetInfo(ID, Type)

Params
Name | Type | Description
ID | Long | The Object ID of the object to be queried.
Type | String | The type of information to be retrieved.
Info | String | The returned information.

Notes

After you modify a document, you may want to get back information about the objects you have added. For example, you might want to find out the natural dimensions of an image or you might want to find out how many characters were drawn when you inserted some text. This method allows you access to this information.

There are core information types that all objects support. There are also information types specific to particular types of object. You can use core information types to allow you to iterate through every object in your document finding out specific information about each of them.

If the object does not exist or does not support the requested type of information, then an empty string is returned.

Every object supports the ID and Type properties. For more detailed information about this and other properties, see the PDF Objects section of this document.

PDF objects are case-sensitive, so be sure you use the correct case when specifying information.

Example

The following code snippet illustrates how one might find out the natural dimensions of an image.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theID1 = theDoc.AddImageFile("c:\mypics\mypic.jpg", 1)
theID2 = theDoc.GetInfo(theID1, "XObject")
theWidth = theDoc.GetInfo(theID2, "Width")
theHeight = theDoc.GetInfo(theID2, "Height")
Response.Write "Width " & theWidth & "<br>"
Response.Write "Height " & theHeight & "<br>"


GetText Method

Extracts content from the current page in a specified format.

Syntax

Text = Doc.GetText(Type)

Params
Name | Type | Description
Type | String | The format in which to return the content.
Text | String | The returned content.

Notes

This method allows you to extract the content from a page.

There are three formats supported - "Text", "SVG" and "SVG+".

Text is in layout order, which may not be the same as reading order. For example, what to a user may look like a space may simply be two items of text positioned apart from each other, or it may not. ABCpdf will make sensible assumptions on how items of text should be combined but many situations are ambiguous.

SVG is an XML based format for representing vector graphics. Because SVG is standard XML, it's easy to parse and gives you the precise position of each item of text on the page. The way that ABCpdf constructs the SVG should make it easy to extract any information you require. ABCpdf currently supports SVG text and paths.

For example, a simple "Hello World" PDF might produce the following content:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="612" height="792" x="0" y="0">
<text x="0" y="76.8" font-size="96" font-family="Times-Roman" >Hello World</text>
</svg>

SVG+ is an annotated form of SVG which includes details of the PDF operators and how they relate to the items of content in the SVG. It can be very useful if you are trying to deconstruct a page and determine how objects in the PDF relate to objects in the SVG.

For example, you could use SVG+ to identify the section of a PDF stream that relates to a particular word on a page. You could then replace the text show operator for that word with another one. Effectively, you'd be performing a low-level Search/Replace on the PDF document.

There is no official standard for SVG+, but if you are familiar with the PDF specification it should be easy enough to understand.

For example, a simple "Hello World" PDF might produce the following content:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="612" height="792" x="0" y="0">
<pdf pdf_Op="q" pdf_StreamID="5" pdf_StreamOffset="0" pdf_StreamLength="1" />
<pdf pdf_Op="BT" pdf_StreamID="5" pdf_StreamOffset="3" pdf_StreamLength="2" />
<pdf pdf_Op="0 Tr" pdf_StreamID="5" pdf_StreamOffset="7" pdf_StreamLength="4" />
<pdf pdf_Op="/Fabc6 96 Tf" pdf_StreamID="5" pdf_StreamOffset="13" pdf_StreamLength="12" />
<pdf pdf_Op="0 0 0 rg" pdf_StreamID="5" pdf_StreamOffset="27" pdf_StreamLength="8" />
<pdf pdf_Op="1 0 0 1 0 715.2 Tm" pdf_StreamID="5" pdf_StreamOffset="37" pdf_StreamLength="18" />
<pdf pdf_Op="0 Ts" pdf_StreamID="5" pdf_StreamOffset="57" pdf_StreamLength="4" />
<text x="0" y="76.8" font-size="96" font-family="Times-Roman" pdf_CTM="1 0 0 1 0 0" pdf_TM="1 0 0 1 0 715.2" pdf_Trm="96 0 0 96 0 715.2" pdf_Tf="Fabc6" pdf_Tz="100" pdf_Ts="0" pdf_w1000="5027" pdf_Op="(Hello World) Tj" pdf_StreamID="5" pdf_StreamOffset="63" pdf_StreamLength="16" >Hello World</text>
<pdf />
<pdf pdf_Op="ET" pdf_StreamID="5" pdf_StreamOffset="81" pdf_StreamLength="2" />
<pdf pdf_Op="Q" pdf_StreamID="5" pdf_StreamOffset="85" pdf_StreamLength="1" />
</svg>

The operators within the PDF stream are detailed in the SVG. For example, the first 'q' operator is located in Object ID 5 at offset 0 and has a length of 1 byte. The 'Tj' operator which shows "Hello World" is at offset 63 and has length 16. The Current Transformation Matrix (CTM), the Text Matrix (TM), and other important PDF state values are shown.

Example

None.


Read Method

Reads an existing PDF.

Syntax

Doc.Read PathOrData [, Password]

Params
Name | Type | Description
PathOrData | String or Array of Bytes | The source file path or the source data.
Password | String | Any password needed to open the document.

Notes

Use this method to read a PDF into a document object. Any existing document content will be discarded.

You can specify the PDF as a file path or by passing in the raw PDF data. Raw data must be held as an array of bytes. You can open encrypted PDF documents if you supply a valid password.

After the read operation is complete, the Page property will contain the ID of the first page in the document. The Rect and MediaBox properties will reflect the size of the first page in the document.

ABCpdf operates an intelligent just-in-time object loading scheme, which ensures that only those objects that are required are loaded into memory. This means that if you are modifying large documents, then server load will be kept to a minimum. The original PDF document must be available for as long as the Document object is being used.

As a result, you cannot overwrite a PDF file while it is open for reading. You will need to save your PDF to another location and then swap the two files round.

Object deletion requires that all references to an object be removed. There is no way of doing this without checking each object in the document. So object deletion requires that every object in the document is loaded, and for large documents, this may place a significant load on the server.

Reading encrypted documents places a greater load on the server because - like object deletion - it requires that every object in the document be loaded.

Please note that you are legally bound to respect the permissions present in existing PDF documents. For details, please see the Legal Requirement Section.

The Read method may be used to read eForm FDF documents as well as PDF documents. Most PDF operations will not work on FDF documents, but you can query field values using the GetInfo methods to return Unicode strings.

Modifying Documents. ABCpdf will allow you to open, modify and save PDF documents.

ABCpdf will allow you to draw on top of PDF documents or add or delete pages or modify document data. However, because of the way that PDF documents are structured, it's unlikely that you'll be able to edit existing content.

So if there are blank spaces which you can draw your entries into, that will work. Indeed, you might want to draw a white box over existing content and then draw on that.

However, you shouldn't expect to be able to edit and re-flow text that is already in your PDF.

Example

The following illustrates how one might add a large red number to every page of a PDF document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypics\sample.pdf"
theDoc.FontSize = 500
theDoc.Color = "255 0 0"
theDoc.HPos = 0.5
theDoc.VPos = 0.3
theCount = theDoc.PageCount
For i = 1 To theCount
  theDoc.PageNumber = i
  theDoc.AddText i
Next
theDoc.Save "c:\mypdfs\docread.pdf"

docsave.pdf [Page 1] | docsave.pdf [Page 2]
docsave.pdf [Page 3] | docsave.pdf [Page 4]


RemapPages Method

Remaps pages for reordering, copying and deletion.

Syntax

Doc.RemapPages(Pages)

Params
Name | Type | Description
Pages | String | The ordered list of page numbers of pages to remain.

Notes

This method provides a simple method for remapping the pages in a document. It can be used for reordering, copying or deleting pages.

It accepts a list of page numbers and reorders the pages in the document so that they mach these page numbers. If a number is repeated more than once, the page is duplicated. If a number is omitted, the page is deleted.

Page numbers can be delimited using spaces, commas or semicolons. The first page in a document is page one. So to reverse a four-page document, you might use "4 3 2 1".

Example

The following code snippet illustrates how one might reverse all the pages in a document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypics\sample.pdf"
theDoc.FontSize = 500
theDoc.Color = "255 0 0"
theDoc.HPos = 0.5
theDoc.VPos = 0.3
theCount = theDoc.PageCount
thePages = ""
For i = 1 To theCount
theDoc.PageNumber = i
theDoc.AddText i
thePages = thePages & (theCount - i + 1) & "
              "
Next
theDoc.RemapPages thePages
theDoc.Save "c:\mypdfs\docremappages.pdf"

docremappages.pdf [Page 1] | docremappages.pdf [Page 2]
docremappages.pdf [Page 3] | docremappages.pdf [Page 4]


Save Method

Saves the document as PDF.

Syntax

Doc.Save Path

Params
Name | Type | Description
Path | String | The destination file path.

Notes

Use this method to export the current document as PDF. The supplied path is used as the destination. Any existing file will be overwritten.

ABCpdf operates an intelligent just-in-time object loading scheme, which ensures that only those objects that are required are loaded into memory. This means that if you are modifying large documents, then server load will be kept to a minimum. The original PDF document must be available for as long as the Document object is being used.

As a result, you cannot overwrite a PDF file while it is open for reading. You will need to save your PDF to another location and then swap the two files round.

If you need to obtain a PDF as raw data, you can use the GetData method.

Versions. ABCpdf automatically determines the PDF version depending on the features you use. If you use features from only the 1.1 specification, it will write a 1.1 PDF. If you use 1.3 features, it will write a 1.3 PDF. If you use 1.4 features, it will write a 1.4 PDF. Ditto 1.5 and 1.6.

If you're using a PDF template or drawing from another PDF, the final output will be the minimum version used in these templates. In many real world applications, this will be the factor which determines the version in the final output produced by ABCpdf.

There is no advantage in producing a 1.6 document if you're not using features from the 1.6 feature set. To do this will simply stop users of older versions of Acrobat from accessing a document which should be available to them.

Example

The following code illustrates how one might add text to a PDF and then save it out.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96
theDoc.AddText "Hello World"
theDoc.Save "c:\mypdfs\docsave.pdf"

docsave.pdf


SetInfo Method

Sets information about an object.

Syntax

Doc.SetInfo ID, Type, Value

Params
Name | Type | Description
ID | Long | The Object ID of the object to be modified.
Type | String | The type of value to insert.
Value | String | The value to insert.

Notes

In the same way as you can get information about aspects of a document using the GetInfo method, you can modify aspects of the document using the SetInfo method.

Different types of object support different types of properties. For more detailed information, see the PDF Objects section of this document.

PDF objects are case-sensitive, so be sure you use the correct case.

Example

The following shows how to modify the document catalog to ensure that the PDF opens onto the second page rather than the first.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypdfs\sample.pdf"
thePages = theDoc.GetInfo(theDoc.Root, "Pages")
thePage2 = theDoc.GetInfo(thePages, "Page 2")
theAction = "[ " & thePage2 & " 0 R /Fit ]"
theDoc.SetInfo theDoc.Root, "/OpenAction", theAction
theDoc.Save "c:\mypdfs\docsetinfo.pdf"

Open Actions. The way in which a PDF is displayed when opened is dependent on certain flags within the PDF itself. Here are some common combinations. For full details of how these work, you should see the Adobe PDF Specification available from the Adobe web site.

To show outlines:

theDoc.SetInfo theDoc.Root, "/PageMode", "/UseOutlines"

Or for thumbnails:

theDoc.SetInfo theDoc.Root, "/PageMode", "/UseThumbs"

To display two pages side by side:

theDoc.SetInfo theDoc.Root, "/PageLayout", "/TwoColumnLeft"

To make the print dialog appear when the document is opened:

theDoc.SetInfo theDoc.Root, "/OpenAction", "<</Type /Action /S /Named /N /Print>>"

To open at 200% zoom onto the current page:

theDoc.SetInfo theDoc.Root, "/OpenAction", "[ " & theDoc.Page & " 0 R /XYZ null null 2 ]"

To fit the document width onto the current page:

theDoc.SetInfo theDoc.Root, "/OpenAction", "[ " & theDoc.Page & " 0 R /FitH " & theDoc.MediaBox.Height & " ]"


ComFactory Property

Type | Default Value | Read Only | Description
ComFactory | n/a | Yes | The factory for creating objects in the same application domain.

Notes

This property allows you to create objects that are in the application domain of this object.

See the ComFactory object for full details.

Example

None.


Bookmark Property

Type | Default Value | Read Only | Description
XBookmark | n/a | Yes | The top-level bookmark for the document.

Notes

The bookmarks associated with this document.

PDF documents typically provide a list of bookmarks for easy navigation between pages. In Acrobat, this navigation structure is available under the Bookmarks tab. The PDF specification refers to this structure as the document outline.

The document outline comprises of a hierarchy of bookmarks. The bookmark at the top of the hierarchy is available via this property.

See the XBookmark object for further details.

Example

None.


Color Property

Type | Default Value | Read Only | Description
XColor | Black | Yes | The current drawing and filling color.

Notes

This property determines the color used for drawing lines, shapes, filled shapes and text.

Example

The following code creates a PDF document with a red background.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Color = "255 0 0"
theDoc.FillRect
theDoc.Save "c:\mypdfs\doccolor.pdf"

doccolor.pdf


ColorSpace Property

Type | Default Value | Read Only | Description
Long | 0 | No | The current ColorSpace ID.

Notes

This property determines the current color space.

The ColorSpace is used when the Color is of a matching type. If the color type does not match, then the default - device - color space is used.

For example, you add a CMYK color space and assign it to the ColorSpace property. All CMYK Colors you use will be defined in terms of this color space. However, RGB and Grayscale colors will continue to be defined in terms of the default - device - color spaces.

To get a ColorSpace ID, you need to add your color space to the current document using the AddColorSpaceFile or AddColorSpaceSpot method.

Example

The following code shows how to colorize an image. It adds a base image to the current page and converts it to grayscale. Then it creates a new spot color space and assigns the new color space to the image.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 20, 20

Set theImg = Server.CreateObject("ABCpdf14.Image")
theImg.SetFile "c:\mypics\mypic.jpg"
theID = theDoc.AddImageObject(theImg, False)

theID = theDoc.GetInfo(theID, "XObject")
theDoc.SetInfo theID, "Grayscale", ""

theCS = theDoc.AddColorSpaceSpot("MAGENTA", "0 100 0 0")
theDoc.SetInfo theID, "/ColorSpace:Ref", theCS

theDoc.Save "c:\mypdfs\doccolorspace.pdf"

doccolorspace.pdf


CropBox Property

Type | Default Value | Read Only | Description
XRect | Letter Size [0, 0, 612, 792]. | Yes | The current document visible page size.

Notes

This property reflects the CropBox (visible page size) of the current page.

For methods you can use to change the CropBox of the current page, see the MediaBox property.

Example

None.


Encryption Property

Type | Default Value | Read Only | Description
XEncryption | No encryption. | Yes | The current encryption settings.

Notes

This property determines the current encryption settings. When you save the document, the encryption settings - if any - will be used to determine the method of encryption to be used.

By default, documents are not encrypted when created. However, if you read an existing PDF document, the encryption property will be updated to reflect the encryption settings used to create the original document.

PDF encryption supports two different types of password - a user password and an owner password. You can use either password to open and view the document. However, unless you supply the owner password, permissions will be applied and access to the document may be restricted.

Typically, PDF encryption is used to apply permissions to a document. The user password is left blank, and only an owner password supplied. PDF readers will not prompt for a password if there is no user password. However, any permissions will automatically be applied. In this way, you can allow anyone to open the document but restrict access to operations like copying text, printing the document or extracting images.

Please note that you are legally bound to respect the permissions present in existing PDF documents. For details, please see the Legal Requirement Section.

Example

The following code saves a simple PDF document using a 128-bit encryption key. It applies a copy-protection permission to stop people copying text out of the document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96
theDoc.AddText "Hello World!"
theDoc.Encryption.Type = 2
theDoc.Encryption.CanCopy = False
theDoc.Encryption.OwnerPassword = "owner"
theDoc.Save "c:\mypdfs\docencrypt.pdf"


Font Property

Type | Default Value | Read Only | Description
Long | 0 | No | The current Font ID.

Notes

This property holds the current Font ID and determines the style of text that is added to the document using methods like AddText.

To get a Font ID, you need to add your font to the current document using the AddFont method.

Example

The following example adds two blocks of styled text to a document. The first block is in Helvetica, and the second in Courier.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96 ' big text
theDoc.Font = theDoc.AddFont("Helvetica")
theDoc.AddText "Helvetica Text."
theDoc.Font = theDoc.AddFont("Courier")
theDoc.AddText "Courier Text."
theDoc.Save "c:\mypdfs\docfont.pdf"

docfont.pdf


FontSize Property

Type | Default Value | Read Only | Description
Long | 10 | No | The current text size.

Notes

This property determines the size of text that is added to the document using methods like AddText.

The FontSize property is equivalent to the the XTextStyle.Size property, but unlike the Size property, it only allows integral sizes to be specified.

The font size is measured in the current Units.

Example

The following example adds two blocks of styled text to a document. The first block is in 96-point type, and the second is in 192-point type.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96
theDoc.AddText "Small "
theDoc.FontSize = 192
theDoc.AddText "Big"
theDoc.Save "c:\mypdfs\docfontsize.pdf"

docfontsize.pdf


Form Property

Type | Default Value | Read Only | Description
XForm | n/a | Yes | The document eForm.

Notes

This property allows you to examine and manipulate the document Form and Fields.

Fields are generally obtained using a fully qualified name. A full name describes a path down through the field hierarchy - using periods as delimiters - to a specific field object.

Once a field has been obtained, you can query or change its values. If you wish to convert the fields into a permanent part of the document, you can use the XField.Stamp method to permanently emboss them.

See the XForm object for full details.

Example

None.


HPos Property

Type | Default Value | Read Only | Description
Double | 0.0 | No | The current horizontal positioning.

Notes

This property determines the horizontal offset of blocks of text - used for left aligning, right aligning or centering.

The offset is measured as a proportion of the distance from the left. A value of zero indicates left aligning, a value of one half indicates centered text and a value of one indicates right aligning. Intermediate values can be used for intermediate offsets.

To vertically align text, use the VPos property. To justify text, use the XTextStyle.Justification property.

Example

The following code adds two blocks of text to a document. The first block is left aligned, and the second is right aligned. Before adding the text, we change the current rectangle and frame it so that you can see how the text is aligned.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96
theDoc.Rect.Magnify 1.0, 0.5
theDoc.Rect.Inset 40, 40
theDoc.FrameRect
theDoc.AddText "Left justified text..."
theDoc.Rect.Move 0, theDoc.Rect.Height + 80
theDoc.FrameRect
theDoc.HPos = 1.0
theDoc.AddText "Right justified text..."
theDoc.Save "c:\mypdfs\dochpos.pdf"

dochpos.pdf


HtmlOptions Property

Type | Default Value | Read Only | Description
XHtmlOptions | n/a | Yes | The HTML and URL rendering options and control.

Notes

This property allows you control over the way that HTML is rendered.

The properties of this object may be used to control the way that the AddImageUrl and AddImageHtml methods work.

The methods of this object operate on objects added using the the Doc.AddImageUrl and Doc.AddImageHtml methods. Some operations change the content. Others provide information about the content which has been added.

See the XHtmlOptions object for further details.

Example

None.


Layer Property

Type | Default Value | Read Only | Description
Long | 1 | No | The insertion position for new content.

Notes

The insertion position for new content.

The default layer is one, which indicates insertion at the top. So if you want to insert at the bottom and your page has ten layers, you need to insert at position eleven.

Note that insertion may not behave predictably with documents read from file. It is good practice for each layer to operate independently but not all documents are set up this way.

Example

None.


LayerCount Property

Type | Default Value | Read Only | Description
Long | 0 | Yes | The number of layers on the current page.

Notes

This property holds the number of layers on the current page.

You can add layers to pages using calls to methods such as AddText and AddImage. See the Layer property for more details.

Example

None.


License Property

Type | Default Value | Read Only | Description
String | See Below | Yes | The current license details.

Notes

The license property contains the current license details.

If you have ABCpdf installed on a trial basis, the license property contains details of the amount of time left on the trial.

If you have a full version of ABCpdf installed, this property contains the full description of your license and also the key that you have installed.

Example

The following example writes out the license information to an ASP page.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
Response.Write(theDoc.License)

Typical output might be:

Trial License - 26 days 02:18:19 Left


MediaBox Property

Type | Default Value | Read Only | Description
XRect | Letter Size [0, 0, 612, 792]. | Yes | The current document page size.

Notes

This property reflects the size of the current page. It also determines the size of new pages created by the AddPage method. Note that changing the MediaBox does not change the current Rect. So typically, you'll want to write code like this:

theDoc.MediaBox = "0 0 200 300"
theDoc.Rect = theDoc.MediaBox

Changing this property will change the size of pages created by subsequent calls to AddPage. However, it will not change the size of the pages that have already been created. To change the size of the pages that have already been created, you need to use the SetInfo method. For example:

theDoc.SetInfo theDoc.Page, "/MediaBox:Rect", "0 0 200 300"

Similar methods can be used to control other page size measures such as the CropBox, BleedBox, TrimBox and ArtBox. For example:

theDoc.SetInfo theDoc.Page, "/CropBox:Rect", "20 20 180 280"

The default page size is often the one you'll want to use. However, it may be that your PDFs are required to conform to a different page size. If this is the case, you can simply specify the name of the size rather than the exact dimension. See the Rect.String property for details.

Example

The following code creates a PDF document containing three different pages each with a different size.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Page = theDoc.AddPage
theDoc.MediaBox = "A4"
theDoc.Page = theDoc.AddPage
theDoc.MediaBox = "B5"
theDoc.Page = theDoc.AddPage
theDoc.Save "c:\mypdfs\docmediabox.pdf"


Options Property

Type | Default Value | Read Only | Description
String | "" | No | The current state options.

Notes

The options property is an advanced feature which allows low-level control over PDF drawing. It is important to use it correctly as incorrect use can corrupt your documents.

The value of the options property is inserted into the PDF content stream after state has been established but before any drawing has taken place. You can use this property to insert your own state commands. This is most commonly used for drawing dashed lines.

FillRect, FrameRect, AddLine and AddArc all insert the options parameter.

You can find details of graphics state parameters and how to use them in the Adobe PDF Specification.

Example

The following code adds an arc to a document. It uses the options parameter to make the line dashed rather than solid.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Width = 24
theDoc.Color = "0 120 0"
theDoc.Options = "[6 10] 6 d"
theDoc.AddArc 0, 270, 300, 400, 200, 300
theDoc.Save "c:\mypdfs\docoptions.pdf"

docoptions.pdf


Page Property

Type | Default Value | Read Only | Description
Long | 0 | No | The current Page ID.

Notes

This property holds the current Page ID. The current page is the one that receives new objects as they are added to the document.

For example, the methods AddText, AddLine, AddImage, FrameRect and FillRect all operate on the current page.

When you change this property, the Pos property is reset to the top left of the current Rect.

Note that the PageNumber property is not the same as the Page property. Page holds an Object ID typically returned from a call to AddPage. PageNumber indicates the page using an index ranging between one and the PageCount.

Either the Page or the PageNumber property can be used to set the current page.

If no page is specified, the current page is taken to be the first page in the document.

Example

The following example creates a document with two pages and adds text to each of the pages in turn.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96 ' big text
theDoc.Page = theDoc.AddPage()
theDoc.AddText "Page One"
theDoc.Page = theDoc.AddPage()
theDoc.AddText "Page Two"
theDoc.Save "c:\mypdfs\docpage.pdf"

docpage.pdf


PageCount Property

Type | Default Value | Read Only | Description
Long | 0 | Yes | The number of pages in the document.

Notes

This property holds the number of pages in the document.

You can add pages to the document using the AddPage method.

Example

None.


PageNumber Property

Type | Default Value | Read Only | Description
Long | 0 | No | The page number of the current page.

Notes

This property holds the current Page Number. The current page is the one that receives new objects as they are added to the document.

For example, the methods AddText, AddLine, AddImage, FrameRect and FillRect all operate on the current page.

When you change this property, the Pos property is reset to the top left of the current Rect.

Note that the PageNumber property is not the same as the Page property. Page holds an Object ID typically returned from a call to AddPage. PageNumber indicates the page using an index ranging between one and the PageCount.

Either the Page or the PageNumber property can be used to set the current page.

If no page is specified, the current page is taken to be the first page in the document.

Example

None.


Pos Property

Type | Default Value | Read Only | Description
XPoint | The top left of the current rectangle. | Yes | The current drawing position.

Notes

This property determines the current drawing position. This is used by the AddText method.

When you change the Page or Rect properties, the Pos is automatically reset to the top left of the current Rect. After adding text using the AddText method, the Pos is updated to point to the next text insertion position - just after the last drawn character.

Example

The following code creates a PDF document with text positioned at a number of different points within it.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 48
For i = 1 to 8
  theDoc.Pos.X = i * 40
  theDoc.Pos.Y = i * 80
  theDoc.AddText "Pos = " & theDoc.Pos
Next
theDoc.Save "c:\mypdfs\docpos.pdf"

docpos.pdf


Rect Property

Type | Default Value | Read Only | Description
XRect | The dimensions of the current page. | Yes | The current rectangle used for drawing operations.

Notes

This property determines the current rectangle. This is used by a number of operations including AddText, AddImage, FrameRect and FillRect.

The XRect object represents a rectangular area in two-dimensional space. The properties of the XRect object represent the bottom left and top right corners of the area.

AddText adds text within the current rectangle wrapping the text at the edges.

The AddImage methods add an image scaled to fill the current rectangle.

FrameRect frames the current rectangle, and FillRect fills the current rectangle.

When you change this property, the Pos property is reset to point to the top left of the Rect.

Example

The following code creates a PDF document containing a number of concentric frames.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect = "50 50 550 550"
For i = 1 to 20
  theDoc.FrameRect
  theDoc.Rect.Inset 20, 20
Next
theDoc.Save "c:\mypdfs\docrect.pdf"

docrect.pdf


Rendering Property

Type | Default Value | Read Only | Description
XRendering | n/a | Yes | The rendering options and control.

Notes

This property allows you control over the way that PDFs are rendered.

Note that Rendering is only available under the ABCpdf Professional License.

See the XRendering object for further details.

Example

None.


Root Property

Type | Default Value | Read Only | Description
Long | 1 | Yes | The root catalog object.

Notes

This property holds the ID of the catalog object.

The catalog is the root of the whole PDF document. It contains information on the root Pages object and the Outline object.

For dynamically created documents, the root of the document is always one. However, documents read from existing PDF files may use different root IDs.,

Example

The following code snippet illustrates how one might find some information about a PDF document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypdfs\mydoc.pdf"
theVers = theDoc.GetInfo(theDoc.Root, "/Version")
theNames = theDoc.GetInfo(theDoc.Root, "/Names")
thePages = theDoc.GetInfo(theDoc.Root, "Pages")
theOutlines = theDoc.GetInfo(theDoc.Root, "outlines")
Response.Write "Version " & theVers & "<br>"
Response.Write "Names " & theNames & "<br>"
Response.Write "Pages ID" & thePages & "<br>"
Response.Write "Outlines ID " & theOutlines & "<br>"

This might result in the following output.

Version /1.4
Names 12 0 R
Pages ID 618
Outlines ID 2169


SaveOptions Property

Type | Default Value | Read Only | Description
XSaveOptions | n/a | Yes | The save options and control.

Notes

This property allows you control over the way that PDF documents are saved or streamed.

The properties of this object may be used to control the way that the Save and GetData methods work.

See the XSaveOptions object for further details.

Example

None.


TextStyle Property

Type | Default Value | Read Only | Description
XTextStyle | Ten point text. | Yes | The current style for drawing text.

Notes

This property determines the current style settings used for adding text.

Example

The following code creates a PDF document and adds some text using a number of the text style properties to control formatting.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes lingua, institutis, legibus inter se differunt. Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit."
theText = theText & vbCrLf & theText & vbCrLf & theText & vbCrLf
theDoc.Rect.Inset 20, 20
theDoc.TextStyle.Size = 32
theDoc.TextStyle.Justification = 1
theDoc.TextStyle.Indent = 64
theDoc.TextStyle.ParaSpacing = 32
theDoc.AddText theText
theDoc.Save "c:\mypdfs\doctextstyle.pdf"

doctextstyle.pdf


TopDown Property

Type | Default Value | Read Only | Description
Boolean | False | No | The gradient of the vertical coordinate.

Notes

PDF coordinates are measured upwards from the bottom of the document. For some types of layout, it can be useful to measure coordinates downwards from the top of the document.

By setting this property to true, coordinates are assumed to start at the top rather than the bottom of the document.

More precisely, the origin is assumed to be at the top-left of the current MediaBox.

There are a variety of methods you can use to change coordinate systems.

Note that transforms operate on the underlying PDF coordinate space rather than any abstraction specified by the Units and TopDown properties. If you are using transforms, you will find it easiest to work in the native PDF coordinate space.

Example

The following code creates a PDF document and adds a grid measured in inches.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Units = "inches"
theDoc.TopDown = True
theDoc.Width = 1 / 8
theDoc.FontSize = 1
theDoc.Rect.Pin = 1
For i = 0 To 12 Step 2
  theDoc.AddLine 0, i, 12, i
  theDoc.Rect.Position 0, i
  theDoc.AddText i
  theDoc.AddLine i, 0, i, 12
  theDoc.Rect.Position i, 0
  theDoc.AddText i
Next
theDoc.Save "c:\mypdfs\doctopdown.pdf"

doctopdown.pdf


Transform Property

Type | Default Value | Read Only | Description
XTransform | The identity. | Yes | The current transformation for drawing.

Notes

This property determines the current world space transform. It affects any drawing using the AddText, AddImage, AddLine, FrameRect and FillRect methods.

Transforms are general operations which encompass rotation, translation, magnification and skewing or a combination of these. Note that the order in which transforms are applied is significant: a rotation followed by a translation is not the same as a translation followed by a rotation.

A world space transform is not same an object transform. You are changing the coordinate system - not the objects you're inserting.

Note that transforms operate on the underlying PDF coordinate space rather than any abstraction specified by the Units and TopDown properties. If you are using transforms, you will find it easiest to work in the native PDF coordinate space.

Example

The following code creates a PDF document and adds some text and a rectangle rotated at 45 degrees anti-clockwise around the middle of the document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes lingua, institutis, legibus inter se differunt. Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit."
theText = theText & vbCrLf & theText & vbCrLf & theText & vbCrLf
theDoc.Rect.Magnify 0.5, 0.5
theDoc.Rect.Position 151, 198
theDoc.FrameRect
theDoc.Transform.Rotate 45, 302, 396
theDoc.FrameRect
theDoc.FontSize = 24
theDoc.AddText theText
theDoc.Save "c:\mypdfs\doctransform.pdf"

doctransform.pdf


Units Property

Type | Default Value | Read Only | Description
String | "points" | No | The current measurement units.

Notes

This property holds the current measurement units. This property can take any of the following values:

  • points (PostScript Points) - 1/72 of an Inch
  • twips (Twentieths of a Point) - 1/20 of a PostScript Point
  • didots (Didot Points) - 1/72 of a French Royal Inch
  • atapoints (ATA Points) - 1/72.272 of an Inch
  • texpoints (TeX Points) - 1/72.27 of an Inch
  • inpoints (l'Imprimerie Nationale Points) - 0.4 mm
  • picas - 12 PostScript Points
  • ciceros - 12 Didot Points
  • ataciceros - 12 ATA Points
  • texciceros - 12 TeX Points
  • microns - millionths of a metre
  • mm - thousandths of a metre
  • cm - hundredths of a metre
  • m - metres
  • inches
  • feet

There are a variety of methods you can use to change coordinate systems.

Example

See the TopDown property.


VPos Property

Type | Default Value | Read Only | Description
Double | 0.0 | No | The current vertical positioning.

Notes

This property determines the vertical offset of blocks of text - used for bottom alignment, top alignment or middle alignment.

The offset is measured as a proportion of the distance from the top. A value of zero indicates top alignment, a value of one half indicates center aligned text and a value of one indicates bottom aligned text. Intermediate values can be used for intermediate offsets.

To horizontally align text, use the HPos property. To justify text, use the XTextStyle.Justification property.

Example

The following code adds two blocks of text to a document. The first block is bottom-aligned, and the second is top-aligned. Before adding the text, we change the current rectangle and frame it so that you can see how the text is aligned.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96
theDoc.Rect.Magnify 1.0, 0.5
theDoc.Rect.Inset 40, 40
theDoc.FrameRect
theDoc.AddText "Top aligned text..."
theDoc.Rect.Move 0, theDoc.Rect.Height + 80
theDoc.FrameRect
theDoc.VPos = 1.0
theDoc.AddText "Bottom aligned text..."
theDoc.Save "c:\mypdfs\docvpos.pdf"

docvpos.pdf


Width Property

Type | Default Value | Read Only | Description
Double | 1 | No | The current line width.

Notes

The width determines the width of lines drawn using methods like AddLine and FrameRect. The width is measured in the current Units.

The AddLine method creates lines centered on the points you provide. This means that if you draw a horizontal line with a width of ten, the line will extend five points above your start position and five points below it.

The FrameRect method draws lines outside the rectangle you provide. So if you frame a rectangle using a width of ten, the drawn rectangle will extend ten points above, below, to the left and to the right of your specified rectangle. No drawing will fall within the rectangle.

Example

The following code adds two lines to a document. The first line has a width of ten points, and the second has a width of twenty points.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Width = 10
theDoc.AddLine 10, 10, 300, 300
theDoc.Width = 20
theDoc.AddLine 10, 300, 300, 10
theDoc.Save "c:\mypdfs\docwidth.pdf"

docwidth.pdf


HtmlRender Event

This event is fired during HTML rendering.

The HTML render event in this version of ABCpdf has not been implemented.

Syntax

Sub object_HtmlRender(ByVal Stage As String, ByVal Page As Object)

Params
Name | Type | Description
Stage | String | The stage of the render.
Page | Object | The HTML Document being rendered.

Notes

This event is fired during HTML rendering.

During the time that HTML rendering is taking place, progress events are sent out to any event subscribers. This gives a mechanism for tracking progress and for intercepting and modifying or querying pages on the fly.

If the page is obtained from the cache, then events will not be fired.

Note that the amount of work done during a progress event should be kept to a minimum.

Current values for the stage variable are 'get width', 'get height' and 'render'. The first event occurs prior to finding the natural width of the HTML (the width it can occupy without scrolling). The second occurs prior to finding the natural height. The third occurs prior to translation into PDF format.

The page is provided via an IHTMLDocument interface - see Microsoft documentation for details. However, note that while the interface is standard, the behavior may not be identical. For example, element positions may not be available.

If you want to handle HtmlRender events, you must declare your Doc variable explicitly using the WithEvents keyword.

Public WithEvents mDoc As Doc

Please note that WithEvents variables must be module-level variables and can only be placed in forms and other class modules. For further details of the WithEvents keyword, see Microsoft documentation.

Example

None.


Image Object

Allows access to images stored in files or in data.

Images can be added to a document using the Doc.AddImageObject method.

Method | Description
Clear | Clears the image.
SetData | Loads an image from data.
SetFile | Loads an image from a file.
SetMask | Assigns a soft mask to the image.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
BoundingBox | No | The physical bounds of the image (points).
Frame | No | The currently selected frame.
Frame Count | No | The number of frames in the image.
Height | No | The height of the current frame (pixels).
HRes | No | The horizontal resolution of the current frame (DPI).
Indirect | No | Whether the image will be added using indirect mode.
Selection | No | The current selection rectangle.
Type | No | The type of image.
VRes | No | The vertical resolution of the current frame (DPI).
Width | No | The width of the current frame (pixels).


Clear Method

Clears the image.

Syntax

Image.Clear

Params
Name | Type | Description
n/a | n/a | n/a

Notes

Use this method to release resources and return the image to a just-created state.

Example

None.


SetData Method

Loads an image from data.

Syntax

Image.SetData Data

Params
Name | Type | Description
Data | Array of Bytes | The data containing the graphic.

Notes

Loads an image from data. The data is expected to be provided as an array of bytes.

The data can be any of the following types: JPEG, GIF, TIFF, BMP, PNG, EXIF, WMF or EMF.

Different images within the file can be accessed using the Frame property. Different portions of the image can be selected using the Selection property.

Example

Here, we read a TIFF file and present the data to the Image object. We then add the image to our document and then save the PDF.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
Set theImg = Server.CreateObject("ABCpdf14.Image")
theData = ReadData("c:\mypics\mypic.tif")
' ReadData is an external function
theImg.SetData theData
theDoc.Rect.Inset 20, 20
theDoc.AddImageObject theImg, 1
theDoc.Save "c:\mypdfs\imagesetdata.pdf"

imagesetfile.pdf


SetFile Method

Loads an image from a file.

Syntax

Image.SetFile FilePath

Params
Name | Type | Description
FilePath | String | The path to the graphic file.

Notes

Loads an image from a file.

The file can be any of the following types: JPEG, GIF, TIFF, BMP, PNG, EXIF, WMF or EMF.

Different images within the file can be accessed using the Frame property. Different portions of the image can be selected using the Selection property.

Example

Here, we open a TIFF file using the Image object. After we've opened the file, we add the image to our document and then save the PDF.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
Set theImg = Server.CreateObject("ABCpdf14.Image")
theImg.SetFile "c:\mypics\mypic.tif"
theDoc.Rect.Inset 20, 20
theDoc.AddImageObject theImg, False
theDoc.Save "c:\mypdfs\imagesetfile.pdf"

imagesetfile.pdf


SetMask Method

Assigns a soft mask to the image.

Syntax

Image.SetMask Mask, Invert

Params
Name | Type | Description
Mask | XImage | The image containing the soft mask.
Invert | Boolean | Whether to invert the mask.

Notes

Assigns a soft mask or alpha channel. Soft masks are used to assign levels of transparency to an image.

The mask provided will be converted to a grayscale intensity map and may be scaled to ensure that the dimensions of the mask match those of the image. The assigned mask applies to all frames of the current image.

If the Invert parameter is set, then the mask will be inverted - making transparent areas opaque and opaque areas transparent.

Different images within the mask can be accessed using the Frame property. Different portions of the mask can be selected using the Selection property.

Note that transparency is only applied to an Image if the Indirect property is true (which is generally the case).

Example

Here, we read a TIFF file and present the data to the Image object. We then read a mask image and assign that to our Image. Finally, we add the image to our document and then save the PDF.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
Set theImg = Server.CreateObject("ABCpdf14.Image")
Set theMsk = Server.CreateObject("ABCpdf14.Image")
theImg.SetFile "c:\mypics\mypic.tif"
theMsk.SetFile "c:\mypics\mymask.jpg"
theImg.SetMask theMsk, True
theMsk.Clear
theDoc.Color = "0 0 0"
theDoc.FillRect
theDoc.Rect.Inset 20, 20
theDoc.AddImageObject theImg, True
theDoc.Save "c:\mypdfs\imagesetmask.pdf"

Given the following input images.

mypic.tif
mymask.jpg

This is the kind of output you might expect.

imagesetmask.pdf


BoundingBox Property

Type | Default Value | Read Only | Description
XRect | The bounds of the current frame. | Yes | The physical bounds of the image in points.

Notes

This property reflects the physical bounds of the image.

It is more relevant for EPS and PS files, which operate in terms of physical dimensions rather than pixels.

Note that EPS and PS files may have bounds which are not anchored at the origin.

Example

None.


Frame Property

Type | Default Value | Read Only | Description
Long | 1 | No | The currently selected frame.

Notes

Some file formats can contain more than one image. The FrameCount property reflects the number of images.

You can change the currently selected image using the Frame property. As you change the frame, the Width, Height, HRes and VRes properties will change to reflect the dimensions and resolution of the currently selected image. When you add an Image using the Doc.AddImageObject method, the currently selected frame is added.

Example

Here, we open a TIFF file using the Image object. We then scan through each of the images within the file and insert them into a new page of our PDF document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
Set theImg = Server.CreateObject("ABCpdf14.Image")
theImg.SetFile "c:\mypics\multipage.tif"
For i = 1 To theImg.FrameCount
  theImg.Frame = i
  theDoc.Page = theDoc.AddPage()
  theDoc.AddImageObject theImg, False
Next
theDoc.Save "c:\mypdfs\imageframe.pdf"

imageframe.pdf [Page 1]

imageframe.pdf [Page 2]


FrameCount Property

Type | Default Value | Read Only | Description
Long | See description. | Yes | The number of frames in the image.

Notes

TIFF and GIF files may contain more than one image. The FrameCount property reflects the number of images found in the file. You can select different images using the Frame property.

Multi-frame TIFF images are generally used for one of two purposes. Sometimes, multiple copies of the same image are embedded at different sizes to allow previews to be obtained quickly and easily. This type of multi-frame image is generally created for print purposes. Sometimes, multiple pages of a document may be embedded in a TIFF. This type of multi-frame image is generally created by document scanning software or fax software.

Multi-frame GIF images are often called animated GIFs. Each image represents a frame of the animation.

PostScript is a programming language. So a PostScript program may output a different number of pages each time it is run. For this reason, it is not possible to reliably determine the number of pages in a PostScript file until it is actually displayed. As a result, EPS and PS files always have a FrameCount of one no matter how many pages they may display. However, it is reasonably safe to assume that EPS files only ever contain one page of content.

Example

See the Frame property.


Height Property

Type | Default Value | Read Only | Description
Long | See description. | Yes | The height of the current frame (pixels).

Notes

This property reflects the height of the current frame. It is measured in pixels.

Example

None.


HRes Property

Type | Default Value | Read Only | Description
Double | See description. | Yes | The horizontal resolution of the current frame (DPI).

Notes

This property reflects the horizontal resolution of the current frame. It is measured in dots per inch (DPI).

Example

None.


Indirect Property

Type | Default Value | Read Only | Description
Boolean | See description. | Yes | Whether the image will be added using indirect mode.

Notes

Images can be added using indirect mode or pass-through mode.

You can find details of these modes in the Image Handling section of the documentation.

When you add an Image using the Doc.AddImageObject method, it will generally be added using indirect mode.

However, some file types do not support indirect mode and can only be added using pass-through mode. If this is the case, the operation of the Doc.AddImageObject method becomes identical to the Doc.AddImageFile or Doc.AddImageData methods.

The value of this property tells you if the image will be added using indirect mode. It is true for all image types with the exception of EPS and PS.

Example

None.


Selection Property

Type | Default Value | Read Only | Description
XRect | The dimensions of the current frame. | Yes | The current selection rectangle.

Notes

You may wish to add only a portion of an image. By changing the selection rectangle, you can specify different areas to be added.

Note that this property only has an effect on an Image if the Indirect property is true (which is generally the case).

Example

Here, we open a TIFF file using the Image object. We add the entire image to the document and then just a portion of the image using the Selection property.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
Set theImg = Server.CreateObject("ABCpdf14.Image")
theImg.SetFile "c:\mypics\mypic.tif"
theDoc.Rect = theImg.Selection
theDoc.Rect.Magnify 0.5, 0.5
theDoc.Rect.Position 100, 30
theDoc.AddImageObject theImg, False
theImg.Selection.Inset 100, 200
theDoc.Rect = theImg.Selection
theDoc.Rect.Position 170, 400
theDoc.AddImageObject theImg, False
theDoc.Save "c:\mypdfs\imageselect.pdf"

imageselect.pdf


Type Property

Type | Default Value | Read Only | Description
String | See description. | Yes | The type of image.

Notes

The type property reflects the type of image that has been loaded using SetFile or SetData. It can take one of the following values.

  • ""
  • "BMP"
  • "EMF"
  • "EXIF"
  • "GIF"
  • "Icon"
  • "JPEG"
  • "MemoryBMP"
  • "PNG"
  • "TIFF"
  • "WMF"
  • "EPS"
  • "PS"

Example

None.


VRes Property

Type | Default Value | Read Only | Description
Double | See description. | Yes | The vertical resolution of the current frame (DPI).

Notes

This property reflects the vertical resolution of the current frame. It is measured in dots per inch (DPI).

Example

None.


Width Property

Type | Default Value | Read Only | Description
Long | See description. | Yes | The width of the current frame (pixels).

Notes

This property reflects the width of the current frame. It is measured in pixels.

Example

None.


XBookmark Object

The bookmarks associated with this document.

PDF documents typically provide a list of bookmarks for easy navigation between pages. In Acrobat, this navigation structure is available under the Bookmarks tab. The PDF specification refers to this structure as the document outline.

The document outline comprises of a hierarchy of bookmarks. The bookmark at the top of the hierarchy is available via the Doc.Bookmark property. Typically, a bookmark triggers navigation to a particular page, but in some cases, it may trigger a different and more complex type of action.

Every bookmark holds a collection of all its child bookmarks. As with all collections, you can use the Count property to determine the number of items contained, and you can iterate through the collection using the standard methods appropriate to the language you are coding in.

Method | Description
Add | Adds a new bookmark.
Adopt | Adopts a specified bookmark.
Insert | Inserts a new bookmark at a specified location.
Refresh | Refreshes and reloads the document bookmarks.
RemoveAt | Removes the bookmark at the specified location.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
Count | No | The number of bookmarks in the collection.
Item | Yes | Returns a particular bookmark referenced by name or index.
Open | No | Whether the bookmark appears open or closed.
Page | No | The Page ID for the page associated with this bookmark.
Title | No | The bookmark title to be displayed on screen.


Add Method

Adds a new bookmark.

Syntax

Set Bookmark = XBookmark.Add(Title)

Params
Name | Type | Description
Title | String | The title for the bookmark.
Bookmark | XBookmark | The bookmark added.

Notes

Use this method to add a new bookmark.

A new bookmark is created and given the title specified. It is added at the end of the collection, and the newly created bookmark is returned.

Example

None.


Adopt Method

Adopts a specified bookmark.

Syntax

XBookmark.Adopt(Bookmark)

Params
Name | Type | Description
Bookmark | XBookmark | The bookmark to be adopted.

Notes

Use this method to move bookmarks within the bookmark hierarchy.

The bookmark to be adopted is detached from the bookmark hierarchy. Then it is added at the end of the bookmark collection for the current object.

Some Adopt operations are not possible. For example, a child cannot adopt its parent. In these cases, the field structure will be left unchanged.

Example

None.


Insert Method

Inserts a new bookmark at a specified location.

Syntax

Set Bookmark = XBookmark.Insert(Index, Title)

Params
Name | Type | Description
Index | Long | The zero based index at which the bookmark should be inserted.
Title | String | The title for the bookmark.
Bookmark | XBookmark | The bookmark added.

Notes

Use this method to insert a new bookmark at a specified location.

A new bookmark is created and given the title specified. It is added at the specified location, and the newly created bookmark is returned.

If the index is greater than or equal to the number of items in the collection, then the bookmark is appended to the end.

Bookmarks that follow the insertion point move down to accommodate the new bookmark.

Example

None.


Refresh Method

Refreshes and reloads the document bookmarks.

Syntax

XBookmark.Refresh

Params
Name | Type | Description
n/a | n/a | n/a

Notes

Use this method to refresh and reload all children of this bookmark.

When a bookmark is first referenced, the bookmark data from the PDF is cached. This allows a level of optimization which would not otherwise be possible.

However, if you are using the low-level functionality to modify the bookmark structure, the cache will not reflect your changes. In this situation, you can force the bookmarks to be reloaded by calling Refresh.

Example

None.


RemoveAt Method

Removes the bookmark at the specified location.

Syntax

XBookmark.RemoveAt(Index)

Params
Name | Type | Description
Index | Long | The zero based index specifying the bookmark to be removed.

Notes

Use this method to remove the bookmark at the specified location.

The bookmarks that follow the removed bookmark move up to occupy the empty spot.

Example

None.


Count Property

Type | Default Value | Read Only | Description
Long | See description. | Yes | The number of bookmarks in the collection.

Notes

The number of bookmarks in the collection.

As with all collections, you can use the Count property to determine the number of items contained, and you can iterate through the collection using the standard methods appropriate to the language you are coding in.

Example

None.


Item Property

Returns a particular bookmark referenced by name or index.

Syntax

Set Bookmark = XBookmark.Item(Key)

Params
Type | Read Only | Description
XBookmark | Yes | The matching bookmark.
Name | Type | Description
Key | Object | The name or zero-based index of the bookmark.

Notes

Use this property to retrieve a bookmark referenced by full name or zero-based index.

Bookmarks can be referenced by name or by index. The type of the value you pass is used to determine whether you are looking by name or by index.

If you intend to reference an item by index, pass a number. If you intend to reference an item by name, pass a string. In cases where a string is passed but no matching items could be found, an attempt will be made to convert the string to a number and return an item with that index.

Example

None.


Open Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether the bookmark appears open or closed.

Notes

This property determines whether the bookmark appears open or closed.

When a bookmark is open, all its children are visible in a tree below it. When it is closed, its children are hidden. Clients can toggle the state of the bookmark by clicking on it.

This property determines the default state of the bookmark.

Example

None.


Page Property

Type | Default Value | Read Only | Description
Long | 0 | No | The Page ID for the page associated with this bookmark.

Notes

When activated, a bookmark will trigger an action. In most cases, this will be a navigation action resulting in a new page being displayed. The Page ID for the destination page is available via this property.

Occasionally, you may come across bookmarks which have more complicated actions. In these cases, this property will be zero.

Example

None.


Title Property

Type | Default Value | Read Only | Description
String | "" | No | The bookmark title to be displayed on screen.

Notes

This property determines the title of the bookmark.

The title is the text that appears in the bookmarks tab.

Example

None.


XColor Object

This object represents a color. Colors may be expressed in RGB, CMYK or Grayscale.

When first created, the color defaults to RGB black "0 0 0".

Method | Description
none |

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
String | Yes | The color as a delimited string.
Red | No | The red RGB component.
Green | No | The green RGB component.
Blue | No | The blue RGB component.
Gray | No | The gray Grayscale component.
Cyan | No | The cyan CMYK component.
Magenta | No | The magenta CMYK component.
Yellow | No | The yellow CMYK component.
Black | No | The black CMYK component.
Alpha | No | The alpha opacity of the color.
ColorSpace | No | The native color space for the color.


Alpha Property

Type | Default Value | Read Only | Description
Long | 255 | No | The alpha opacity.

Notes

Allows you to get or set the alpha opacity of the color.

Alpha values can range from 0 to 255. Zero indicates fully transparent, and 255 indicates fully opaque.

Example

Here, we create a PDF document showing how different values of alpha result in different levels of transparency.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 20,20
theDoc.FontSize = 300
For i = 1 To 10
  theDoc.Color.Alpha = 255 / i
  theDoc.AddText theDoc.Color.Alpha
  theDoc.Rect.Move 25, -50
Next
theDoc.Save "c:\mypdfs\coloralpha.pdf"

coloralpha.pdf


Black Property

Type | Default Value | Read Only | Description
Long | 100 | No | The black component.

Notes

Allows you to get or set the black level.

CMYK color components can range from 0 to 100.

Querying this property does not change the ColorSpace. This means you can obtain approximate CMYK values for RGB or Grayscale colors.

However, if you change the value of this property, the color will automatically be converted to CMYK.

Example

None.


Blue Property

Type | Default Value | Read Only | Description
Long | 0 | No | The blue component.

Notes

Allows you to get or set the blue component.

RGB color components can range from 0 to 255.

Querying this property does not change the ColorSpace. This means you can obtain approximate RGB values for CMYK or Grayscale colors.

However, if you change the value of this property, the color will automatically be converted to RGB.

Example

None.


ColorSpace Property

Type | Default Value | Read Only | Description
Long | 3 | No | The native color space for the color.

Notes

Allows you to get or set the current color space for the color.

This property is defined in terms of the number of components in the color space. RGB colors have three components. CMYK colors have four components. Grayscale colors have only one component. So the values you can use are one, three or four to indicate Grayscale, RGB or CMYK respectively.

If you change the value of this property, the current color will automatically be converted to the indicated color space. However, different color spaces have fundamentally different properties, and color conversions can only ever be approximate.

Example

None.


Cyan Property

Type | Default Value | Read Only | Description
Long | 0 | No | The cyan component.

Notes

Allows you to get or set the cyan level.

CMYK color components can range from 0 to 100.

Querying this property does not change the ColorSpace. This means you can obtain approximate CMYK values for RGB or Grayscale colors.

However, if you change the value of this property, the color will automatically be converted to CMYK.

Example

None.


Gray Property

Type | Default Value | Read Only | Description
Long | 0 | No | The gray component.

Notes

Allows you to get or set the gray level.

Grayscale levels can range from 0 (black) to 255 (white).

Querying this property does not change the ColorSpace. This means you can obtain approximate Grayscale values for RGB or CMYK colors.

However, if you change the value of this property, the color will automatically be converted to Grayscale.

This property can also be used to specify levels for spot colorants. Levels can range from 0 (0% intensity) to 255 (100% intensity). See the AddColorSpaceSpot method for an example.

Example

None.


Green Property

Type | Default Value | Read Only | Description
Long | 0 | No | The green component.

Notes

Allows you to get or set the green component.

RGB color components can range from 0 to 255.

Querying this property does not change the ColorSpace. This means you can obtain approximate RGB values for CMYK or Grayscale colors.

However, if you change the value of this property, the color will automatically be converted to RGB.

Example

None.


Magenta Property

Type | Default Value | Read Only | Description
Long | 0 | No | The magenta component.

Notes

Allows you to get or set the magenta level.

CMYK color components can range from 0 to 100.

Querying this property does not change the ColorSpace. This means you can obtain approximate CMYK values for RGB or Grayscale colors.

However, if you change the value of this property, the color will automatically be converted to CMYK.

Example

None.


Red Property

Type | Default Value | Read Only | Description
Long | 0 | No | The red component.

Notes

Allows you to get or set the red component.

RGB color components can range from 0 to 255.

Querying this property does not change the ColorSpace. This means you can obtain approximate RGB values for CMYK or Grayscale colors.

However, if you change the value of this property, the color will automatically be converted to RGB.

Example

None.


String Property

Type | Default Value | Read Only | Description
String | "0 0 0" | No | The color as a string.

Notes

Allows you access to the color as a string.

If the color is in the RGB color space, then the string contains three values representing the Red, Green and Blue levels. For example, "100 150 200".

If the color is in the CMYK color space, then the string contains four values representing the Cyan, Magenta, Yellow and Black levels. For example, "30 60 90 10".

If the color is in the Grayscale color space, then the string contains one value representing the Gray level. For example, "150".

You can use the ColorSpace property to find the current color space for the color.

Alpha values can be indicated by prepending an 'a' to an extra component. For example, "30 60 90 a120" would indicate an RGB value with an alpha value of 120.

Example

None.


Yellow Property

Type | Default Value | Read Only | Description
Long | 0 | No | The yellow component.

Notes

Allows you to get or set the yellow level.

CMYK color components can range from 0 to 100.

Querying this property does not change the ColorSpace. This means you can obtain approximate CMYK values for RGB or Grayscale colors.

However, if you change the value of this property, the color will automatically be converted to CMYK.

Example

None.


XEncryption Object

Represents the current encryption settings.

By default, encryption is not applied unless you explicitly specify it using the Type property.

Method | Description
SetCryptMethods | Sets the crypt methods for encryption levels of type 4 or above.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
CanAssemble | No | Whether a user can assemble the document.
CanChange | No | Whether a user can modify the document.
CanCopy | No | Whether a user can copy from the document.
CanEdit | No | Whether a user can edit the document.
CanExtract | No | Whether a user can extract from the document.
CanFillForms | No | Whether a user can fill forms in the document.
CanPrint | No | Whether a user can print the document.
CanPrintHi | No | Whether a user can print a high-resolution copy of the document.
EncryptMetadata | No | Whether to encrypt the document metadata for encryption levels of type 4 or above.
OwnerPassword | No | The owner password.
Password | No | The user password.
StreamCryptionMethod | No | The crypt method for streams for encryption levels of type 4 or above.
StringCryptionMethod | No | The crypt method for strings for encryption levels of type 4 or above.
Type | No | The level of encryption to use.


SetCryptMethods Method

Sets the crypt methods for encryption levels of type 4 or above.

Syntax

XEncryption.SetCryptMethods(StringMethod [, StreamMethod])

Params
Name | Type | Description
StringMethod | Long | The crypt method for strings. It is also for streams if StreamMethod is missing.
StreamMethod | Long | The crypt method for streams (optional).

Notes

The default crypt method for Type 4 is V2, which uses RC4 algorithm. Crypt method settings are in effect only when Type is 4 or higher.

The StringMethod and StreamMethod parameters can take any of the following values:

  • 0 [None] – (Not supported)
  • 1 [Identity] – No encryption
  • 2 [V2] – Uses the RC4 algorithm
  • 3 [AESV2] – Uses the AES algorithm with 128-bit encryption keys
  • 4 [AESV3] – Uses the AES algorithm with 256-bit encryption keys

Adobe Reader does not support using more than one crypt method per document (i.e. stringMethod≠streamMethod). However, Identity is degenerate and can be used with other crypt methods.

Example

Here we use 128-bit AES encryption.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 96
theDoc.AddText "Hello World!"
theDoc.Encryption.Type = 4
theDoc.Encryption.SetCryptMethods 3
theDoc.Save "c:\mypdfs\docencrypt.pdf"


CanAssemble Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether a user can assemble the document.

Notes

This property determines whether people who supply the user password can assemble the document.

Assembling is defined as inserting, rotating or deleting pages; creating bookmarks or thumbnail images. This is allowed even if the CanChange property is set to false.

This property is only applied if the Type is set to 2 or higher.

Example

See the Doc.Encryption property.


CanChange Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether a user can modify the document.

Notes

This property determines whether people who supply the user password can change the document.

Changing is defined as modifying the document in any way other than those controlled by the CanEdit, CanFillForms or CanAssemble properties.

This property is only applied if the Type is set to 1 or higher.

Example

See the Doc.Encryption property.


CanCopy Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether a user can copy from the document.

Notes

This property determines whether people who supply the user password can copy from the document.

Copying is defined as copying, or otherwise extracting text and graphics from the document. If the Type is set to 3 or higher and the CanExtract property is set to true, then extracting text and graphics in support of accessibility to disabled users is allowed.

This property is only applied if the Type is set to 1 or higher.

Example

See the Doc.Encryption property.


CanEdit Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether a user can edit the document.

Notes

This property determines whether people who supply the user password can edit the document.

Editing is defined as adding or modifying text annotations, filling in interactive form fields, and if the CanChange property is set, creating or modifying interactive form fields including signature fields.

This property is only applied if the Type is set to 1 or higher.

Example

See the Doc.Encryption property.


CanExtract Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether a user can extract from the document.

Notes

This property determines whether people who supply the user password can extract from the document.

Extracting is defined as extracting text or graphics in support of accessibility to disabled users or for other purposes.

This property is only applied if the Type is set to 2 or higher.

Example

See the Doc.Encryption property.


CanFillForms Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether a user can fill forms in the document.

Notes

This property determines whether people who supply the user password can fill forms in the document.

Filling forms is defined as filling in existing interactive form fields including signature fields. This is allowed even if the CanEdit property is set to false.

This property is only applied if the Type is set to 2 or higher.

Example

See the Doc.Encryption property.


CanPrint Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether a user can print the document.

Notes

This property determines whether people who supply the user password can print the document.

Printing may not be available at the highest quality level if the CanPrintHi property is set to false.

This property is only applied if the Type is set to 1 or higher.

Example

See the Doc.Encryption property.


CanPrintHi Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether a user can print a high-resolution copy of the document.

Notes

This property determines whether people who supply the user password can print a high-resolution copy of the document.

When this property is set to false and the CanPrint property is set to true, printing is limited to a lower-quality representation of the document.

This property is only applied if the Type is set to 2 or higher.

Example

See the Doc.Encryption property.


EncryptMetadata Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether to encrypt the document metadata for encryption levels of type 4 or above.

Notes

This property determines whether the document metadata is encrypted. It is in effect only when Type is 4 or higher.

The document metadata can be saved unencrypted so that tools that do not support PDF encryption can still index/process the document using the metadata.

Example

None.


OwnerPassword Property

Type | Default Value | Read Only | Description
String | "" | No | The owner password.

Notes

This property determines or reflects the owner password for the document.

You can open and view an encrypted document with either the user or the owner password. However, only the owner has full control over the document. The user may have a restricted set of permissions.

For more information about the user and owner passwords, see the Doc.Encryption property.

Example

See the Doc.Encryption property.


Password Property

Type | Default Value | Read Only | Description
String | "" | No | The user password.

Notes

This property determines or reflects the user password for the document.

You can open and view an encrypted document with either the user or the owner password. However, only the owner has full control over the document. The user may have a restricted set of permissions.

Typically, the user password is left blank to allow all users to view the document.

For more information about the user and owner passwords, see the Doc.Encryption property.

Example

See the Doc.Encryption property.


StreamCryptionMethod Property

Type | Default Value | Read Only | Description
Long | 2 | Yes | The crypt method for streams for encryption levels of type 4 or above.

Notes

This property returns the crypt methods for streams. Crypt method settings are in effect only when Type is 4 or higher.

To change this value, use SetCryptMethods.

Example

None.


StringCryptionMethod Property

Type | Default Value | Read Only | Description
Long | 2 | Yes | The crypt method for strings for encryption levels of type 4 or above.

Notes

This property returns the crypt methods for strings. Crypt method settings are in effect only when Type is 4 or higher.

To change this value, use SetCryptMethods.

Example

None.


Type Property

Type | Default Value | Read Only | Description
Long | 0 | No | The level of encryption to use.

Notes

This property determines the level of encryption used when saving the document. The default value of zero indicates that no encryption will be used.

Higher levels of encryption provide higher levels of security and more flexibility in applying permissions but also require more recent versions of Adobe Acrobat to view. The table below details valid combinations.

Type Value | 0 | 1 | 2 | 4 | 5
Acrobat Version Required | Any | 2.0 | 5.0 | 7.0 | 9.0
Encryption Key Length (bits) | None | 40 | 128 | 128 | 256
Encryption Algorithm | Identity | RC4 | RC4 | Identity/RC4/AES | Identity/AES
Can Assemble |  |  |  |  |
Can Change |  |  |  |  |
Can Copy |  |  |  |  |
Can Edit |  |  |  |  |
Can Extract |  |  |  |  |
Can Fill Forms |  |  |  |  |
Can Print |  |  |  |  |
Can Print Hi |  |  |  |  |

Example

See the Doc.Encryption property.


XField Object

Represents a field in a document.

The PDF specification makes a distinction between a field (in terms of a named value) and the visible appearance of the field on the document.

So not every field has a visible appearance. Those that do can be located using the Page and Rect properties. The value of the field can be modified using the Value property.

Fields exist within a hierarchy. Fields have children and their children can have children in turn. You can drill down through the hierarchy using the Kids property.

Alternatively, given a fully qualified name, you can use the XForm-level methods to obtain references directly.

Method | Description
Focus | Prepares document for drawing at the field location.
Stamp | Stamps this field into the document.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
Format | No | The field format.
ID | No | The Object ID associated with this field.
Kids | No | All children of this field.
MultiSelect | No | Whether the field supports multiple selections.
Name | No | The fully qualified field name.
Options | No | The field options.
Page | No | The ID of the page on which the field appears.
PartialName | No | The partial field name.
Rect | No | The location and size of the field.
Type | No | The field type.
Value | Yes | The field value.


Focus Method

Prepares document for drawing at the field location.

Syntax

XForm.Focus

Params
Name | Type | Description
n/a | n/a | n/a

Notes

Use this method to focus on the field.

This prepares the document for drawing at the field location.

The Doc.Page, Doc.Rect and Doc.Transform may all be changed as a result of calling this method.

Example

None.


Stamp Method

Stamps this field into the document.

Syntax

XField.Stamp

Params
Name | Type | Description
n/a | n/a | n/a

Notes

Use this method to permanently stamp a field into the document.

When this method is called, the field appearance is stamped permanently into the document and the field is deleted.

The field becomes a new layer on the page (see Doc.LayerCount) so you may wish to call Doc.Flatten on the affected page.

You can use the XForm.Stamp method to stamp all fields into the document.

Example

None.


Format Property

Type | Default Value | Read Only | Description
String | See description. | Yes | The field format.

Notes

The format for this field.

The PDF specification does not define how fields should be formatted. Acrobat uses a set of standard JavaScripts to perform field formatting.

This property reflects the JavaScript formatting function which is being used and the values which are being passed to it. A typical value might be:

AFNumber_Format(2, 3, 0, 0, "", true);

This defines a number format with two decimal places. For a precise understanding of the purposes of the other parameters, you will need to see the JavaScripts which come installed with Acrobat.

Other typical formatting functions are AFPercent_Format, AFSpecial_Format, AFDate_Format and AFTime_Format. Again, for full details, you should see the JavaScripts which come installed with Acrobat.

Example

None.


ID Property

Type | Default Value | Read Only | Description
Long | See description. | Yes | The Object ID associated with this field.

Notes

The XField object is an abstraction of the underlying objects defined in the document.

As such, the Object ID may refer to an Annotation Widget, a Field, or a hybrid Widget Field as defined in the PDF specification.

Example

None.


Kids Property

Type | Default Value | Read Only | Description
XField Collection | See description. | Yes | All children of this field.

Notes

This property holds the children of this field.

Items in this collection can be referenced by partial field name or by zero-based index. The type of the value you pass is used to determine whether you are looking by name or by index.

So if you intend to reference an item by index, pass a number. If you intend to reference an item by name, pass a string. In cases where a string is passed but no matching items could be found, an attempt will be made to convert the string to a number and return an item with that index.

As with all collections, you can use the Count property to determine the number of items contained, and you can iterate through the collection using the standard methods appropriate to the language you are coding in.

Example

None.


MultiSelect Property

Type | Default Value | Read Only | Description
Boolean | See description. | Yes | Whether the field supports multiple selections.

Notes

This property allows you to determine whether the the field supports multiple values.

Most fields have a single value. A text box contains one item of text. A radio button group has one selected button. A checkbox can be checked or clear.

However, some kinds of fields can hold multiple values. For example, a list box can be used to select multiple items. If this is the case, then the MultiSelect property will be set to true.

If the field supports multiple selection, then the Value of the field will be a comma-delimited list of the items which are selected.

Example

None.


Name Property

Type | Default Value | Read Only | Description
String | See description. | Yes | The fully qualified field name.

Notes

The fully qualified field name for this field.

See the XForm object for details of how fully qualified names are constructed.

Example

None.


Options Property

Type | Default Value | Read Only | Description
Array of Strings | See description. | Yes | The field options.

Notes

The options available for the value of this field.

Typically, you assign a value using the Value property. Some fields such as Text fields will accept any value. Others such as Checkboxes and List Boxes accept only a limited range of options. The field options tell you what options are available for a particular field.

The unmarked state of a Checkbox or Radio Button is always "Off". The marked state varies and is available via item zero of this property.

The set of options for a Combo Box or List Box can be obtained directly via this property.

Pushbuttons, Signatures and Text fields do not have options.

Example

None.


Page Property

Type | Default Value | Read Only | Description
Long | See description. | Yes | The ID of the page on which the field appears.

Notes

This property reflects the ID of the page on which this field is located.

This value may be zero if the field does not have a visible appearance.

Example

None.


PartialName Property

Type | Default Value | Read Only | Description
String | See description. | Yes | The partial field name.

Notes

The partial name for this field.

See the XForm object for details of how partial and fully qualified names are related.

Example

None.


Rect Property

Type | Default Value | Read Only | Description
XRect | See description. | Yes | The location and size of the field.

Notes

This property reflects the position and area of the field on the page.

This rectangle may be empty if the field does not have a visible appearance.

Example

None.


Type Property

Type | Default Value | Read Only | Description
String | See description. | Yes | The field type.

Notes

The field type.

The following field types are available:

  • "Pushbutton"
  • "Checkbox"
  • "Radio"
  • "Text"
  • "List"
  • "Combo"
  • "Signature"
  • "Unknown"

More details of these field types can be found in the Section 8.6.3 of the Adobe PDF Specification.

Example

None.


Value Property

Type | Default Value | Read Only | Description
String | "" | No | The field value.

Notes

This property allows you access to the value of the field.

You may wish to assign or query the form field value using this property.

Text fields have a free-text value.

Checkboxes and Radio Buttons have a value which is either "Off" or the on-state of the control as specified in the Options.

Combo Boxes and List Boxes have values restricted to a set of selections as specified in the Options property.

Pushbuttons and Signatures do not have a value.

Common Operations.

Set a checkbox:

theField.Value = theField.Options(0)

Clear a checkbox:

theField.Value = "Off"

Set the fifth Radio Button in a group:

theField.Value = theField.Options(4)

Multiline Form Field Tip.

When inserting carriage returns into multiline form fields, use carriage returns (\r) only.

Using line feeds (\n) or a carriage return linefeed combination (\r\n) is less compatible with older versions of Acrobat.

Example

None.


XForm Object

Represents the form and fields associated with this document.

The PDF specification makes a distinction between a field (in terms of a named value) and the visible appearance of the field on the document.

In general, one field will have one visible appearance on the document. However, it is possible for a field to have multiple or, indeed, no appearances on the document.

For example, a Radio Button group encapsulates one value and is represented by one field. However, each radio button has a separate appearance on the document. So one Radio Button field is likely to have many appearances.

For this reason, fields exist within a hierarchy. Each field may or may not have a visible appearance. Each field may or may not have children. These children may be fields themselves and again may have their own children.

Fields are generally referenced by fully qualified names. A full name describes a path down through the field hierarchy - using periods as delimiters - to a specific field object. For example, the name 'person.address.city' would reference a field with a partial field name called 'city' which has a parent called 'address' which has a parent at the top level called 'person'. You can resolve a fully qualified name using the Item property.

Once a field has been obtained, you can query or change its values. If you wish to convert the fields into a permanent part of the document, you can use the Stamp method to permanently emboss them.

Method | Description
Refresh | Refreshes and reloads the document fields.
Stamp | Stamps all fields into the document.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
Fields | No | All top-level fields in the form.
FormatFields | No | Whether values should be formatted before insertion into fields.
GenerateAppearances | No | Whether field appearances should be pre-generated.
Item | Yes | Returns a particular field referenced by full name.
NeedAppearances | No | Whether the viewer should automatically regenerate field appearances.


Refresh Method

Refreshes and reloads the document fields.

Syntax

XForm.Refresh

Params
Name | Type | Description
n/a | n/a | n/a

Notes

Use this method to refresh and reload the document fields.

When the form is first requested, field data is cached. This allows a level of optimization which would not otherwise be possible.

However, if you are using the low-level functionality to modify the field structure, the cache will not reflect your changes. In this situation, you can force the fields to be reloaded by calling Refresh.

Example

None.


Stamp Method

Stamps all fields into the document.

Syntax

XForm.Stamp

Params
Name | Type | Description
n/a | n/a | n/a

Notes

Use this method to permanently stamp all fields into the document.

When this method is called, all field appearances are stamped permanently into the document and the fields are deleted.

Each field becomes a new layer on the page (see Doc.LayerCount) so you may wish to call Doc.Flatten on any affected pages.

You can use the XField.Stamp method to stamp individual fields into the document.

Example

None.


Fields Property

Type | Default Value | Read Only | Description
XField Collection | See description. | Yes | All top-level fields in the form.

Notes

The collection of all top-level fields in the form.

Items in this collection can be referenced by partial field name or by zero-based index. The type of the value you pass is used to determine whether you are looking by name or by index.

So if you intend to reference an item by index, pass a number. If you intend to reference an item by name, pass a string. In cases where a string is passed but no matching items could be found, an attempt will be made to convert the string to a number and return an item with that index.

As with all collections, you can use the Count property to determine the number of items contained, and you can iterate through the collection using the standard methods appropriate to the language you are coding in.

Example

None.


FormatFields Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether values should be formatted before insertion into fields.

Notes

This property determines whether values should be formatted before insertion.

Acrobat uses JavaScript to implement number and date formats. Although this is something which is part of Acrobat rather than of the PDF specification, you can ask ABCpdf to adhere to these formatting scripts.

When this property is set to true, ABCpdf will detect these standard scripts and generate appearances conforming with them.

It is unlikely you will want to change the value of this property.

Example

None.


GenerateAppearances Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether field appearances should be pre-generated.

Notes

This property determines whether field appearances are pre-generated.

Many PDF viewing applications are unable to generate field appearances dynamically. This means that they are unable to display fields given the field and the value of that field. Instead, they require the appearance of the field to be pre-generated.

A new appearance will only be generated when it is required. Typically, this is when the value of a field changes.

It is unlikely you will want to change the value of this property.

Example

None.


Item Property

Returns a particular field referenced by full name.

Syntax

Set Field = XForm.Item(Name)

Params
Type | Read Only | Description
XField | Yes | The matching field.
Name | Type | Description
Name | String | The fully qualified name of the field.

Notes

Use this method to retrieve a field referenced by fully qualified name.

See the XForm object for details of how fully qualified names are constructed.

Example

None.


NeedAppearances Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether the viewer should automatically regenerate field appearances.

Notes

This property determines whether the NeedAppearances flag in the PDF is set when field values are changed.

The NeedAppearances flag signals to the viewing application that field appearances should be automatically generated rather than using the appearance embedded in the PDF.

It is generally best to allow the viewing application to generate its own appearances and use the pre-generated ones as a fallback.

It is unlikely you will want to change the value of this property unless you want to generate your own appearance streams.

Example

None.


XHtmlOptions Object

Represents the current HTML rendering settings.

The properties of this object may be used to control the way that the Doc.AddImageUrl and Doc.AddImageHtml methods work.

The methods of this object operate on objects added using the the Doc.AddImageUrl and Doc.AddImageHtml methods. Some operations change the document. Others provide information about the content which has been added.

Since ABCpdf version 8 HTML documents can be imported using different HTML engines. The current supported ones are the MSHTML engine (used in Microsoft Internet Explorer) and a modified version of Mozilla Firefox's Gecko engine tailored to work with ABCpdf. Different engines interpret HTML documents in different ways and support a different set of HTML options, please see the Engine property for details.

Method | Description
GetScriptReturn | Retrieves the client side onload script return value.
GetTagIDs | Gets an array of the HTML IDs of tagged visible items.
GetTagRects | Gets an array of the locations of tagged visible items.
LinkPages | Converts external links to internal links wherever possible.
PageCacheClear | Clears the HTML page cache.
PageCachePurge | Purges the HTML page cache.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
Engine | No | The engine to use for HTML import operations.
AddForms | No | Whether form fields should be live.
AddLinks | No | Whether hyperlinks should be live.
AddMovies | No | Whether active content such as movies should be added.
AddTags | No | Whether location of certain tags should be noted.
AutoTruncate | No | Whether to automatically clip redundant content at the end of the page.
BrowserWidth | No | The width of the virtual browser in pixels.
ContentCount | No | The minimum number of content items required for a page to be valid.
DoMarkup | No | Whether HTML pages are marked up before conversion to PDF.
FireShieldEnabled | No | Whether FireShield should be enabled.
FontEmbed | No | Whether fonts should be embedded rather than referenced.
FontProtection | No | Whether fonts should be protected.
FontSubstitute | No | Whether font substitution should be used to reduce file size.
HideBackground | No | Whether to hide the background color of a page.
HostWebBrowser | No | Whether to host a WebBrowser control.
HttpAdditionalHeaders | No | Additional HTTP headers to send in the request.
ImageQuality | No | The quality of compression acceptable for continuous tone images such as JPEGs.
LogonName | No | A user name to be used for authentication.
LogonPassword | No | A password to be used for authentication.
MakeFieldNamesUnique | No | Whether field names should be changed to make them unique.
MaxAtomicImageSize | No | The maximum size at which an image may be regarded as atomic.
Media | No | The CSS media type to use.
NoCookie | No | Whether to disable automatic cookies.
OnLoadScript | No | A script to be run after the page is loaded.
PageCacheEnabled | No | Whether the page cache should be searched before rendering the page.
PageCacheExpiry | No | The length of time that pages can be held in the cache (ms).
PageCacheSize | No | The number of pages that can be held in the cache.
Paged | No | Whether content should be rendered in multipaged format.
PageLoadMethod | No | The method for loading URI/HTML.
ReloadPage | No | Whether to reload page.
RepaintDelay | No | Minimum time to wait for the page to finish animation (ms).
RepaintTimeout | No | Maximum time to wait for the page to finish animation (ms).
RequestMethod | No | The request method for URL.
RetryCount | No | The number of times a page should be retried if unavailable or invalid.
TargetLinks | No | Whether hyperlinks should be allowed to open new windows.
Timeout | No | The maximum amount of time allowed for obtaining a page (ms).
TransferModule | No | The module for obtaining URI/HTML data.
UseActiveX | No | Whether to enable ActiveX.
UseJava | No | Whether to enable Java.
UseNoCache | No | Whether any proxy servers should re-request items of content.
UseResync | No | Whether all items of content should be re-downloaded.
UseScript | No | Whether to enable JavaScript and VBScript.
UseTheme | No | Whether to use theme or not.
UseVideo | No | Whether to enable video.


GetScriptReturn Method

Retrieves the client side onload script return value.

Syntax

Value = XHtmlOptions.GetScriptReturn(ID)

Params
Name | Type | Description
ID | Long | The Object ID of the web page to be accessed.
Value | String | The return value.

Notes

Use this method to retrieve the client side onload script return value.

The ID should be obtained from a call to Doc.AddImageUrl or Doc.AddImageHtml.

See the OnLoadScript property for further details.

Example

None.


GetTagIDs Method

Gets an array of the HTML IDs of tagged visible items.

Syntax

IDs = XHtmlOptions.GetTagIDs(ID)

Params
Name | Type | Description
ID | Long | The Object ID of the object.
IDs | Array of Strings | The IDs of tagged visible HTML objects.

Notes

Use this method to retrieve the HTML IDs of tagged visible items.

To use this method, you need to enable the tagging functionality. See the AddTags property for details.

This method takes an ID obtained from a call to Doc.AddImageUrl, Doc.AddImageHtml or Doc.AddImageToChain and returns the IDs of any items which are visible on the PDF page as a result of that call.

For example, the ID associated with the following paragraph is "p1".

<p id="p1" style="abcpdf-tag-visible: true">Gallia est omnis divisa in partes tres.<p>

The IDs may be repeated if the objects are split over more than one area.

The IDs match up directly on a one-to-one basis with the XRects returned by the GetTagRects method.

Example

See the GetTagRects method.


GetTagRects Method

Gets an array of the locations of tagged visible items.

Syntax

Rects = XHtmlOptions.GetTagRects(ID)

Params
Name | Type | Description
ID | Long | The Object ID of the object.
Rects | Array of XRects | The location of tagged visible HTML objects.

Notes

Use this method to retrieve the locations of tagged visible items.

To use this method, you need to enable the tagging functionality. See the AddTags property for details.

This method takes an ID obtained from a call to Doc.AddImageUrl, Doc.AddImageHtml or Doc.AddImageToChain and returns the locations of any items which are visible on the PDF page as a result of that call.

The locations match up directly on a one-to-one basis with the IDs returned by the GetTagIDs method.

Example

The following example shows the effect that this parameter has on HTML rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 100, 100
theDoc.Rect.Top = 700
' Tag elements with style 'abcpdf-tag-visible' 'true'
theDoc.HtmlOptions.AddTags = True
id = theDoc.AddImageHtml("<FONT id=""p1"" style=""abcpdf-tag-visible: true; font-size: 72pt"">Gallia est omnis divisa in partes tres.</FONT>")
' Frame location of the tagged element
tagRects = theDoc.HtmlOptions.GetTagRects(id)
For Each theRect in tagRects
  theDoc.Rect.String = theRect.String
  theDoc.FrameRect
Next
' Output tag ID
tagIds = theDoc.HtmlOptions.GetTagIDs(id)
theDoc.Rect.String = theDoc.MediaBox.String
theDoc.Rect.Inset 20, 20
theDoc.FontSize = 64
theDoc.Color.String = "255 0 0"
theDoc.AddText "Tag ID """ + tagIds(0) +""":"
' Save the document
theDoc.Save "c:\mypdfs\HtmlOptionsGetTagRects.pdf"

HtmlOptionsGetTagRects.pdf


LinkPages Method

Converts external links to internal links wherever possible.

Syntax

XHtmlOptions.LinkPages

Params
Name | Type | Description
n/a | n/a | n/a

Notes

This method scans the entire document converting external links to internal links wherever possible.

By default, links in rendered HTML are preserved as is. This means that links in a web page link to external URLs. When you click on them, a browser window will be launched and the original target of the link displayed.

In some situations, you may wish to resolve links within the document so that they take you between pages in the PDF rather than launching an external browser window.

For example, you might add a number of web pages which contain links to each other. Rather than linking to the pages on the original web site, you might like to resolve the links so that they point at at the pages as they now appear in the PDF.

Similarly, if you use named destinations (HTML fragments) with links within the document, you will may wish to use this method to convert them from external links to internal ones.

Example

This example shows how to import an HTML page which uses named destinations.

We first create a Doc object and inset the edges a little so that the HTML will appear in the middle of the page. We assign the appropriate HTML options so that links will be rendered live.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 18, 18
theDoc.HtmlOptions.AddLinks = True

We add the pages to the document.

theURL = "http://www.websupergoo.com/support.htm"
theID = theDoc.AddImageUrl(theURL)
Do
  If Not theDoc.Chainable(theID) Then Exit Do
  theDoc.Page = theDoc.AddPage()
  theID = theDoc.AddImageToChain(theID)
Loop

The URL we've referenced makes extensive use of named destinations. We want these named destination links to take us between pages on the PDF rather than taking us to the original URL.

After adding the pages, we can flatten them. We can't do this until after the pages have been added because flattening will invalidate our previous ID and break the chain.

theDoc.HtmlOptions.LinkPages
For i = 1 To theDoc.PageCount
  theDoc.PageNumber = i
  theDoc.Flatten
Next

Finally, we save.

theDoc.Save "c:\mypdfs\linkpages.pdf"

We get the following output. The links work - where possible - within the PDF.

linkpages.pdf [Page 1]
linkpages.pdf [Page 2]


PageCacheClear Method

Clears the HTML page cache.

Syntax

XHtmlOptions.PageCacheClear

Params
Name | Type | Description
n/a | n/a | n/a

Notes

ABCpdf holds a cache of recently requested URLs, and it's only after five minutes or so that these pages expire from the cache.

This results in a considerable degree of optimization for many common operations.

You can clear the cache of all pages by calling this method.

Example

None.


PageCachePurge Method

Purges the HTML page cache.

Syntax

XHtmlOptions.PageCachePurge

Params
Name | Type | Description
n/a | n/a | n/a

Notes

ABCpdf holds a cache of recently requested URLs, and it's only after five minutes or so that these pages expire from the cache.

This results in a considerable degree of optimization for many common operations.

You can clear the cache of all expired pages by calling this method.

Example

None.


Engine Property

Type | Default Value | Read Only | Description
Long | See default below. | No | The engine to use for HTML import operations.

Notes

The Engine property can take any of the following values:

  • 0 - MSHtml
  • 1 - Gecko
  • 2 - ABCChrome 65
  • 3 - ABCChrome 86
  • 4 - WebKit
  • 5 - ABCChrome 117
  • 6 - ABCChrome 123 (default)

This property specifies which HTML engine to use for when importing HTML pages. ABCpdf can use different HTML engines to import HTML for PDF rendering.

Each HTML engine supports a different set of HtmlOptions and has different characteristics.

MSHtml

Characteristics

Due to differences in paradigms and engines' working internals, there are things to note when using the MSHTML engine to render HTML documents:

  • The Screen style sheets are used during the rendering process.
  • Page heights can vary across different pages. Segments of the HTML document are composed dynamically to fit the target rectangle as accurately as possible during each call to Doc.AddImageToChain. This means the target rectangle will be filled with more contents for larger target rectangles instead of scaled to fit.
  • For definite control of HTTP requests, you should set TransferModule to a non-default value.

Supported methods

  • GetScriptReturn
  • GetTagIDs
  • GetTagRects
  • LinkPages
  • PageCacheClear
  • PageCachePurge

Supported options

  • AddForms
  • AddLinks
  • AddMovies
  • AddTags
  • AutoTruncate
  • BrowserWidth
  • ContentCount
  • DoMarkup
  • FontEmbed
  • FontProtection
  • FontSubstitute
  • HideBackground
  • HostWebBrowser
  • HttpAdditionalHeaders
  • ImageQuality
  • LogonName
  • LogonPassword
  • MakeFieldNamesUnique
  • MaxAtomicImageSize
  • NoCookie
  • OnLoadScript
  • PageCacheEnabled
  • PageCacheExpiry
  • PageCacheSize
  • Paged
  • PageLoadMethod
  • ReloadPage
  • RequestMethod
  • RetryCount
  • TargetLinks
  • Timeout
  • TransferModule
  • UseActiveX
  • UseJava
  • UseNoCache
  • UseResync
  • UseScript
  • UseTheme
  • UseVideo

Gecko

Characteristics

  • The Gecko engine is a component indepdendent on other parts of the Operating System. The engine will not be affected even if you upgrade your Internet Explorer or another local Firefox installation.
  • Supports a wide range of the upcoming HTML5 and CSS3 standards.
  • Supports the majority of the SVG Full profile. SVG graphics embedded inside Web pages convert natively to PDF primitives. Alternatively, you can specify the a SVG file's location in Doc.AddImageUrl or feed a string of SVG contents to Doc.AddImageHtml to have it converted to PDF using the Gecko engine.
  • Supports XML pages with XSLT and MathML.
  • You can specify which set of stylesheets to use (Print/Screen) through the use of the Media property.
  • In large tables that span across pages, thead and tfoot elements are repeated across different pages properly.
  • The rendered HTML will always fill the entire current rectangle. After the initial call to Doc.AddImageUrl or Doc.AddImageHtml, the page height will be fixed at that point. Subsequent pages rendered using Doc.AddImageToChain will be automatically scaled (instead of having the contents reflowed) to fit in the current rectangle as much as possible.
  • ActiveX components are not supported.
  • The Paged property is always assumed to be true.
  • The Gecko engine does not use Page caching. This means that your rendered PDF is never stored in a memory cache.
  • On the other hand, Web caching is used to store contents downloaded over the Internet and is configurable using with the UseNoCache property.
  • JavaScript in OnLoadScript cannot directly modify the document object. For example, document.write("hello world"); would not work. Most of the time you can work around to get your desired effect by indirectly modifying elements on the page, such as document.body.innerHTML = "hello world";
  • The use of OnLoadScript does not require UseScript. You are free to use JavaScript to customize the page without allowing JavaScript execution in the HTML.

Supported methods

  • GetScriptReturn
  • GetTagIDs
  • GetTagRects
  • LinkPages

Supported options

  • AddForms
  • AddLinks
  • AddMovies (Flash only)
  • AddTags
  • BrowserWidth
  • FontEmbed
  • FontSubstitute
  • FontProtection
  • HideBackground
  • ImageQuality
  • LogonName
  • LogonPassword
  • MakeFieldNamesUnique
  • Media
  • OnLoadScript
  • UseNoCache
  • RetryCount
  • Timeout
  • UseScript

Script accessible properties

  • window.ABCpdf_go ABCpdf will wait for this property to be either undefined or true before capturing the HTML page. You can use this property to delay rendering of the HTML page. This can be used to control the moment of "capture" for animated HTML pages. This property is initially undefined. You need to bootstrap this property to false in OnLoadScript for it to be considered. UseScript is also required for this property to be considered. The whole HTML rendering operation is still subject to the Timeout property's value.


AddForms Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether form fields should be live.

Notes

This property determines whether form fields in HTML are reproduced as form fields in the final PDF output.

Form fields in PDF do not work exactly the same as form fields in HTML, so while the results will be similar, they may not be identical.

Example

The following example shows the effect that this parameter has on HTML rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' Covert html form fields to the pdf form fields in the output file
theDoc.HtmlOptions.AddForms = True
id = theDoc.AddImageUrl("http://www.websupergoo.com/download.htm")
' Save the document
theDoc.Save "c:\mypdfs\HtmlOptionsAddForms.pdf"

HtmlOptionsAddForms.pdf


AddLinks Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether hyperlinks should be live.

Notes

This property determines whether links in HTML are reproduced as links in the final PDF output.

Links which are not live look exactly like links but do not link through to a destination when you click on them.

Live links are reproduced exactly as specified on the page and link through to the web pages specified. These web pages will open in a new browser window.

To change external links to internal PDF links, see the Doc.LinkPages method.

Example

See the Doc.LinkPages method.


AddMovies Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether active content such as movies should be added.

Notes

Enables the embedding of active content such as Flash (SWF), AVI, MPEG and WMV.

Example

None.


AddTags Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether location of certain tags should be noted.

Notes

This property determines whether certain tags in HTML are noted so that their location can be determined at a later time.

All elements of style 'abcpdf-tag-visible' 'true' will be tagged. For example:

<p id="p1" style="abcpdf-tag-visible: true">Gallia est omnis divisa in partes tres.<p>

After adding your web pages, you can retrieve information about the items on the PDF page using the GetTagIDs and the GetTagRects methods.

Example

See the GetTagRects method.


AutoTruncate Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether to automatically clip redundant content at the end of the page.

Notes

This property determines whether redundant content at the end of an HTML page is shown.

Redundancy is determined using a number of heuristics. However, most commonly, it covers repeating background images which don't need to be shown.

Example

None.


BrowserWidth Property

Type | Default Value | Read Only | Description
Long | 0 | No | The width of the virtual browser in pixels.

Notes

This property determines or reflects the virtual browser width when rendering HTML.

HTML documents do not have a predefined width and height. The width of an HTML document varies as the client resizes the browser. How far the content flows down the page is dependent on the width of the browser.

The Width parameter is used to control this aspect of HTML rendering. It is exactly as if you were displaying your HTML in a browser window the same width as the supplied value. Typical values might be 640 or 800.

If the Width is zero, then the web page view will default to a size which shows all the available content without needing to scroll from left to right. You can use this default to ensure that all your HTML content is visible.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theURL = "http://www.nasa.gov/multimedia/imagegallery/image_feature_313.html"
' Render html page with default browser width
theDoc.AddImageUrl theURL
' Save the document
theDoc.Save "c:\mypdfs\HtmlOptionsBrowserWidth0.pdf"
theDoc.Clear
' Render html page with browser width = 300
theDoc.HtmlOptions.BrowserWidth = 300
theDoc.AddImageUrl theURL
' Save the document
theDoc.Save "c:\mypdfs\HtmlOptionsBrowserWidth300.pdf"
theDoc.Clear

HtmlOptionsBrowserWidth0.pdf

HtmlOptionsBrowserWidth300.pdf


ContentCount Property

Type | Default Value | Read Only | Description
Long | 36 | No | The minimum number of content items required for a page to be valid.

Notes

The minimum number of items a page of HTML should contain.

If the number is less than this value, then the page will be assumed to be invalid. Depending on the RetryCount settings, the page may be re-requested or an error may be returned.

Example

See the RetryCount property.


DoMarkup Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether HTML pages are marked up before conversion to PDF.

Notes

This property determines whether HTML pages are marked up before conversion to PDF.

Markup allows common HTML problems to be fixed automatically. It is also necessary for enabling page break CSS tags, for adding fields and for tagged content to be identified.

However, if you are not using these features, then skipping markup can save time for some documents.

Example

None.


FontEmbed Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether fonts should be embedded rather than referenced.

Notes

This property determines whether fonts are embedded.

HTML rendering may require that fonts are added to the PDF document.

By default, these fonts are - where possible - referenced. You can use this setting to ensure that fonts are embedded. This will increase output fidelity at a cost of processing time and output file size.

Example

None.


FontProtection Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether fonts should be protected.

Notes

This property determines whether fonts are protected.

HTML rendering may require that fonts are embedded into the PDF document.

Fonts often contain licensing information. By default, ABCpdf will prevent you from embedding fonts which indicate that embedding is not permitted.

You can disable this protection by changing the default for this value.

Example

None.


FontSubstitute Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether font substitution should be used to reduce file size.

Notes

This property determines whether font substitution is enabled.

In many situations, default built-in fonts can be substituted in place of the specified fonts.

This can result in a substantial increase in speed and a considerable reduction in file size with little or no loss in output quality.

Example

None.


HideBackground Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to hide the background color of a page.

Notes

Whether to to hide the background color of an HTML page.

This can be useful for making HTML pages with transparent backgrounds.

Note that the background color is not the same as a background image or tiled image. This property operates on background colors only.

Example

The following example shows the effect that this parameter has on HTML rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theURL = "http://www.usa.gov/"
' Add some content
theDoc.Color.String = "0 255 255" ' light blue
theDoc.FillRect 200, 200
' Hide the background of the HTML page so content shows through
theDoc.HtmlOptions.HideBackground = True
theDoc.AddImageUrl theURL
' Save the document
theDoc.Save "c:\mypdfs\HtmlOptionsHideBackground.pdf"
theDoc.Clear

HtmlOptionsHideBackground.pdf


HostWebBrowser Property

Type | Default Value | Read Only | Description
Boolean | True (overridable by registry value) | No | Whether to host a WebBrowser control.

Notes

This property determines whether a WebBrowser control is hosted.

By default, a WebBrowser control is hosted. Script-accessible properties (left, top, width, height, offsetLeft, offsetTop, offsetWidth, offsetHeight, clientLeft, clientTop, clientWidth, clientHeight, pixelLeft, pixelTop, pixelWidth, pixelHeight, posLeft, posTop, posWidth, and posHeight) hold their proper values. The source document can be in any format as long as it is HTML-compatible. For example, XML (with or without XSL applied) can be used because the WebBrowser control transforms it to HTML.

When no WebBrowser control is hosted, script-accessible dynamic, geometric properties are always zero.

Example

None.


HttpAdditionalHeaders Property

Type | Default Value | Read Only | Description
String | "" | No | Additional HTTP headers to send in the request.

Notes

This property specifies HTTP headers added to the default headers. It must follow the syntax of HTTP headers.

For example, you may add the cookies from a response to a request under some authentication (e.g. ASP.NET Forms) where a session ID is returned for subsequent requests so re-authentication is not needed. See the NoCookie property for further information if you specify cookies in the HTTP headers.

Example

None.


ImageQuality Property

Type | Default Value | Read Only | Description
Long | 101 | No | The quality of compression acceptable for continuous tone images such as JPEGs.

Notes

This property determines the image quality acceptable when rendering HTML.

ABCpdf uses a high-quality lossless compression method for image compression when rendering HTML.

Using this setting, you can indicate the quality of compression which is acceptable for continuous tone images such as JPEGs.

This can result in a considerable reduction in file size with little or no loss in output quality.

Qualities should range between 0 and 100 (75 is a reasonable value). Values higher than 100 will result in lossless compression being used in all situations.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theURL = "http://www.nasa.gov/multimedia/imagegallery/image_feature_313.html"
' Set low image quality for HTML rendering
theDoc.HtmlOptions.ImageQuality = 5
theDoc.AddImageUrl theURL
' Save the document
theDoc.Save "c:\mypdfs\HtmlOptionsImageQuality5.pdf"
theDoc.Clear
' Set lossless image quality for HTML rendering
theDoc.HtmlOptions.ImageQuality = 101
theDoc.AddImageUrl theURL
' Save the document
theDoc.Save "c:\mypdfs\HtmlOptionsImageQuality101.pdf"
theDoc.Clear

HtmlOptionsImageQuality5.pdf [file size 42 KB]

HtmlOptionsImageQuality101.pdf [file size 444 KB]


LogonName Property

Type | Default Value | Read Only | Description
String | "" | No | A user name to be used for authentication.

Notes

This property determines the authentication user name to be used when accessing secured web sites.

For example, you might set this property to "MyServer\Steve" to authenticate as Steve when accessing a particular web site.

This property needs to be used in conjunction with the LogonPassword property.

ABCpdf is a user like any other user. When it is logged in, it stays logged in until the session times out or until you explicitly log it out. So if you wish ABCpdf to log on as a different user, you must ensure that it is logged out first.

Example

The following example shows this property may be used.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theURL = "https://www.top-secret-site.com"
' Assign name and password
theDoc.HtmlOptions.LogonName = "Steve"
theDoc.HtmlOptions.LogonPassword = "stevepassword"
' Add HTML page
theDoc.AddImageUrl theURL
' Save the document
theDoc.Save "c:\mypdfs\HtmlOptionsLogon.pdf"
theDoc.Clear


LogonPassword Property

Type | Default Value | Read Only | Description
String | "" | No | A password to be used for authentication.

Notes

This property determines the authentication password to be used when accessing secured web sites.

For example, you might set this property to "stevespassword" to authenticate as Steve when accessing a particular web site.

This property needs to be used in conjunction with the LogonName property.

Example

See the LogonName property.


MakeFieldNamesUnique Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether field names should be changed to make them unique.

Notes

HTML forms can contain fields with the same name.

If the names of two fields in a PDF are the same, then the fields take the same value.

So if multiple HTML fields with the same name are added to a PDF, these fields will all appear to contain the same content. This is true even if the original HTML fields contained different content.

Setting this property will result in duplicate fields being renamed to allow the content to be different.

Example

None.


MaxAtomicImageSize Property

Type | Default Value | Read Only | Description
Long | 480 | No | The maximum size at which an image may be regarded as atomic.

Notes

ABCpdf generally regards images as atomic - unbreakable over more than one page.

However, when an image reaches a certain size, it's impossible to stop the image from being broken. To try do so would result in unacceptable gaps in the content. So the assumption that the image is atomic has to be disregarded.

This property reflects the height (in pixels) at which images will be redefined as non-atomic.

Example

None.


Media Property

Type | Default Value | Read Only | Description
Long | 0 (Print) | No | The CSS media type to use.

Notes

The Media property can take any of the following values:

  • 0 - Print (default)
  • 1 - Screen

For the Gecko engine, the Screen media must be used with UseScript enabled. An invalid combination (i.e. Screen without UseScript) with yield an exception when you call AddImageUrl or AddImageHtml.

The same HTML document can achieve different visual representation when rendered on different media by specifying several sets of CSS style rules for each medium type. The Gecko engine supports rendering Web pages using the print stylesheets and the screen stylesheets.


NoCookie Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to disable automatic cookies.

Notes

This property determines whether automatic cookies are disabled. If it is true, PageLoadMethod must be effectively MonikerForHtml.

The HTML engine manages cookies as it receives HTTP/HTTPS responses and sends HTTP/HTTPS requests. If this property is set to true, cookies stored in the local cookie database will not be sent in requests, and cookies received in responses will not be stored in the local cookie database.

Cookies specified in HttpAdditionalHeaders are not sent in requests if automatic cookies are enabled. Set this property to true if cookies are specified in HttpAdditionalHeaders.

Example

None.


OnLoadScript Property

Type | Default Value | Read Only | Description
String | "" | No | A script to be run after the page is loaded.

Notes

A client-side JavaScript to be applied to a web page before the page is rendered to PDF.

Note that you must have the UseScript key set to true or you will get an access denied error.

This kind of script can be used for a variety of purposes. For example, you might wish to hide background images or get pre-render information from the document.

You can provide a return value by setting an "abcpdf" property in the documentElement. For example:

document.documentElement.abcpdf = "my return value";

The return value can be accessed using the GetScriptReturn method with the ID returned from Doc.AddImageUrl or Doc.AddImageHtml.

Example

None.


PageCacheEnabled Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether the page cache should be searched before rendering the page.

Notes

ABCpdf holds a cache of recently requested URLs, and it's only after five minutes or so that these pages expire from the cache.

Searching the page cache before rendering a URL results in a considerable degree of optimization for many common operations.

However, if you wish to bypass the cache, you can do so by setting this property to false.

Example

None.


PageCacheExpiry Property

Type | Default Value | Read Only | Description
Long | 300,000 | No | The length of time that pages can be held in the cache (ms).

Notes

ABCpdf holds a cache of recently requested URLs, and it's only after five minutes or so that these pages expire from the cache.

This results in a considerable degree of optimization for many common operations.

You can modify the length of time that pages are held in the cache using this parameter. This value cannot be reduced to zero.

This value is measured in milliseconds.

Example

None.


PageCacheSize Property

Type | Default Value | Read Only | Description
Long | 100 | No | The number of pages that can be held in the cache.

Notes

ABCpdf holds a cache of recently requested URLs, and it's only after five minutes or so that these pages expire from the cache.

This results in a considerable degree of optimization for many common operations.

You can modify the number of items which can be held in the URL cache using this parameter. This value cannot be reduced to zero.

Example

None.


Paged Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether content should be rendered in multipaged format.

Notes

This property determines whether HTML should be prepared in a way that allows it to be paged over multiple PDF pages.

If paged mode is used, then only the first page of the document is drawn. Subsequent pages can be drawn using the Doc.AddImageToChain method.

There are subtle differences between paged and non-paged HTML. In general, you will want to set this parameter to true even if you only wish to draw one page.

Example

None.


PageLoadMethod Property

Type | Default Value | Read Only | Description
Long | 0 (Default) | No | The method for loading URI/HTML.

Notes

This property specifies the method to load the URI/HTML page.

The PageLoadMethod property can take any of the following values:

  • 0 — Default. This is currently the same as MonikerForHtml.
  • 1 — MonikerForHtml. Moniker is used to load the page.
  • 2 — WebBrowserNavigate. IWebBrowser2::Navigate is used to load the page. HostWebBrowser must be true to use this value.

This property affects the NoCookie property.

Example

None.


ReloadPage Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to reload page.

Notes

This property determines whether the page is reloaded from the server. If it is true, PageLoadMethod must be effectively MonikerForHtml.

When a page is to be reloaded, all proxy servers will request the page anew, the page cache is not searched, and if the page cache is enabled, the reloaded page is stored in the page cache.

Example

None.


RepaintDelay Property

Type | Default Value | Read Only | Description
Integer | 0 | No | Minimum time to wait for the page to finish animation (ms).

Notes

This feature allows you to cope with web pages that animate.

Most web pages simply load and complete. However some web pages may not complete in a simple manner. For example graphs may draw themselves, maps may update, images may move. These are all features associated with more dynamic modern HTML and AJAX based pages.

To cope with this we introduce the concept of a RepaintDelay and a RepaintTimeout.

When the page has finished loading we wait to see what drawing occurs. Each time the page updates - drawing occurs - we set a timer back to zero.

If the timer reaches the RepaintDelay limit then we assume that the page has reached a ready state. At that point we convert it to PDF.

If the total time exceeds the RepaintTimeout we assume that the page is never going to reach a ready state. At that point we convert whatever we have to PDF.

This value is measured in milliseconds.

Example

None.


RepaintTimeoutProperty

Type | Default Value | Read Only | Description
Integer | 5000 | No | Maximum time to wait for the page to finish animation (ms).

Notes

This feature allows you to cope with web pages that animate.

Most web pages simply load and complete. However some web pages may not complete in a simple manner. For example graphs may draw themselves, maps may update, images may move. These are all features associated with more dynamic modern HTML and AJAX based pages.

To cope with this we introduce the concept of a RepaintDelay and a RepaintTimeout.

When the page has finished loading we wait to see what drawing occurs. Each time the page updates - drawing occurs - we set a timer back to zero.

If the timer reaches the RepaintDelay limit then we assume that the page has reached a ready state. At that point we convert it to PDF.

If the total time exceeds the RepaintTimeout we assume that the page is never going to reach a ready state. At that point we convert whatever we have to PDF.

This value is measured in milliseconds.

Example

None.


RequestMethod Property

Type | Default Value | Read Only | Description
Long | 0 (Get) | No | The request method for URL.

Notes

The RequestMethod property can take any of the following values:

  • 0 — Get
  • 1 — Post

This property specifies which method Doc.AddImageUrl uses to get the HTML page. Normally, Get is the preferred method when requesting the page is an idempotent operation. However, the Get method supports at most 2,048 characters in the URL. If the URL is longer than 2,048 characters and contains parameters, it is necessary to use the Post method. However, the URL minus the parameters (and the question mark) is still limited to 2,048 characters.

The Post method is used only when the the URL contains a question mark (and this property is set to Post). If the URL does not contain any parameter, the Post method can still be used by appending a question mark to the URL.

Example

None.


RetryCount Property

Type | Default Value | Read Only | Description
Long | 5 | No | The number of times a page should be retried if unavailable or invalid.

Notes

This property controls how many times ABCpdf will attempt to obtain a page.

HTML rendering may fail one time but succeed the next. This is often for reasons outside the control of ABCpdf.

So ABCpdf may attempt to re-request a page if it is not immediately available. This is analogous to clicking on the refresh button of a web browser if the page is failing to load.

See the ContentCount and the Timeout properties for how ABCpdf determines whether a page is unavailable or invalid.

Example

The following example shows the effect that this parameter has on HTML rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theURL = "http://www.nasa.gov/multimedia/imagegallery/image_feature_313.html"
' Set minimum number of items a page of HTML should contain.
' Otherwise the page will be assumed to be invalid.
theDoc.HtmlOptions.ContentCount = 20
' Try to obtain html page 10 times
theDoc.HtmlOptions.RetryCount = 10
' The page must be obtained in less then 10 seconds
theDoc.HtmlOptions.Timeout = 10000
On Error Resume Next
theDoc.AddImageUrl theURL
If Err.Description <> "" Then
  ' Page couldn't be loaded
End If
' Save the document
theDoc.Save "c:\mypdfs\HtmlOptionsRetryCount.pdf"
theDoc.Clear

HtmlOptionsRetryCount.pdf


TargetLinks Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether hyperlinks should be allowed to open new windows.

Notes

Whether hyperlinks with targets should be allowed to open in a new browser window.

In HTML, hyperlinks whose targets are neither empty, "_self", "_parent", nor "_top" will be opened in new browser window.

Setting this property to true allows you to mimic this behavior when the PDF document is viewed inside a browser.

Example

None.


Timeout Property

Type | Default Value | Read Only | Description
Long | 15,500 | No | The maximum amount of time allowed for obtaining a page (ms).

Notes

HTML rendering can take some time.

If the time taken exceeds the Timeout, then the page is assumed to be unavailable. Depending on the RetryCount settings, the page may be re-requested or an error may be returned.

This value is measured in milliseconds.

Example

See the RetryCount property.


TransferModule Property

Type | Default Value | Read Only | Description
Long | 0 (Default) | No | The module for obtaining URI/HTML data.

Notes

This property specifies the module to obtain URI/HTML data.

The TransferModule property can take any of the following values:

  • 0 — Default. This is currently the same as RetryNetWebRequestOnEngineAccessDenied.
  • 1 — EngineTransfer. The engine (i.e. MSHTML/WinINet) obtains the page.
  • 2 — NetWebRequest. System.Net.WebRequest is used to obtain the page.
  • 33 — RetryNetWebRequestOnEngineAccessDenied (33 is not 3). The engine obtains the page. If the engine is denied access to local storage, System.Net.WebRequest is used to obtain the page. (Possibly more than one request sent.)

Example

None.


UseActiveX Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to enable ActiveX.

Notes

This property determines whether ActiveX is enabled.

By default, ActiveX is disabled when rendering HTML documents.

This is done for good security reasons, and we strongly recommend that you do not change this setting.

However, if you are sure that your source documents do not pose a security risk, you can enable ActiveX using this setting.

Compatibility. Not all ActiveX controls are compatible with ABCpdf. In particular, some rely on being able to draw directly to screen, which stops ABCpdf from being able to use them.

Example

None.


UseJava Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to enable Java.

Notes

This property determines whether Java is enabled.

By default, Java is disabled when rendering HTML documents.

This is done for good security reasons, and we strongly recommend that you do not change this setting.

However, if you are sure that your source documents do not pose a security risk, you can enable Java using this setting.

Example

None.


UseNoCache Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether any proxy servers should re-request items of content.

Notes

This property determines whether no-cache is enabled.

Setting this property to true forces any intervening proxy server to re-request the page.

Example

None.


UseResync Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether all items of content should be re-downloaded.

Notes

This property determines whether resync is enabled.

Setting this property to true forces the page to be reloaded.

Example

None.


UseScript Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to enable JavaScript and VBScript.

Notes

This property determines whether JavaScript and VBScript are enabled.

By default, client-side script such as JavaScript is disabled when rendering HTML documents.

This is done for good security reasons, and we strongly recommend that you do not change this setting.

However, if you are sure that your source documents do not pose a security risk, you can enable Script using this setting.

Example

None.


UseTheme Property

Type | Default Value | Read Only | Description
Long | 1 (UseTheme) | No | Whether to use theme or not.

Notes

The UseTheme property can take a combination of the following values:

  • 1 — UseTheme
  • 2 — NoTheme

This property determines whether UI theme is applied to controls or not.

If both UseTheme and NoTheme are set or both are clear, no theme is applied.

Example

None.


UseVideo Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to enable video.

Notes

This property determines whether video is enabled.

By default, video is disabled when rendering HTML documents.

This is done for good security reasons, and we strongly recommend that you do not change this setting.

However, if you are sure that your source documents do not pose a security risk, you can enable video using this setting.

Example

None.


XPoint Object

Represents a point in two-dimensional space. When first created, the object defaults to the origin "0 0", which is at the bottom left of the space.

ABCpdf uses the standard Adobe PDF coordinate space. The origin of this space is at the bottom left of the document. Distances are measured up and to the right in points. Points are a traditional measure for print work, and there are 72 points in an inch. For further details, see the Coordinates section of the documentation.

Method | Description
none |

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
String | Yes | The point as a delimited string.
X | No | The horizontal coordinate.
Y | No | The vertical coordinate.


String Property

Type | Default Value | Read Only | Description
String | "0 0" | No | The point as a string.

Notes

Allows you to access to the point as a string.

The format of the string must be "x y".

Example

The following code.

Set pt = Server.CreateObject("ABCpdf14.XPoint")
pt.String = "20 10"
Response.Write("X = " & pt.X)
Response.Write("<br>")
Response.Write("Y = " & pt.Y)

Produces the following output.

X = 20
Y = 10


X Property

Type | Default Value | Read Only | Description
Double | 0 | No | The horizontal coordinate.

Notes

Allows you access to the horizontal offset of the point.

Distances are measured from the left of the document.

Example

None.


Y Property

Type | Default Value | Read Only | Description
Double | 0 | No | The vertical coordinate.

Notes

Allows you access to the vertical offset of the point.

Distances are measured from the bottom of the document.

Example

None.


XRect Object

Represents a rectangular area in two-dimensional space. When first created, the object defaults to an empty rectangle "0 0 0 0".

By default, ABCpdf uses the standard Adobe PDF coordinate space. The origin of this space is at the bottom left of the document. Distances are measured up and to the right in points. Points are a traditional measure for print work, and there are 72 points in an inch. For further details, see the Coordinates section of the documentation.

You can change the coordinate system used by the Doc.Rect and the Doc.MediaBox using the Doc.Units and Doc.TopDown properties.

Method | Description
Inset | Insets the edges of the rectangle.
Magnify | Magnifies the rectangle.
Move | Translates the rectangle.
Position | Positions the bottom left of the rectangle.
Resize | Resizes the rectangle.
SetRect | Sets the location and size of the rectangle.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
String | Yes | The rect as a delimited string.
Left | No | The left of the rect.
Bottom | No | The bottom of the rect.
Right | No | The right of the rect.
Top | No | The top of the rect.
Width | No | The width of the rect.
Height | No | The height of the rect.
Pin | No | The corner of the rectangle to pin.


Inset Method

Insets the edges of the rectangle.

Syntax

XRect.Inset X, Y

Params
Name | Type | Description
X | Double | The amount to inset the left and right edges.
Y | Double | The amount to inset the top and bottom edges.

Notes

Insets the edges of the rectangle by specified horizontal and vertical amounts.

Example

The following code.

Set rc = Server.CreateObject("ABCpdf14.XRect")
rc.String = "0 0 200 100"
Response.Write("Rect = " & rc)
Response.Write("<br>")
rc.Inset 10, 20
Response.Write("Inset = " & rc)

Produces the following output.

Rect = 0 0 200 100
Inset = 10 20 190 80


Magnify Method

Magnifies the rectangle.

Syntax

XRect.Magnify X, Y

Params
Name | Type | Description
X | Double | The horizontal scale factor.
Y | Double | The vertical scale factor.

Notes

Scales the rectangle width and height by specified horizontal and vertical factors.

When you magnify a rectangle, one corner of the rectangle is pinned and the width and height of the rectangle adjusted. The corner which is pinned is indicated by the Pin property. The default pin corner is the bottom left.

Example

The following code.

Set rc = Server.CreateObject("ABCpdf14.XRect")
rc.String = "20 20 220 120"
Response.Write "Rect = " & rc
Response.Write "<br>"
rc.Magnify 0.5, 0.5
Response.Write "Scale = " & rc

Produces the following output.

Rect = 20 20 220 120
Scale = 20 20 120 70


Move Method

Translates the rectangle.

Syntax

XRect.Move X, Y

Params
Name | Type | Description
X | Double | The horizontal distance to move the rectangle.
Y | Double | The vertical distance to move the rectangle.

Notes

Moves the rectangle maintaining the width and height.

Example

The following code.

Set rc = Server.CreateObject("ABCpdf14.XRect")
rc.String = "20 20 220 120"
Response.Write "Rect = " & rc
rc.Move 50, 50
Response.Write "<br>"
Response.Write "Move = " & rc

Produces the following output.

Rect = 20 20 220 120
Move = 70 70 270 170


Position Method

Positions the bottom left of the rectangle.

Syntax

XRect.Position X, Y

Params
Name | Type | Description
X | Double | The new left position.
Y | Double | The new bottom position.

Notes

Moves the rectangle to the supplied position while maintaining the width and height. The corner moved to the location is indicated by the Pin property. The default pin corner is the bottom left.

Example

The following code.

Set rc = Server.CreateObject("ABCpdf14.XRect")
rc.String = "20 20 220 120"
Response.Write "Rect = " & rc
Response.Write "<br>"
rc.Position 50, 50
Response.Write "Pos. = " & rc

Produces the following output.

Rect = 20 20 220 120
Pos. = 50 50 250 150


Resize Method

Resizes the rectangle.

Syntax

XRect.Resize W, H

Params
Name | Type | Description
W | Double | The new width.
H | Double | The new height.

Notes

Changes the width and height of the rectangle while maintaining the position.

When you change the width or height of a rectangle, one corner of the rectangle is pinned to maintain position. The corner which is pinned is indicated by the Pin property. The default pin corner is the bottom left.

Example

The following code.

Set rc = Server.CreateObject("ABCpdf14.XRect")
rc.String = "20 20 220 120"
Response.Write "Rect = " & rc
Response.Write "<br>"
rc.Resize 50, 150
Response.Write "Pos. = " & rc

Produces the following output.

Rect = 20 20 220 120
Pos. = 20 20 70 170


SetRect Method

Sets the location and size of the rectangle.

Syntax

XRect.SetRect X, Y, W, H

Params
Name | Type | Description
X | Double | The new left position.
Y | Double | The new bottom position.
W | Double | The new width.
H | Double | The new height.

Notes

Sets the location and size of the rectangle.

The width and height of the rectangle are set to the new width and height.

The rectangle is then moved to the supplied position while maintaining the width and height. The corner moved to the location is indicated by the Pin property. The default pin corner is the bottom left.

Example

The following code.

Set rc = Server.CreateObject("ABCpdf14.XRect")
rc.String = "20 20 220 120"
Response.Write "Rect = " & rc
Response.Write "<br>"
rc.SetRect 20, 40, 50, 150
Response.Write "Pos. = " & rc

Produces the following output.

Rect = 20 20 220 120
Pos. = 20 40 70 190


Bottom Property

Type | Default Value | Read Only | Description
Double | 0 | No | The bottom coordinate.

Notes

Allows you access to the bottom coordinate.

Example

None.


Height Property

Type | Default Value | Read Only | Description
Double | 0 | No | The height of the rectangle.

Notes

Allows you access to the height of the rectangle.

When you change the width or height of a rectangle, one corner of the rectangle is pinned and the width or height of the rectangle adjusted to match the new width or height. The corner which is pinned is indicated by the Pin property. The default pin corner is the bottom left.

Example

None.


Left Property

Type | Default Value | Read Only | Description
Double | 0 | No | The left coordinate.

Notes

Allows you access to the left coordinate.

Example

None.


Pin Property

Type | Default Value | Read Only | Description
Long | 0 (bottom left) | No | The corner of the rectangle to pin.

Notes

Allows you change the pinned corner of the rectangle.

The Pin property can take any of the following values:

  • 0 - bottom left (the default)
  • 1 - top left
  • 2 - bottom right
  • 3 - top right

Some operations require that the rectangle be pinned to a location. For example, if you want to change the width of a rectangle, you can do this either by shifting the left side or the right side. If the pin property is set to the bottom left or top left, then the left side of the rectangle will be kept fixed and the right side shifted. Conversely, if the pin property is set to the bottom right or top right, then the right side of the rectangle will be kept fixed and the left side shifted.

Example

None.


Right Property

Type | Default Value | Read Only | Description
Double | 0 | No | The right coordinate.

Notes

Allows you access to the right coordinate.

Example

None.


String Property

Type | Default Value | Read Only | Description
String | "0 0 0 0" | No | The rect as a string.

Notes

Allows you access to the rect as a string.

When working in standard PDF coordinates, the format of the string is "left bottom right top". When working with top-down coordinates, the format of the string is "left top right bottom".

You can use the following page sizes as shortcuts when assigning a string value to an XRect:

Paper Size | Width in Points | Height in Points
A3 | 842 | 1190
A4 | 595 | 842
A5 | 420 | 595
B4 | 729 | 1032
B5 | 516 | 729
Letter | 612 | 792
Legal | 612 | 1008
Tabloid | 792 | 1224
Ledger | 1224 | 792
Statement | 396 | 612
Executive | 540 | 720
Folio | 612 | 936
Quarto | 610 | 780
10x14 | 720 | 1008

Example

The following code.

Set rc = Server.CreateObject("ABCpdf14.XRect")
rc.String = "10 10 200 100"
Response.Write "Width = " & rc.Width
Response.Write "<br>"
Response.Write "Height = " & rc.Height

Produces the following output.

Width = 190
Height = 90


Top Property

Type | Default Value | Read Only | Description
Double | 0 | No | The top coordinate.

Notes

Allows you access to the top coordinate.

Example

None.


Width Property

Type | Default Value | Read Only | Description
Double | 0 | No | The width of the rectangle.

Notes

Allows you access to the width of the rectangle.

When you change the width or height of a rectangle, one corner of the rectangle is pinned and the width or height of the rectangle adjusted to match the new width or height. The corner which is pinned is indicated by the Pin property. The default pin corner is the bottom left.

Example

None.


XRendering Object

Provides control over PDF rendering and rendering options.

Note: rendering is only available under the ABCpdf Professional License.

Rendering is initiated by using the Save method. Properties of this object allow finer control over the way that rendering is performed.

Method | Description
GetData | Renders the current area of the current page to memory.
Save | Renders and saves the current area of the current page.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
AntiAliasImages | No | Whether to anti-alias images.
AntiAliasPoly | No | Whether to anti-alias polygons.
AntiAliasScene | No | Whether to apply entire-scene anti-aliasing.
AntiAliasText | No | Whether to anti-alias text.
AutoRotate | No | Whether pages should be automatically rotated.
BitsPerChannel | No | The number of bits per output color channel.
ColorSpace | No | The name of the output color space.
DefaultHalftone | No | The default halftone type and options.
DotsPerInch | No | The output resolution in dots per inch (DPI).
DotsPerInchX | No | The horizontal output resolution in dots per inch (DPI).
DotsPerInchY | No | The vertical output resolution in dots per inch (DPI).
DrawAnnotations | No | Whether to render fields and annotations.
IccCmyk | No | The path to the default CMYK ICC color profile.
IccGray | No | The path to the default Gray ICC color profile.
IccRgb | No | The path to the default RGB ICC color profile.
IccOutput | No | The path to the default output ICC color profile.
Log | No | The log for the last render.
NamedSeparation | No | Named separations.
Overprint | No | Whether to apply overprint.
SaveAlpha | No | Whether to save the alpha channel into the output.
SaveAppend | No | Whether to append to (rather than overwrite) existing image files.
SaveCompression | No | The preferred compression method.
SaveQuality | No | The output file quality for lossy compression.
UseEmbeddedHalftone | No | Whether to use embedded halftones.


GetData Method

Renders the current area of the current page to memory.

Syntax

Data = XRendering.GetData(Name)

Params
Name | Type | Description
Name | String | A dummy file name used to determine the type of image required.
Data | Array of Bytes | The image as an array of bytes.

Notes

Use this method to render the PDF to memory.

The output is a rendition of the current Doc.Rect of the current Doc.Page.

Any page rotation specified in the PDF page is applied so that the output render is the correct orientation. This may mean that the output width and height are transposed copies of the width and height as specified in the Doc.Rect.

The file path extension determines the format of the output. The file name extensions which may be used are .TIF, .TIFF, JPG, GIF, PNG, .BMP and .EMF. EMF is a vector rather than raster format, which can be useful when you require resolution independence and smaller files.

Normally, you will want to render your documents using the Save method. However, sometimes, you will need to obtain your image as raw data rather than in file format. The GetData method allows you to do this.

You may wish to write such an image directly to a client browser rather than going through an intermediate file. The data you obtain using GetData can be written direct to an HTTP stream using Response.BinaryWrite. Similarly, you may wish to obtain raw data for insertion into a database.

Example

None.


Save Method

Renders and saves the current area of the current page.

Syntax

XRendering.Save Path

Params
Name | Type | Description
Path | String | The destination file path.

Notes

Use this method to render the PDF.

The output is a rendition of the current Doc.Rect of the current Doc.Page.

Any page rotation specified in the PDF page is applied so that the output render is the correct orientation. This may mean that the output width and height are transposed copies of the width and height as specified in the Doc.Rect.

The file path extension determines the format of the output. The file name extensions which may be used are .TIF, .TIFF, .JPG, .GIF, .PNG, .BMP, .JP2, .EMF and .PS. JP2 is used for the JPEG 2000 format. EMF is a vector rather than raster format, which can be useful when you require resolution independence and smaller files. PS is PostScript-compatible raw vector output.

Example

See the AntiAliasPolygons property.


AntiAliasImages Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether to anti-alias images.

Notes

Determines whether image transformations will be interpolated.

This feature is most useful when the original embedded image resolution is greater than the output resolution. When this property is set to true, interpolation is used to scale images thus increasing output quality.

Whether the edges of images are anti-aliased is determined by the AntiAliasPolygons property.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypics\HyperX.pdf"
theDoc.Rect.Inset 200, 200
' Render document with AntiAliasImages = true (default)
theDoc.Rendering.Save "c:\mypdfs\RenderingAntiAliasImagesTrue.png"
' Render document with AntiAliasImages = false
theDoc.Rendering.AntiAliasImages = False
' Save the image
theDoc.Rendering.Save "c:\mypdfs\RenderingAntiAliasImagesFalse.png"
theDoc.Clear

RenderingAntiAliasImagesTrue.png

RenderingAntiAliasImagesFalse.png


AntiAliasPolygons Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether to anti-alias polygons.

Notes

Determines whether polygons will be rendered with anti-aliased edges.

Anti-aliasing is a technique for using gradients of color to eliminate jagged edges when objects are drawn. The object edges are blurred to reduce pixelation.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' Add a polygon
theDoc.Color.String = "255 0 0"
theDoc.AddPoly "32 650 50 704 68 650 22 683 79 683 32 650", True
theDoc.Rect.String = "20 650 80 704"
' Render the drawn area with AntiAliasPolygons (default)
antiAliasedBitmap = theDoc.Rendering.GetData(".tif")
' Render the drawn area without AntiAliasPolygons
theDoc.Rendering.AntiAliasPolygons = False
aliasedBitmap = theDoc.Rendering.GetData(".tif")
' Add magnified aliased image
theDoc.Rect.String = "5 20 605 560"
theDoc.AddImageData aliasedBitmap, 1
' Anotate
theDoc.Color.String = "black"
theDoc.FontSize = 30
theDoc.Pos.String = "20 750"
theDoc.AddText "Original path:"
theDoc.Pos.String = "20 620"
theDoc.AddText "Magnified rendered image:"
' Render the document with aliased image
theDoc.Rendering.DotsPerInch = 36
theDoc.Rect.String = theDoc.MediaBox.String
theDoc.Rendering.Save "c:\mypdfs\RenderingAntiAliasPolygonsFalse.png"
' Add magnified antialiased image
theDoc.Rect.String = "5 20 605 560"
theDoc.AddImageData antiAliasedBitmap, 1
' Render the document with antialiased image
theDoc.Rendering.DotsPerInch = 36
theDoc.Rect.String = theDoc.MediaBox.String
theDoc.Rendering.Save "c:\mypdfs\RenderingAntiAliasPolygonsTrue.png"
theDoc.Clear

RenderingAntiAliasPolygonsTrue.png

RenderingAntiAliasPolygonsFalse.png


AntiAliasScene Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to apply entire-scene anti-aliasing.

Notes

Determines whether to apply entire-scene anti-aliasing.

If this property is set to true, then text, polygons and images will be anti-aliased together instead of individually. This uses considerably more memory and takes considerably longer but can result in higher-quality output.

When this property is set to true, this implicitly disables any other anti-aliasing applied to individual object types.

Anti-aliasing is a technique for using gradients of color to eliminate jagged edges when objects are drawn.

Example

None.


AntiAliasText Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether to anti-alias text.

Notes

Determines whether text will be rendered with anti-aliased edges.

Anti-aliasing is a technique for using gradients of color to eliminate jagged edges when objects are drawn. The object edges are blurred to reduce pixelation.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 50, 50
' Add some text
theDoc.FontSize = 48
theDoc.Pos.String = "50 690"
id = theDoc.AddText("Abc")
' Render images
theDoc.Rect.String = theDoc.GetInfo(id, "rect")
theDoc.Rendering.AntiAliasText = True
antialiasedBitmap = theDoc.Rendering.GetData(".tif")
theDoc.Rendering.AntiAliasText = False
aliasedBitmap = theDoc.Rendering.GetData(".tif")
' Add enlarged images to the pdf file
theDoc.Rect.Magnify 5, 5
theDoc.Rect.Move 0, -300
theDoc.AddImageData aliasedBitmap, 1
theDoc.Rect.Move 0, -300
theDoc.AddImageData antialiasedBitmap, 1
' Annotate
theDoc.Rect.String = theDoc.MediaBox.String
theDoc.Color.String = "255 0 0"
theDoc.FontSize = 36
theDoc.Pos.String = "50 740"
theDoc.AddText "Original text:"
theDoc.Pos.String = "50 620"
theDoc.AddText "Magnified aliased image:"
theDoc.Pos.String = "50 320"
theDoc.AddText "Magnified antialiased image:"
' Save render of pdf files
theDoc.Rendering.AntiAliasText = True
theDoc.Rendering.DotsPerInch = 36
theDoc.Rendering.Save "c:\mypdfs\RenderingAntiAliasText.png"
theDoc.Clear

RenderingAntiAliasText.png


AutoRotate Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether pages should be automatically rotated.

Notes

A PDF document may contain pages in portrait or landscape mode.

If the pages are in landscape mode, the viewing application should rotate them by 90 degrees before displaying them.

If you use ABCpdf to render a landscape page, then it will automatically apply the correct rotation. However, if you want to disable this automatic rotation, you can set this property to false.

Example

None.


BitsPerChannel Property

Type | Default Value | Read Only | Description
Long | 8 | No | The number of bits per output color channel.

Notes

This property determines the precision of the output color channels.

The value is specified in terms of the number of bits used to represent each channel of color. This can be 1, 8 or 16.

All color spaces support 8 and 16 bits per channel. Only the Gray color space supports 1 bit per channel.

The TIFF output format supports all output precisions. The JP2 (JPEG 2000) format supports 8 and 16 bits per channel. The JPG, GIF, PNG and .BMP. output formats support 8-bit RGB and 8-bit Gray only.

Example

See the DefaultHalftone property.


ColorSpace Property

Type | Default Value | Read Only | Description
String | "RGB" | No | The name of the output color space.

Notes

A string representation of the output color space. This property can take any of the following values:

  • RGB - red, green and blue
  • Gray - grayscale
  • CMYK - cyan, magenta, yellow and black
  • Lab - a device-independent color space

The TIFF output format supports all color spaces. The JP2 (JPEG 2000) format supports RGB, Gray and CMYK. The JPG, GIF, PNG and .BMP. output formats support 8-bit RGB and 8-bit Gray only.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.AddImage "c:\mypics\Shuttle.jpg"
theDoc.Rect.String = theDoc.MediaBox.String
' Render document in Gray colorspace
theDoc.Rendering.ColorSpace = "Gray"
theDoc.Rendering.DotsPerInch = 36
theDoc.Rendering.Save "c:\mypdfs\RenderingColorSpace.png"
theDoc.Clear

Shuttle.jpg

RenderingColorSpace.png


DefaultHalftone Property

Type | Default Value | Read Only | Description
String | "Spot,30,100,CosineDot" | No | The default halftone type and options.

Notes

Specifies the default halftone type and options.

The default halftone remains in effect until an embedded halftone screen is encountered.

The Type can be:

  • Spot
  • ErrorDiffusion
  • OrderedDither

If the type is Spot, then an angle in degrees, frequency and spot function can also be specified. These should be separated by commas with no extraneous spaces. The spot functions available are:

  • SimpleDot
  • InvertedSimpleDot
  • DoubleDot
  • InvertedDoubleDot
  • CosineDot
  • Double
  • InvertedDouble
  • Line
  • LineX
  • LineY
  • Round
  • Ellipse
  • EllipseA
  • InvertedEllipseA
  • EllipseB
  • EllipseC
  • InvertedEllipseC
  • Square
  • Cross
  • Rhomboid
  • Diamond

For full details of how Halftones work, you should see the Adobe PDF Specification available from the Adobe web site.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
Set image = Server.CreateObject("ABCpdf14.Image")
image.SetFile "c:\mypics\Shuttle.jpg"
theDoc.Rect.String = image.Selection.String
theDoc.AddImage(image)
' Save rendered image as black and white picture using Line spot function
theDoc.Rendering.UseEmbeddedHalftone = False
theDoc.Rendering.DotsPerInch = 50
theDoc.Rendering.ColorSpace = "Gray"
theDoc.Rendering.BitsPerChannel = 1
theDoc.Rendering.DefaultHalftone = "Spot,30,100,Line"
theDoc.Rendering.Save "c:\mypdfs\RenderingHalftoneLine.png"
' Save rendered image as black and white picture using Diamond spot function
theDoc.Rendering.DefaultHalftone = "Spot,0,100,Diamond"
theDoc.Rendering.Save "c:\mypdfs\RenderingHalftoneDiamond.png"
theDoc.Clear()

RenderingHalftoneLine.png

RenderingHalftoneDiamond.png


DotsPerInch Property

Type | Default Value | Read Only | Description
Double | 72.0 | No | The output resolution in dots per inch (DPI).

Notes

This property determines the resolution of the output image.

Because PDF documents specify distances in physical units (typically points), a resolution unit is needed to convert these physical units to pixel based units.

For example, a document 612 points wide rendered at 144 DPI will result in an output image 1224 pixels wide.

Changing this property will change the values of both the DotsPerInchX and DotsPerInchY properties.

Example

See the DefaultHalftone property.


DotsPerInchX Property

Type | Default Value | Read Only | Description
Double | 72.0 | No | The horizontal output resolution in dots per inch (DPI).

Notes

This property determines the horizontal resolution of the output image.

Because PDF documents specify distances in physical units (typically points), a resolution unit is needed to convert these physical units to pixel based units.

For example, a document 612 points wide rendered at 144 DPI will result in an output image 1224 pixels wide.

Example

See the SaveCompression property.


DotsPerInchY Property

Type | Default Value | Read Only | Description
Double | 72.0 | No | The vertical output resolution in dots per inch (DPI).

Notes

This property determines the vertical resolution of the output image.

Because PDF documents specify distances in physical units (typically points), a resolution unit is needed to convert these physical units to pixel based units.

For example, a document 612 points high rendered at 144 DPI will result in an output image 1224 pixels high.

Example

See the SaveCompression property.


DrawAnnotations Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether to render fields and annotations.

Notes

Determines whether fields and annotations will be rendered.

PDF fields and annotations are not part of the PDF content. Instead, they float over the PDF background. You may choose to render these fields or you may wish to avoid rendering them.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypics\Annotations.pdf"
theDoc.Rect.Pin = 1
theDoc.Rect.Height = 300
' Render document with DrawAnnotations (default)
theDoc.Rendering.Save "c:\mypdfs\RenderingDrawAnnotationsTrue.png"
' Render document without DrawAnnotations
theDoc.Rendering.DrawAnnotations = False
theDoc.Rendering.Save "c:\mypdfs\RenderingDrawAnnotationsFalse.png"
theDoc.Clear

RenderingDrawAnnotationsTrue.png

RenderingDrawAnnotationsFalse.png


IccCmyk Property

Type | Default Value | Read Only | Description
String | "standard" | No | The path to the default CMYK ICC color profile.

Notes

A path to the default CMYK ICC color profile.

The profile that will be used to convert any device CMYK specified in the PDF file to the device-independent working color space.

This is used when the output ColorSpace is Lab or another device-independent color space. If the IccOutput indicates that a color profile should be used, the output is always device-independent. If the IccOutput indicates that no color profile should be used, then the output is always device-dependent.

This property can take a path to an icm file. However, there are also two special values you can use. If the property takes the value "device", then the device color space will be used. If the property takes the value "standard", then a built-in default color profile will be used.

If this property is set to "standard" or a path to a color profile, then IccRgb, IccCmyk, IccGray and IccOutput should also be set to "standard" or paths to color profiles. All color spaces are assumed to be device-independent color spaces.

If this property is set to "device", then IccRgb, IccCmyk, IccGray and IccOutput should also be set to "device". All color spaces are all assumed to be device color spaces.

If this property is set to a file name with no path information, then the system ICC color profile directory will be searched to locate the file.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 20, 40
theDoc.FontSize = 96
' Add CMYK Content
theDoc.Color.String = "200 20 20 20"
theDoc.AddText "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur."
theDoc.Rect.String = theDoc.MediaBox.String
theDoc.Rendering.DotsPerInch = 36
theDoc.Rendering.IccCmyk = "c:\mypics\cmyk.icc"
theDoc.Rendering.ColorSpace = "RGB"
' Save the image
theDoc.Rendering.Save "c:\mypdfs\RenderingIccCmyk.png"
theDoc.Clear

RenderingIccCmyk.png


IccGray Property

Type | Default Value | Read Only | Description
String | "standard" | No | The path to the default Gray ICC color profile.

Notes

A path to the default Gray ICC color profile.

The profile that will be used to convert any device Gray specified in the PDF file to the device-independent working color space.

This is used when the output ColorSpace is Lab or another device-independent color space. If the IccOutput indicates that a color profile should be used, the output is always device-independent. If the IccOutput indicates that no color profile should be used, then the output is always device-dependent.

This property can take a path to an icm file. However, there are also two special values you can use. If the property takes the value "device", then the device color space will be used. If the property takes the value "standard", then a built-in default color profile will be used.

If this property is set to "standard" or a path to a color profile, then IccRgb, IccCmyk, IccGray and IccOutput should also be set to "standard" or paths to color profiles. All color spaces are assumed to be device-independent color spaces.

If this property is set to "device", then IccRgb, IccCmyk, IccGray and IccOutput should also be set to "device". All color spaces are all assumed to be device color spaces.

If this property is set to a file name with no path information, then the system ICC color profile directory will be searched to locate the file.

Example

None.


IccOutput Property

Type | Default Value | Read Only | Description
String | "standard" | No | The path to the default output ICC color profile.

Notes

A path to the default output ICC color profile.

Rendering can occur either to a device color space or to a device-independent color space. By specifying an output color profile, you are telling ABCpdf the characteristics of the device-independent output color space you wish to use.

This property can take a path to an icm file. However, there are also two special values you can use. If the property takes the value "device", then the device color space will be used. If the property takes the value "standard", then a built-in default color profile will be used.

If this property is set to "standard" or a path to a color profile, then IccRgb, IccCmyk and IccGray should also be set to "standard" or paths to color profiles. All color spaces are assumed to be device-independent color spaces.

If this property is set to "device", then IccRgb, IccCmyk and IccGray should also be set to "device". All color spaces are all assumed to be device color spaces.

If this property is set to a file name with no path information, then the system ICC color profile directory will be searched to locate the file.

Example

None.


IccRgb Property

Type | Default Value | Read Only | Description
String | "standard" | No | The path to the default RGB ICC color profile.

Notes

A path to the default RGB ICC color profile.

The profile that will be used to convert any device RGB specified in the PDF file to the device-independent working color space.

This is used when the output ColorSpace is Lab or another device-independent color space. If the IccOutput indicates that a color profile should be used, the output is always device-independent. If the IccOutput indicates that no color profile should be used, then the output is always device-dependent.

This property can take a path to an icm file. However, there are also two special values you can use. If the property takes the value "device", then the device color space will be used. If the property takes the value "standard", then a built-in default color profile will be used.

If this property is set to "standard" or a path to a color profile, then IccRgb, IccCmyk, IccGray and IccOutput should also be set to "standard" or paths to color profiles. All color spaces are assumed to be device-independent color spaces.

If this property is set to "device", then IccRgb, IccCmyk, IccGray and IccOutput should also be set to "device". All color spaces are all assumed to be device color spaces.

If this property is set to a file name with no path information, then the system ICC color profile directory will be searched to locate the file.

Example

None.


Log Property

Type | Default Value | Read Only | Description
String | "" | Yes | The log for the last render.

Notes

During rendering, inconsistencies may be detected in the PDF or in the environment.

For example, if a PDF contains a corrupt image, then it may not be possible to display it. If a PDF contains a reference to a font which is not on the current system, then a font substitution may be required.

ABCpdf will do its best to complete the render even if errors or inconsistencies are found. However, it will log these type of issues and make the log available via this property. This can be useful for debugging purposes.

Example

None.


NamedSeparation Property

Type | Default Value | Read Only | Description
String | "" | No | Named separations.

Notes

Named separations to be used in addition to the color channels specified in the ColorSpace.

Separate color channels for the named separations are only created if the output type is TIFF and the output color space is CMYK or RGB.

If these conditions are met, ABCpdf will write each separation to a different TIFF page and set the TIFF ink name to the name of that separation.

This property can be either a comma-separated list of the named separations, or it can be the keyword 'All', which indicates that all named separations referenced by the page should be output.

Note that ABCpdf will not create spot colors if it encounters a page group color space that is different from the specified color space. However, in this situation, it will still write the process colors individually to the TIFF output.

Example

The following code will create a tiff file with 5 separated colors, each written to its own page. The ink name for each page will be the name of the separation plane: 'Cyan', 'Magenta', 'Yellow', 'Black' and 'Fluorescent Orange'.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypics\sample.pdf"
theDoc.Rendering.NamedSeparation = "Fluorescent Orange"
theDoc.Rendering.Colorspace = "CMYK"
theDoc.Rendering.Save "c:\mypdfs\separated.tiff"
theDoc.Clear


Overprint Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to apply overprint.

Notes

Overprint is a way of combining colors when dealing with subtractive color spaces such as CMYK or DeviceN.

Normally, when one color is painted over another, it replaces the underlying color. So a black over a cyan becomes yellow. If Overprint is set, then the top color may be placed over the top of the base color. So black over cyan becomes a mixture of both black and cyan inks. This can be useful for printing purposes.

In ABCpdf, overprint is only applied when the Overprint property is set to true, the output ColorSpace is CMYK, the IccOutput is "device", the PDF graphics state indicates that overprint mode should be applied (see the Adobe PDF Specification for details) and no transparency has been detected.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
' Open document with overprint
theDoc.Read "C:\WSG\Projects\ABCpdf\TestSuite\mypics\Overprint.pdf"
' Render the document (we need to go to CMYK for overprint)
theDoc.Rendering.ColorSpace = "CMYK"
theDoc.Rendering.Overprint = True
theDoc.Rendering.IccRgb = "device"
theDoc.Rendering.IccGray = "device"
theDoc.Rendering.IccCmyk = "device"
theDoc.Rendering.IccOutput = "device"
' Put image back into another PDF and render the document as RGB
' (so that we can see the effect of the overprint in RGB)
Set theRgb = Server.CreateObject("ABCpdf14.Doc")
theRgb.AddImageData theDoc.Rendering.GetData(".tif"), 1
theDoc.Clear
theRgb.Rendering.DotsPerInch = 36
theRgb.Rendering.ColorSpace = "RGB"
theRgb.Rendering.Save "C:\WSG\Projects\ABCpdf\TestSuite\TestEx\RenderingOverprint.png"
theRgb.Clear

RenderingOverprint.png


SaveAlpha Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to save the alpha channel into the output.

Notes

This property determines whether the Save method includes an alpha channel in the rendered output.

Only some types of output support alpha. These are:

  • PNG
  • BMP
  • TIFF (Grayscale, RGB and CMYK)
  • Bitmap (via the GetBitmap function)

By including an alpha channel in your output, you can identify areas which are transparent and areas on which no drawing has taken place.

Example

None.


SaveAppend Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to append to (rather than to overwrite) existing image files.

Notes

This property determines whether the Save method appends to (rather than overwrites) existing image files.

If this property is set to true and a file already exists, then the Save method appends the rendered image to the exisiing file rather than just overwriting it. In this way, you can build up multi-page images.

This property is used for TIFF output only.

Example

See the SaveCompression property.


SaveCompression Property

Type | Default Value | Read Only | Description
Long | 0 | No | The preferred compression method.

Notes

This property determines the preferred compression method.

Not all file formats support all compression methods. Not all compression methods support all color spaces. This is why this property indicates a preferred method.

This property accepts the following values:

  • 0 [Uncompressed]
  • 3 [G3 Black and White Fax Compression]
  • 4 [G4 Black and White Fax Compression]
  • 5 [LZW Compression]
  • 7 [Tiff Jpeg Compression]
  • 8 [Adobe Flate Compression]
  • 32946 [Flate Compression]
  • 32773 [Macintosh PackBits]

In general, this property is most useful when producing output in formats like TIFF which support a range of color spaces and compression methods.

Example

The following example shows how to render a PDF into a multipage G4 compressed Fax TIFF using different vertical and horizontal resolutions.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypdfs\spaceshuttle.pdf"
' set up the rendering parameters
theDoc.Rendering.ColorSpace = "Gray"
theDoc.Rendering.BitsPerChannel = 1
theDoc.Rendering.DotsPerInchX = 200
theDoc.Rendering.DotsPerInchY = 400
' loop through the pages
n = theDoc.PageCount
For i = 1 To n
  theDoc.PageNumber = i
  theDoc.Rect = theDoc.CropBox
  theDoc.Rendering.SaveAppend = (i <> 1)
  theDoc.Rendering.SaveCompression = 4 ' G4 Fax
  theDoc.Rendering.Save "c:\mypdfs\fax.tif"
Next


SaveQuality Property

Type | Default Value | Read Only | Description
Long | 75 | No | The output file quality for lossy compression.

Notes

This property determines the quality of the output image.

It can take values between 0 and 100 ranging from the lowest to the highest quality.

This property is used for JPEG output only.

Example

The following example shows the effect that this parameter has on PDF rendering.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypics\SpaceShuttlePage6.pdf"
theDoc.Rendering.DotsPerInch = 36
' Save at low quality
theDoc.Rendering.SaveQuality = 5
theDoc.Rendering.Save "c:\mypdfs\RenderingQuality5.jpg"
' Save at high quality
theDoc.Rendering.SaveQuality = 75
theDoc.Rendering.Save "c:\mypdfs\RenderingQuality75.jpg"
theDoc.Clear

RenderingQuality5.jpg [file size 9.26 KB]

RenderingQuality5.jpg [file size 37.3 KB]


UseEmbeddedHalftone Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether to use embedded halftones.

Notes

Specifies whether to use embedded halftones.

If embedded halftones are not used, then the DefaultHalftone will be used for all halftoning.

Example

See the DefaultHalftone property.


XSaveOptions Object

Represents the current save settings.

Method | Description
none |

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
FileExtension | No | The file extension for the target when it is not otherwise specified.
IDConstant | No | Whether to assign a constant file version identifier.
IDHexadecimal | No | Whether to assign non-ASCII file identifiers.
IDUpdate | No | Whether to update the file version identifier.
Incremental | No | Whether to use incremental update to preserve an audit trail.
Linearize | No | Whether to linearize the output for fast web viewing.
Remap | No | Whether to reduce size by remapping objects.
Template | No | The path to the template file.
TemplateData | No | The template data.


FileExtension Property

Type | Default | Read Only | Description
String | "" | No | Gets or sets the file extension for the target when it is not otherwise specified.

Notes

This property is used when saving without specifying a file extension, for example when saving to a Stream.

The supported values are ".xps"/"xps" and ".swf"/"swf".

Example

None.


IDConstant Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to assign a constant file version identifier.

Notes

This property determines whether the file identifiers should be constant rather than unique.

PDF documents have two unique file identifiers. One is a file-specific identifier which stays constant throughout the life of the file. The other is a file version identifier which is updated every time the document is saved.

This property allows you to ensure that the same identifiers are always used. This can be useful for debugging if you need to do a binary-level comparison of files and you need to ensure that random elements have been eliminated.

Example

None.


IDHexadecimal Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether to assign non-ASCII file identifiers.

Notes

This property determines whether file identifiers should be hexadecimal or ASCII.

File identifiers take the form of strings. The characters in these strings can span any range. However, some applications demand that identifiers are restricted to the ASCII range while some demand that identifiers contain characters outside the ASCII range.

Setting this value to false will allow you to restrict newly generated identifiers to the ASCII range.

Example

None.


IDUpdate Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether to update the file version identifier.

Notes

This property determines whether the file version identifier should be updated.

PDF documents have two unique file identifiers. One is a file-specific identifier which stays constant throughout the life of the file. The other is a file version identifier which is updated every time the document is saved.

This property allows you to suppress the version update.

Example

None.


Incremental Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to use incremental update to preserve an audit trail.

Notes

This property determines whether incremental update should be used.

Incremental update leaves the structure of any original document intact and appends any changes to the end of the file.

Because the original PDF is unchanged, it is possible to revert back to the state before the changes were applied. Because only updated objects are written to disk it can result in faster write times.

However, most importantly, you have to use incremental update if you wish to preserve any signed signature fields present in the document. Indeed, after any signature field is signed, you need to commit changes to file using incremental update.

Incremental Update is incompatible with Linearization and Remapping. As such it will override these settings.

Example

None.


Linearize Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether to linearize the output for fast web viewing.

Notes

This property determines whether output should be linearized for fast viewing over the web.

Linearized PDFs are organized in a special way to enable efficient access over the web. The output is valid PDF in all ways, but it is structured to allow web viewers to access only the portions of the PDF that they need.

From a practical point of view, this means that a Linearized PDF opens instantly rather than requiring that the entire PDF be downloaded before it can be seen.

Adobe sometimes refer to Linearization as Fast Web View.

There is a performance and memory overhead associated with linearization. However, this is something that you should normally only notice when handling huge documents.

Example

None.


Remap Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to reduce size by remapping objects.

Notes

This property determines whether output size should be reduced by remapping objects.

PDF documents consist of a sequence of numbered objects. If objects have been deleted, there may be gaps in this sequence. Gaps can lead to PDFs which are larger than necessary.

If this property is set to true, then when the document is saved, remapping will occur to eliminate these gaps.

Note that if the Linearize property is set to true, then remapping will occur no matter the value of this property.

Example

None.


Template Property

Type | Default Value | Read Only | Description
String | "" | No | The path to the template file.

Notes

This property specifies the template file, which provides some format-specific data essential to the usefulness of the output when saving in certain formats such as SWF.

Example

None.


TemplateData Property

Type | Default Value | Read Only | Description
XSaveTemplateData | Nothing | No | The template data.

Notes

This property specifies the template data that is not obtained from Template and which provides some format-specific data essential to the usefulness of the output when saving in certain formats such as SWF.

Example

None.


XSaveTemplateData Class

Represents some format-specific data not obtained from a template file.

Method | Description
SetMeasureResolution | Sets the measurement resolutions.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
MeasureDpiX | No | The horizontal measurement resolution.
MeasureDpiY | No | The vertical measurement resolution.


SetMeasureResolution Method

Sets the measurement resolutions.

Syntax

SetMeasureResolution DpiX [, DpiY]

Params
Name | Type | Description
DpiX | Double | The new horizontal measurement resolution in DPI. It is also the new vertical measurement resolution if DpiY is missing.
DpiY | Double | The new vertical measurement resolution in DPI (optional).

Notes

Sets the measurement resolutions, which affects the measurements for certain output formats that does not support physical sizes. For example, SWF measurements are pixel-based while PDF measurements are in points (1/72 of an inch). This specifies how many pixels in SWF an inch in PDF represents.

The values do not affect the pixel sizes of raster-image contents. If DpiY is omitted, DpiX will set both horizontal and vertical measurement resolutions. If one of the values (DpiX or DpiY) is invalid, the other value may be used for both values.

For SWF, these values are used only if XSaveOptions.Template is an empty string.

Example

Here, we use 72 DPI so that 1 inch in the PDF becomes 72 pixels in the SWF.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read "c:\mypics\sample.pdf"
Set theDoc.SaveOptions.TemplateData = Server.CreateObject("ABCpdf14.XSaveTemplateData")
theDoc.SaveOptions.TemplateData.SetMeasureResolution 72
theDoc.Save "c:\mypdfs\swfsave.swf"


MeasureDpiX Property

Type | Default | Read Only | Description
Double | 0 | Yes | The horizontal measurement resolution.

Notes

To change the value, use SetMeasureResolution.

Example

None.


MeasureDpiY Property

Type | Default | Read Only | Description
Double | 0 | Yes | The vertical measurement resolution.

Notes

To change the value, use SetMeasureResolution.

Example

None.


XSignature Object

Represents a digital signature field in a document. It is a specialization of XField object.

As well as providing authorization, digital signatures can also be used to detect whether a file has been altered since signing took place.

Method | Description
Commit | Commit a previously signed signature to the document.
GetCertificates | Extract the encoded X.509 data of the certificate(s).
Sign | Sign the digital signature using a private key and password.
Validate | Check and validate the status of this signature.
 | inherited methods...

Property | Default | Description
IsModified | No | Whether the PDF has been modified after signing.
IsTimeValid | No | Whether the signature's certificate was time-valid when the document was signed.
IsTrusted | No | Whether the signature's certificate is trusted according to ValidationPolicy.
Location | No | The location of the signing.
Reason | No | The reason for signing.
Signer | No | The name of the person signing.
SigningUtcTime | No | The time of signing in UTC format.
TimestampServiceUrl | No | The URL to a time-stamping service.
ValidationPolicy | No | The validation policy for certificates.
 |  | inherited properties...


Commit Method

Commit a previously signed signature to the document.

Syntax

XSignature.Commit

Params
Name | Type | Description
n/a | n/a | n/a

Notes

After a signature is signed, it needs to be committed to the document.

Normally, this is done when you save the document. It happens invisibly without you needing to do anything. However, sometimes, you may wish to commit before the document is saved. This most commonly occurs if you are working with documents containing more than one signature field.

The PDF architecture requires that a document be incrementally updated each time a signature is signed. It requires this so that a PDF viewer can show what changes were made to the document between the times it was signed. For this reason, if you are signing multiple fields, each signature (bar the last) needs to be signed and then committed in turn. The last signature does not need to be committed because this is implicitly done by the final save.

After each commit, all previous references to form fields would be invalidated. You need to obtain updated references to form fields from the Doc.Form.Fields property.

Example

None.


GetCertificates Method

Extract the encoded X.509 data of the certificate(s).

Syntax

CertDataArray = XSignature.GetCertificates

Params
Name | Type | Description
CertDataArray | Array of Arrays of Bytes | The array of encoded X.509 data for the certificate(s).

Notes

Use this method to extract the encoded X.509 data of the certificate that was used to sign the document. Normally, there is only one certificate returned, but for some documents, you may receive additional certificates that can be used to create a certificate chain. In such cases, the first certificate is always the certificate that was used for signing.

You can pass the data returned by this function to the X509Certificate2 class constructor in System.Security.Cryptography.X509Certificates (in .NET BCL) and then extract certificate details such as the subject, the issuer, the serial number, the version, etc. See the Annotations example project for details.

Example

None.


Sign Method

Sign the digital signature using a private key and password.

Syntax

XSignature.Sign PathOrData, Password

Params
Name | Type | Description
PathOrData | String or Array of Bytes | The file path to or the data for the PFX/PKCS #12 (.pfx or .p12) file used for signing.
Password | String | The password used to authorize use of the private key.

Notes

Use this method to sign a signature field.

In order to sign a signature, you need to use your private key. To authorize the use of this key, you need to provide your password.

Typically, this password-protected private key is held in an PFX/PKCS #12 (.pfx or .p12) file. So to perform the signing operation, you provide a path to this file and a password to allow use of the private key.

Time-stamped signatures can be produced by using the service of a Time Stamping Authority (TSA). See TimestampServiceUrl.

If you are signing multiple signature fields in the same PDF document, you should call Commit manually after each signing operation bar the last operation.

If the file is not available, if the file is invalid or if the password is incorrect, then this method will raise an error.

Example

Read a document and sign a signature field embedded within that document. Before signing, we specify a location and a reason why the document is being digitally signed.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read Server.MapPath("../Rez/Authorization.pdf")
Set theSig = theDoc.Form("Signature")
theSig.Location = "Washington"
theSig.Reason = "Schedule Agreed"
theSig.Sign Server.MapPath("../Rez/JohnSmith.pfx"), "1234"
theDoc.Save Server.MapPath("Signed.pdf")

The following AddSignature method simplified from InteractiveForm.AddSignature in the Annotations example project adds and signs a signature.

Set theSig = AddSignature(theDoc, "40 100 240 150", "Signature1", _
  Server.MapPath("JohnSmith.pfx"), "1234", "I am the author", "New York")

Function AddSignature(doc, fieldRect, fieldName, keyPath, keyPassword, reason, location)
  ' make sure that doc.Page is not zero, i.e. the current page exists, before continuing

  Dim eid
  eid = doc.GetInfo(doc.Root, "/AcroForm:Ref")
  If Len(eid) <= 0 Then eid = 0
  If eid = 0 Then
    Dim acro
    acro = doc.GetInfo(doc.Root, "/AcroForm")
    If acro = "" Then acro = "<</Fields []>>"
    eid = doc.AddObject(acro)
    doc.SetInfo doc.Root, "/AcroForm:Ref", eid
  End If
  Dim font
  font = doc.AddFont("Times-Roman")
  doc.SetInfo eid, "/DR/Font/TimesRoman:Ref", font

  Dim fieldId
  fieldId = doc.AddObject("<</Type /Annot /Subtype /Widget /F 4 /FT /Sig /DA (/TimesRoman 0 Tf 0 g)>>")
  Dim sigDictId
  sigDictId = doc.AddObject("<</Filter /Adobe.PPKLite /SubFilter /adbe.pkcs7.detached>>")
  doc.SetInfo fieldId, "/V:Ref", sigDictId

  doc.SetInfo fieldId, "/T:Text", fieldName
  doc.SetInfo doc.Page, "/Annots*[]:Ref", fieldId
  doc.SetInfo fieldId, "/P:Ref", doc.Page
  doc.SetInfo eid, "/Fields*[]:Ref", fieldId
  doc.SetInfo fieldId, "/Rect:Rect", fieldRect

  Dim sig
  Set sig = doc.Form(fieldName)
  sig.Sign keyPath, keyPassword
  If Len(reason) > 0 Then doc.SetInfo sigDictId, "/Reason:Text", reason
  If Len(location) > 0 Then doc.SetInfo sigDictId, "/Location:Text", location
  If Len(sig.Signer) > 0 Then doc.SetInfo sigDictId, "/Name:Text", sig.Signer

  doc.SetInfo eid, "/SigFlags:Num", "3"
  Set AddSignature = sig
End Function


Validate Method

Check and validate the status of this signature.

Syntax

Truth = XSignature.Validate([Certificates])

Params
Name | Type | Description
Certificate | Array each of whose items is either String or Array of Bytes | An array of file paths to or data for X.509 certificate (.cer) files.
Truth | Boolean | Whether the signature is valid.

Notes
This method returns true if the signature is valid. To be precise, this method updates the properties IsModified, IsTimeValid and IsTrusted. The return value is true only if the IsModified is false, and both IsTimeValid and IsTrusted are true.

Signatures' certificates can only be validated by referencing certificates issued by certification authorities.

This method allows you to check and validate the status of a signature with reference to a set of such certificates. Additionally, ABCpdf can also use certificates found in the Windows Certificate Store for validation. See ValidationPolicy for details.

The certificates you provide will be cached at a document level so this method is efficient even when checking multiple signatures within one document. If you do not provide any parameter, this method will use the previously cached certificates to validate the document. Therefore, unless ValidationPolicy is set to EntireChainTrust, or certificates have been provided using a previous call to this method, calling this method without any certificate will cause an error to be raised to indicate that there is no certificate to validate against.

ABCpdf does not currently do revocation checks on certificates provided and on certificates embedded in a PDF document. If you need to do this type of operation, you should use the GetCertificates method and check the certificates yourself.

If a certificate is unavailable or invalid, this method may raise an error. This means validating against an unsigned signature field will cause an error to be raised.

How does Adobe Reader validate a PDF document without certificate files?

You may find that Adobe Reader does not need a list of certificate files to validate PDF documents. This is because Adobe Reader may use several built-in Public Key Infrastructure hierarchies to certify PDF documents:

  • Certified Document Services (CDS) is a trust hierarchy that chains back to the Adobe Root Certification Authority (Adobe Root CA).
  • Adobe Approved Trust List (AATL) is an extra list of CA certificates that Adobe Reader may download from Adobe periodically (for Adobe Reader/Acrobat 9 or later).
  • The Windows Certificate Store. This is only true if Windows digital signature integration is enabled in Acrobat, which is not the default for Acrobat 9 and X.

In order to validate a PDF document the same way Adobe Reader does, you need to use the same certificates it uses. This can be easily achieved by exporting the trusted identities from Adobe Reader to .cer format certificate files. (Note: CDS and AATL certificates are usually not in your Windows Certificate Store by default.)

The Windows Certificate Store can be accessed by using System.Security.Cryptography.X509Certificates.X509Store (in .NET BCL).

Example
' Validate using certificate files
Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Read Server.MapPath("../Rez/Signed.pdf")
Dim theCerts(0)
theCerts(0) = Server.MapPath("../Rez/JohnSmith.cer")
Set theSig = theDoc.Form("Signature")
If theSig.Validate(theCerts) Then
  theDoc.AddText "Signature valid at " & Now
End If
theDoc.Save Server.MapPath("SignedAndValidated.pdf")


IsModified Property

Type | Default Value | Read Only | Description
Boolean | True | Yes | Whether the PDF has been modified after signing.

Notes

This property indicates whether the PDF has been modified after signing.

Example

See the Validate method.


IsTrusted Property

Type | Default Value | Read Only | Description
Boolean | False | Yes | Whether the signature's certificate is trusted according to the validation policy.

Notes

This property indicates whether the signature's certificate is trusted according to the validation policy.

Example

See the Validate method and the ValidationPolicy property.


IsTimeValid Property

Type | Default Value | Read Only | Description
Boolean | False | Yes | Whether the signature's certificate was time-valid when the document was signed.

Notes

This property indicates whether the signature's certificate was time-valid when the document was signed.

Example

See the Validate method.


Location Property

Type | Default Value | Read Only | Description
String | "" | No | The location of the signing.

Notes

The location of the signing.

If you wish to set a value for this property, you should do so before calling the Sign method.

Note that (while reading or validating a PDF file,) this property can only be relied on if the certificate is valid. You can check whether the certificate is valid using the Validate method.

Example

See the Sign method.


Reason Property

Type | Default Value | Read Only | Description
String | "" | No | The reason for signing.

Notes

The reason for signing.

If you wish to set a value for this property, you should do so before calling the Sign function.

Note that (while reading or validating a PDF file,) this property can only be relied on if the certificate is valid. You can check whether the certificate is valid using the Validate method.

Example

See the Sign method.


Signer Property

Type | Default Value | Read Only | Description
String | See description. | No | The name of the person signing.

Notes

The name of the person signing.

When you call the Sign method, the name of the signer is automatically updated to match the name associated with the private key.

Note that (while reading or validating a PDF file,) this property can only be relied on if the certificate is valid. You can check whether the certificate is valid using the Validate method.

You will not need to change the value of this property unless you are writing low-level signature manipulation code.

Example

None.


SigningUtcTime Property

Type | Default Value | Read Only | Description
Date | See description. | No | The time of signing in UTC format.

Notes

The time of signing in UTC format.

When you call the Sign function, the UTC time is automatically updated.

Note that (while reading or validating a PDF file,) this property can only be relied on if the certificate is valid. You can check whether the certificate is valid using the Validate method.

You will not need to change the value of this property unless you are writing low-level signature manipulation code.

If the format of the date in the PDF is incorrect, then querying the value of this property may result in an error being raised.

Example

None.


TimestampServiceUrl Property

Type | Default Value | Read Only | Description
String | "" | No | The URL to a time-stamping service.

Notes

If this property is not empty when you call Sign, an X.509 RFC 3161 time-stamped signature will be created by using the service provided in the URL. Note that this property serves as an option for Sign, and is not persisted in the PDF document.

If your time-stamping service provider requires authentication, you can specify your credentials in the Uri. For example, "https://username:password@example.com/tsp".

ABCpdf uses System.Net.WebRequest to send the time-stamping request. You can use System.Net.ServicePointManager.ServerCertificateValidationCallback (in .NET BCL) to customize trust relationship establishment when you connect to an SSL/TLS channel.

Example

None.


ValidationPolicy Property

Type | Default Value | Read Only | Description
Long | 0 | No | The validation policy for certificates.

Notes

The validation policy for certificates.

The ValidationPolicyType enumeration may take the following values:

  • 0 [EntireChainTrust]
  • 1 [CertificateSignatureOnly]

When you call Validate, you can choose to provide additional certificates. This property indicates how such certificates are used and how the certificates in the document signature are validated.

When you set this property to EntireChainTrust, ABCpdf checks whether the certificates in the document signature can be validated against a trusted root Certificate Authority (trust anchor) by performing a X.509 certification path validation as described in RFC 5280. ABCpdf will use the certificates found in "Trusted Root Certification Authorities" in the Windows Certificate Store of the local machine as trust anchors. Certificates you pass into the Validate method will be regarded as additional trust anchors.

When you set this property to CertificateSignatureOnly, ABCpdf checks whether at least one of the certificates in the document signature has been signed with the public key of one of the certificates passed to Validate. When this property is set to this value, Validate does not check the Windows Certificate Store. If no certificate has been passed to Validate, an error will be raised.

EntireChainTrust is a sensible default because it is how Acrobat builds up a certificate trust chain and also how PKI generally works.

Example

None.


XTextStyle Object

Represents the style used when adding text.

All measurements are specified using the current Doc.Units.

Method | Description
none |

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
String | Yes | A string representation of the style.
Size | No | The text size.
Indent | No | The first line of paragraph indent.
LeftMargin | No | The paragraph indent.
CharSpacing | No | The inter-character spacing.
WordSpacing | No | The inter-word spacing.
LineSpacing | No | The inter-line spacing.
ParaSpacing | No | The inter-paragraph spacing.
Justification | No | The horizontal justification factor.
Bold | No | Whether to apply a synthetic bold effect.
Italic | No | Whether to apply a synthetic italic effect.
Outline | No | The width of character outlining.
Underline | No | Whether to underline text.
Strike | No | Whether to apply a strikethrough effect.
Strike2 | No | Whether to apply a double strikethrough effect.


Bold Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to apply a synthetic bold effect.

Notes

This property determines whether a synthetic bold effect is applied to text.

It is generally better to specify a bold typeface rather than synthesize a bold effect using the current typeface. However, under some circumstances, this may not be possible and you may prefer to apply a synthetic bold effect.

Example

In this example we add some bold text to a document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur."
theDoc.Rect.Inset 20, 40
theDoc.TextStyle.Size = 96
theDoc.TextStyle.Bold = True
theDoc.AddText theText
theDoc.Save "c:\mypdfs\stylebold.pdf"

stylebold.pdf


CharSpacing Property

Type | Default Value | Read Only | Description
Double | 0.0 | No | The inter-character spacing.

Notes

This property controls the spacing between each adjacent pair of characters. It is sometimes called tracking or kerning.

Each character in a string of text has a width, which is used for positioning the next character. The CharSpacing is added to the width of each character.

Specifying a positive value has the effect of stretching out the text. Specifying negative values has the effect of condensing the text.

Because this property is measured as an absolute value, the visual effect will be greater if your text is smaller.

Example

In this example, we add three blocks of text to a document. The first block uses the default spacing. The second block uses a positive value to stretch out the text. The last block uses a negative value to condense the text.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.TextStyle.Size = 96
theDoc.AddText "Zero CharSpacing"
theDoc.Rect.Move 0, -300
theDoc.TextStyle.CharSpacing = 10
theDoc.AddText "Positive CharSpacing"
theDoc.Rect.Move 0, -300
theDoc.TextStyle.CharSpacing = -10
theDoc.AddText "Negative CharSpacing"
theDoc.Save "c:\mypdfs\stylecspace.pdf"

stylecspace.pdf


Indent Property

Type | Default Value | Read Only | Description
Double | 0 | No | The first line of paragraph indent.

Notes

This property determines the horizontal indent applied to the first line of every paragraph.

If the indent is positive, the start of the first line is shifted to the right by the specified number of units. If the indent is negative, it is shifted to the left by the specified number of units.

Example

In this example, we add a block of text to a document. We specify a ParaSpacing value to space out the paragraphs and an Indent value to indent the first line of each paragraph.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes lingua, institutis, legibus inter se differunt."
theText = theText & theText
theText = theText & vbCrLf & theText & vbCrLf
theText = theText & theText & theText & theText
theDoc.Rect.Inset 20, 40
theDoc.TextStyle.Size = 16
theDoc.TextStyle.ParaSpacing = 16
theDoc.TextStyle.Indent = 48
theDoc.AddText theText
theDoc.Save "c:\mypdfs\styleindent.pdf"

styleindent.pdf


Italic Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to apply a synthetic italic effect.

Notes

This property determines whether a synthetic italic effect is applied to text.

It is generally better to specify an italic typeface rather than synthesize an italic effect using the current typeface. However, under some circumstances, this may not be possible and you may prefer to apply a synthetic italic effect.

Example

In this example, we add some italic text to a document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur."
theDoc.Rect.Inset 20, 40
theDoc.TextStyle.Size = 96
theDoc.TextStyle.Italic = True
theDoc.AddText theText
theDoc.Save "c:\mypdfs\styleitalic.pdf"

styleitalic.pdf


Justification Property

Type | Default Value | Read Only | Description
Double | 0.0 | No | The horizontal justification factor.

Notes

Allows you to adjust the horizontal justification.

Every line of text is drawn within a bounding box determined by the Doc.Rect property. The justification property can be used to space out words so that they fit the bounding box exactly.

Typically, you will only need to use values of zero - no justification - and one - full justification. However, intermediate values can be used to partially justify text.

As each line is drawn, the difference between the width of the line and the width of the bounding box is evaluated to determine the amount of free width. This free width is divided by the number of space characters in the line and then multiplied by the justification factor to produce an inter-word spacing for the line. Lines at the end of paragraphs are not justified.

Text alignment is determined by the Doc.HPos and Doc.VPos properties.

Example

In this example, we add two blocks of text to a document. The first is added with no justification, and the second is added with a justification factor of one.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur."
theDoc.Rect.Inset 20, 40
theDoc.TextStyle.Size = 48
theDoc.AddText theText
theDoc.Rect.Move 0, -350
theDoc.TextStyle.Justification = 1
theDoc.AddText theText
theDoc.Save "c:\mypdfs\stylejustification.pdf"

stylejustification.pdf


LeftMargin Property

Type | Default Value | Read Only | Description
Double | 0.0 | No | The paragraph indent.

Notes

Allows you to apply a left margin to a block of text.

The left margin is a horizontal indent applied to every line of text. You can achieve the same effect by insetting the left of the current Rect, but using this property can be more convenient.

If the value is positive, the block is shifted to the right by the specified number of units. If the value is negative, it is shifted to the left by the specified number of units.

Example

In the following example, we add three blocks of text to a document. The first block uses the default left margin. The subsequent blocks use different left margin settings to indent the text.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani..."
theDoc.TextStyle.Size = 48
theDoc.AddText theText
theDoc.Rect.Move 0, -250
theDoc.TextStyle.LeftMargin = 100
theDoc.AddText theText
theDoc.Rect.Move 0, -250
theDoc.TextStyle.LeftMargin = 200
theDoc.AddText theText
theDoc.Save "c:\mypdfs\stylemargin.pdf"

stylelmargin.pdf


LineSpacing Property

Type | Default Value | Read Only | Description
Double | 0.0 | No | The inter-line spacing.

Notes

Allows you to adjust the distance between lines of text.

At the start of every new line of text, the text drawing position is shifted vertically by the distance specified in this property. If the value is positive, this will space the lines out. If the value is negative, it will shift the lines together.

Example

In the following example, we add three blocks of text to a document. The first block uses the default line spacing. The second block uses a positive value to space out the lines. The last block uses a negative value to shift the lines together.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani..."
theDoc.TextStyle.Size = 48
theDoc.AddText theText
theDoc.Rect.Move 0, -250
theDoc.TextStyle.LineSpacing = 20
theDoc.AddText theText
theDoc.Rect.Move 0, -350
theDoc.TextStyle.LineSpacing = -20
theDoc.AddText theText
theDoc.Save "c:\mypdfs\stylelspace.pdf"

stylelspace.pdf


Outline Property

Type | Default Value | Read Only | Description
Double | 0 | No | The width of character outlining.

Notes

This property determines whether a character outlining style is applied and the weight of the outline.

If the outline property is zero, no outlining is done. If the outline property is greater than zero, it indicates the width of lines used to outline the text.

Example

In this example, we add some text to a document varying the outline style to show how different values affect the final result.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.TextStyle.Size = 144
theDoc.AddText "Outline 0"
theDoc.Rect.Move 0, -300
theDoc.TextStyle.Outline = 4
theDoc.AddText "Outline 4"
theDoc.Rect.Move 0, -300
theDoc.TextStyle.Outline = 10
theDoc.AddText "Outline 10"
theDoc.Save "c:\mypdfs\styleoutline.pdf"

styleoutline.pdf


ParaSpacing Property

Type | Default Value | Read Only | Description
Double | 0.0 | No | The inter-paragraph spacing.

Notes

Allows you to adjust the distance between paragraphs.

At the start of every new paragraph, the text drawing position is shifted vertically by the distance specified in this property. If the value is positive, this will space the paragraphs out. If the value is negative, it will shift the paragraphs together.

Example

In this example, we add two blocks of text to a document. The first block uses the default paragraph spacing. The second block uses a positive value to space out the paragraphs.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes lingua, institutis, legibus inter se differunt."
theText = theText & vbCrLf & theText & vbCrLf & theText & vbCrLf & theText
theDoc.Rect.Inset 20, 40
theDoc.TextStyle.Size = 16
theDoc.AddText theText
theDoc.Rect.Move 0, -350
theDoc.TextStyle.ParaSpacing = 20
theDoc.AddText theText
theDoc.Save "c:\mypdfs\stylepspace.pdf"

stylepspace.pdf


Size Property

Type | Default Value | Read Only | Description
Double | 10.0 | No | The current text size.

Notes

This property determines the size of text that is added to the document using methods like AddText.

The Size property is equivalent to the the Doc.FontSize property, but unlike the FontSize property, it allows fractional point sizes to be specified.

The font size is measured in units.

Example

The following example adds two blocks of styled text to a document. The first block is in 96.5 point type and the second is in 192.5 point type.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.TextStyle.Size = 96.5
theDoc.AddText "Small "
theDoc.TextStyle.Size = 192.5
theDoc.AddText "Big"
theDoc.Save "c:\mypdfs\stylesize.pdf"

stylesize.pdf


Strike Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to apply a strikethrough effect.

Notes

This property determines whether a strikethrough is applied to text.

Example

In this example, we add some strikethrough styled text to a document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur."
theDoc.Rect.Inset 20, 40
theDoc.TextStyle.Size = 96
theDoc.TextStyle.Strike = True
theDoc.AddText theText
theDoc.Save "c:\mypdfs\stylestrike.pdf"

stylestrike.pdf


Strike2 Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to apply a double strikethrough effect.

Notes

This property determines whether a double strikethrough is applied to text.

Example

In this example, we add some double strikethrough styled text to a document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur."
theDoc.Rect.Inset 20, 40
theDoc.TextStyle.Size = 96
theDoc.TextStyle.Strike2 = True
theDoc.AddText theText
theDoc.Save "c:\mypdfs\stylestrike2.pdf"

stylestrike2.pdf


String Property

Type | Default Value | Read Only | Description
String | "10 0 0 0 0 0 0 0 0 0 0 0 0 0 -1" | No | The text style as a string.

Notes

Allows you access to the style as a string.

The format of the string must be "size indent charspacing wordspacing linespacing paraspacing justification outline underline strike strike2 bold italic leftmargin ascender". Underline, strike, strike2, bold, italic, and ascender are integers (zero or non-zero for Boolean values); others are floating-point numbers.

Example

The following code.

Set ts = Server.CreateObject("ABCpdf14.XTextStyle")
ts.String = "24.5 10 0 0 0 0 0 0 0 0 0"
Response.Write "Size = " & ts.Size
Response.Write "<br>"
Response.Write "Indent = " & ts.Indent

Produces the following output.

Size = 24.5
Indent = 10


Underline Property

Type | Default Value | Read Only | Description
Boolean | False | No | Whether to underline text.

Notes

This property determines whether underlining is applied to text.

Example

In this example, we add some underlined text to a document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur."
theDoc.Rect.Inset 20, 40
theDoc.TextStyle.Size = 96
theDoc.TextStyle.Underline = True
theDoc.AddText theText
theDoc.Save "c:\mypdfs\styleunderline.pdf"

styleunderline.pdf


WordSpacing Property

Type | Default Value | Read Only | Description
Double | 0.0 | No | The inter-word spacing.

Notes

This property controls the spacing between each adjacent pair of words.

This property works in a similar way to the CharSpacing property, but the value is added to only space characters in the string. This has the effect of spacing out words or pushing them together depending whether a positive or negative value is provided.

Because this property is an absolute value, the visual effect will be greater if your text is smaller.

Example

In this example, we add three blocks of text to a document. The first block uses the default spacing. The second block uses a positive value to stretch out the text. The last block uses a negative value to condense the text.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theText = "This is an example of word spacing."
theDoc.TextStyle.Size = 72
theDoc.AddText theText
theDoc.Rect.Move 0, -300
theDoc.TextStyle.WordSpacing = 20
theDoc.AddText theText
theDoc.Rect.Move 0, -300
theDoc.TextStyle.WordSpacing = -20
theDoc.AddText theText
theDoc.Save "c:\mypdfs\stylewspace.pdf"

stylewspace.pdf


XTransform Object

Represents a world space transform.

When first created, the object defaults to the identity - no transformation.

A world space transform is not an object transform. You are changing the coordinate system - not the objects you're inserting.

Method | Description
Invert | Inverts the transform.
Magnify | Scales about a locked anchor point.
Reset | Resets to the identity.
Rotate | Rotates about a locked anchor point (angle in degrees).
Skew | Skews horizontally and vertically about a locked anchor point.
Translate | Translates horizontally and vertically.

Property | Default | Description
ComFactory | No | The factory for creating objects in the same application domain.
String | Yes | A string representation of the transform.


Invert Method

Inverts the transform.

Syntax

XTransform.Invert

Params
Name | Type | Description
None |  |

Notes

When you invert a transform, a rotation clockwise becomes an identical rotation anti-clockwise. A translation to the left becomes a translation to the right. A zoom in becomes a zoom out.

Note that not every transform can be inverted. If you specify a magnification of zero, you have shrunk your world space to a point. In this case, it is not possible to invert the transform to get the original back again. However, this kind of transform is uncommon in the real world and normally only occurs as a result of programming errors.

If you apply the invert method to a non-invertable transform, the transform will remain unmodified.

Example

Here, we add some text rotated at 45 degrees anti-clockwise around the middle of the document. We then invert the transform and draw some more text. Because the transform has been inverted, the text now appears rotated 45 degrees clockwise.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 72
theDoc.Rect = "0 0 999 999"
theDoc.Pos = "302 396"
theDoc.Transform.Rotate 45, 302, 396
theDoc.AddText "45 Degrees"
theDoc.Pos = "302 396"
theDoc.Transform.Invert
theDoc.AddText "Inverted"
theDoc.Save "c:\mypdfs\transforminvert.pdf"

transforminvert.pdf


Magnify Method

Scales about a locked anchor point.

Syntax

XTransform.Magnify ScaleX, ScaleY, AnchorX, AnchorY

Params
Name | Type | Description
ScaleX | Double | The amount of horizontal scaling to apply.
ScaleY | Double | The amount of vertical scaling to apply.
AnchorX | Double | The horizontal coordinate about which the stretch should be applied.
AnchorY | Double | The vertical coordinate about which the stretch should be applied.

Notes

This method stretches the world space about a locked anchor point. Different degrees of horizontal and vertical stretch can be used.

Another way of looking at this kind of transform is as a zoom. The anchor point is the location you're zooming in on and the scale factors indicate the level of zoom.

Example

Here, we add two chunks of text. The default text is added in black, and the magnified text is drawn in red. We specify the middle of the document as the anchor point, which means that all scaling is relative to the middle of the document. Our horizontal scale factor is larger, so our text has been stretched horizontally somewhat.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 200, 200
theDoc.FontSize = 48
theDoc.AddText "Normal"
theDoc.FrameRect
theDoc.Rect.Move 0, -100
theDoc.Color = "255 0 0" ' red
theDoc.Transform.Magnify 2, 1.5, 302, 396
theDoc.AddText "Magnified"
theDoc.FrameRect
theDoc.Save "c:\mypdfs\transformmagnify.pdf"

transformmagnify.pdf


Reset Method

Resets to the identity.

Syntax

XTransform.Reset

Params
Name | Type | Description
None |  |

Notes

This method resets the transform to it's original state. This state is known as the identity and indicates that no transformation will be applied.

Example

Here, we add some text rotated at 60 degrees around the middle of the document. We then reset the transform and draw some more text. This text is drawn with no rotation because the transform has been reset.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Inset 10, 10
theDoc.FontSize = 96
theDoc.Transform.Rotate 60, 302, 396
theDoc.Pos = "302 396"
theDoc.AddText "Angled"
theDoc.FrameRect
theDoc.Transform.Reset
theDoc.Pos = "302 396"
theDoc.AddText "Reset"
theDoc.FrameRect
theDoc.Save "c:\mypdfs\transformreset.pdf"

transformreset.pdf


Rotate Method

Rotates about a locked anchor point (angle in degrees).

Syntax

XTransform.Rotate Angle, AnchorX, AnchorY

Params
Name | Type | Description
Angle | Double | The angle to rotate in degrees.
AnchorX | Double | The horizontal coordinate about which the rotation should be applied.
AnchorY | Double | The vertical coordinate about which the rotation should be applied.

Notes

This method rotates the world space about a locked anchor point. The angle is specified in degrees anti-clockwise.

Example

Here, we add a number of chunks of text rotated at different angles about the middle of the document.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.FontSize = 48
theDoc.TextStyle.Indent = 48
For i = 1 To 8
  theAngle = i * 45
  theDoc.Pos = "302 396"
  theDoc.Transform.Reset
  theDoc.Transform.Rotate theAngle, 302, 396
  theDoc.AddText "Rotated " & theAngle
Next
theDoc.Save "c:\mypdfs\transformrotate.pdf"

transformrotate.pdf


Skew Method

Skews horizontally and vertically about a locked anchor point.

Syntax

XTransform.Skew SkewX, SkewY, AnchorX, AnchorY

Params
Name | Type | Description
SkewX | Double | The amount of horizontal skewing to apply.
SkewY | Double | The amount of vertical skewing to apply.
AnchorX | Double | The horizontal coordinate about which the stretch should be applied.
AnchorY | Double | The vertical coordinate about which the stretch should be applied.

Notes

This method skews the world space about a locked anchor point. Different degrees of horizontal and vertical stretch can be used.

A skew or shear is a mathematical operation which shifts points by an amount proportional to the distance from the anchor point. This shift is scaled by the horizontal and vertical skew factors.

Example

Here, we draw two rectangles into our document. The black rectangle is drawn before the skew operation, and the red one is drawn after it.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Width = 200
theDoc.Rect.Height = 250
theDoc.Rect.Position 20, 20
theDoc.Width = 20
theDoc.FrameRect
theDoc.Transform.Skew 1.5, 1.5, 20, 20
theDoc.Color = "255 0 0" ' red
theDoc.FrameRect
theDoc.Save "c:\mypdfs\transformskew.pdf"

transformskew.pdf


Translate Method

Translates horizontally and vertically.

Syntax

XTransform.Translate ShiftX, ShiftY

Params
Name | Type | Description
ShiftX | Double | The distance to translate to the right.
ShiftY | Double | The distance to translate upwards.

Notes

This method shifts the world space a specified distance up and to the right. Objects on the PDF will appear to translate upwards and to the right.

Example

Here, we draw two rectangles into our document. The black rectangle is drawn before the translation operation, and the red one is drawn after it.

Set theDoc = Server.CreateObject("ABCpdf14.Doc")
theDoc.Rect.Width = 200
theDoc.Rect.Height = 250
theDoc.Rect.Position 100, 100
theDoc.Width = 20
theDoc.FrameRect
theDoc.Transform.Translate 200, 200
theDoc.Color = "255 0 0" ' red
theDoc.FrameRect
theDoc.Save "c:\mypdfs\transformtranslate.pdf"

transformtranslate.pdf


String Property

Type | Default Value | Read Only | Description
String | "1 0 0 1 0 0" | No | The transform as a string.

Notes

Allows you access to the transform as a string.

The format of the string must be "m11 m12 m21 m22 mX mY".

To transform a point (x, y) to another point (x', y'), the following formula is used:

  x' = (x * m11) + (y * m21) + mX
  y' = (x * m12) + (y * m22) + mY

Example

None.


Legal Requirements

Adobe claims Intellectual Property rights over the Adobe PDF specification and we aim to ensure that those rights are upheld.

When you install ABCpdf you accept the ABCpdf license agreement. Part of the agreement specifies that you must abide by the conditions of use for PDF set down by Adobe and detailed in the Adobe PDF Specification.

For full details you should see the specification. However in summary, Adobe permits you to write software to create, display and manipulate PDF documents.

This permission is conditional on the basis that your software should respect the permissions and permission controls embedded within existing PDF documents.

These permissions do not necessarily make sense within the ABCpdf framework. For example the concept of an encrypted document which bars the user from filling in form fields makes sense if there is a user. However ABCpdf is a component and so is removed from the final user.

You should ensure that when you create software which an end user may operate that your software respects these types of permissions. You are legally bound to do this both by the ABCpdf license agreement and also by the Adobe conditions of use.


FireShieldEnabled Property

Type | Default Value | Read Only | Description
Boolean | True | No | Whether FireShield should be enabled.

Notes

Enables FireShield to be enabled or disabled.

Example

None.