Introduction
absolutePDF - Creator Easy is a Com Activex Object that enables developers to create PDF files programmatically from their Windows-based applications, using any Com-aware programming language, like Visual Basic, Visual C++ or Delphi. The usage is very simple as shown by the supplied VB example project.
The trial version downloaded from the website http://www.abspdf.com is fully functional with a limit of 60-days of free evaluation and writes "Evaluation" on each page of PDF created with the control. To remove the "Evaluation" text and use the control beyond the 60-days trial period just register the object by providing a valid license code. Licenses are on a "per install" basis for workstation and server class machines: each installation will need a separate license code (depending on the unique machine id, which can be obtained querying the control itself or using the included GetSerial.exe application). A royalty free/server license lets a developer or a software house deploy an unlimited number of installations (both server and workstation) in an unlimited number of applications (not development tools) without any additional fee.
To obtain a license code please visit http://www.abspdf.com.
GetSerial.exe [20 KB]
Getting started
Register the control
First you need to register the control. Open a "Command Prompt" window, go to the folder where you unpacked the files and type: regsvr32 absPDF_Creator.dll
To use the control in Visual Basic
Create a new project. See Demo.vbp as an example.
- From menu: Project -> References...
Check 'absPDF - Creator'
- Create object:
Dim objMyControl As Object Set objMyControl = CreateObject("absPDF_Creator")
- Unlock the control (if you have a valid key, otherwise just skip to the next item):
retVal = objMyControl.Unlock("Name", "MyCompany", "unlock_key")
- Start a new PDF supplying the destination file name and path:
retVal = objMyControl.StartPDF("c:\test.pdf")
- Set font for subsequent text:
retVal = objMyControl.SetFont("helvetica", "", "")
- Start a new page:
retVal = objMyControl.StartPage("A4", "LANDSCAPE")
- Draw a rectangle:
retVal = objMyControl.AddRectangle("4", "10", "8", "5", "", "FF0000", "00FF00")
- Add some text:
retVal = objMyControl.AddText("Hello, World", "4.5", "11.5", "", ".5", "0000FF")
- Add an image:
retVal = objMyControl.AddImage("abspdf_creator_logo.png", "4", "4.5", "")
- Finish the PDF and close it:
retVal = objMyControl.EndPDF()
For each step you can test retVal to see if there was an error: if retVal is empty the action succeeded (save for GetSerial(), see Usage for more information), otherwise you get a text string representing the error (see later for details).
Usage
Library absPDF - Creator
absPDF-Creator
Methods
Function AddEllipse(x_cm As String, y_cm As String, x_axis_cm As String, y_axis_cm As String, linewidth_pt As String, bordercolor As String, fillcolor As String) As String
Add ellipse to the current page. Leave fillcolor empty for transparent ellipse. Fillcolor and bordercolor must be specified in hex RGB format, like 'FF0000'. ' x_cm' and ' y_cm' are the coordinates in centimeters of the ellipse's center. The origin of coordinates is in the top left corner of the PDF page. Linewidth is expressed in points, leave blank for default 1pt. Returns:
- <empty string>: ok
- "ERROR_INVALID_BORDERCOLOR": bordercolor format is invalid
- "ERROR_INVALID_FILLCOLOR": fillcolor format is invalid
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function AddImage(image_pathname As String, x_cm As String, y_cm As String, resolution As String) As String
Add image to the current page. Supported formats: png, jpeg, tiff. Specify optional resolution (eg '200' for 200 dpi) or leave blank for screen 72 dpi default. Adding the same image many times, even in different pages of the same PDF, doesn't increase the overall size (only a single copy of the image is automatically added to the central dictionary). ' x_cm' and ' y_cm' are the coordinates in centimeters of lower left corner of the image. The origin of coordinates is in the top left corner of the PDF page. Returns:
- <empty string>: ok
- "ERROR_IMAGE_NOT_FOUND": the image file can't be found or isn't readable
- "ERROR_IMAGE_TYPE_UNSUPPORTED": extension must match the type, supported types png, jpeg, tiff
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function AddImageRecompressLossless(image_pathname As String, x_cm As String, y_cm As String, width_cm As String, height_cm As String, compression As String, resolution As String, temporary_directory As String) As String
Add image to the current page, recompressing image without quality loss. Supported formats: png, jpeg. Recompresses the image with the compression level specified: 0 (none) to 9 (best compression). Specify optional resolution (eg '200' for 200 dpi) or leave blank for screen 72 dpi default. Specify optional width, height (or just one for proportional resizing, or none for no resizing), the control resamples the image automatically to fit the requested resolution as needed. Adding the same image many times, even in different pages of the same PDF, doesn't increase the overall size (only a single copy of the image is automatically added to the central dictionary, but only if width, height and resolution are the same, otherwise the image is resampled at a different size and can't be used as it is). ' x_cm' and ' y_cm' are the coordinates in centimeters of lower left corner of the image. The origin of coordinates is in the top left corner of the PDF page. Please specify a valid temporary directory for recompression and file conversion. Returns:
- <empty string>: ok
- "ERROR_IMAGE_NOT_FOUND": the image file can't be found or isn't readable
- "ERROR_READING_IMAGE": the image file can't be read or is corrupted
- "ERROR_WRITING_TEMP_IMAGE": the temporary image file can't be written to temporary_ directory
- "ERROR_IMAGE_TYPE_UNSUPPORTED": extension must match the type, supported types png, jpeg
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function AddImageRecompressLossy(image_pathname As String, x_cm As String, y_cm As String, width_cm As String, height_cm As String, quality As String, resolution As String, temporary_directory As String) As String
Add image to the current page, with quality loss (smaller PDF output files). Supported formats: png, jpeg. Recompresses the image with the quality level specified: 1 (worst quality, smallest) to 100 (best quality, biggest). Specify optional resolution (eg '200' for 200 dpi) or leave blank for screen 72 dpi default. Specify optional width, height (or just one for proportional resizing, or none for no resizing), the control resamples the image automatically to fit the requested resolution as needed. Adding the same image many times, even in different pages of the same PDF, doesn't increase the overall size (only a single copy of the image is automatically added to the central dictionary, but only if width, height and resolution are the same, otherwise the image is resampled at a different size and can't be used as it is). ' x_cm' and ' y_cm' are the coordinates in centimeters of lower left corner of the image. The origin of coordinates is in the top left corner of the PDF page. Please specify a valid temporary directory for recompression and file conversion. Returns:
- <empty string>: ok
- "ERROR_IMAGE_NOT_FOUND": the image file can't be found or isn't readable
- "ERROR_READING_IMAGE": the image file can't be read or is corrupted
- "ERROR_WRITING_TEMP_IMAGE": the temporary image file can't be written to temporary_ directory
- "ERROR_IMAGE_TYPE_UNSUPPORTED": extension must match the type, supported types png, jpeg
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function AddLine(x1_cm As String, y1_cm As String, x2_cm As String, y2_cm As String, linewidth_pt As String, color As String) As String
Add line to the current page. ' x1_cm', ' y1_cm', ' x1_cm' and ' y1_cm' are the coordinates in centimeters of the start and end points of the line. The origin of coordinates is in the top left corner of the PDF page. Color must be specified in hex RGB format, like 'FF0000'; leave blank for default black. Linewidth is expressed in points, leave blank for default 1pt. Returns:
- <empty string>: ok
- "ERROR_INVALID_COLOR": color format is invalid
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function AddRectangle(x_cm As String, y_cm As String, width_cm As String, height_cm As String, linewidth_pt As String, bordercolor As String, fillcolor As String) As String
Add rectangle to the current page. Leave fillcolor empty for transparent rectangle. Fillcolor and bordercolor must be specified in hex RGB format, like 'FF0000'. ' x_cm' and ' y_cm' are the coordinates in centimeters of lower left corner of the rectangle. The origin of coordinates is in the top left corner of the PDF page. Linewidth is expressed in points, leave blank for default 1pt. Returns:
- <empty string>: ok
- "ERROR_INVALID_BORDERCOLOR": bordercolor format is invalid
- "ERROR_INVALID_FILLCOLOR": fillcolor format is invalid
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function AddText(text As String, x_cm As String, y_cm As String, rotation As String, size As String, color As String) As String
Adds text to the current page, with specified size (in centimeters) and optionally color. Color must be specified in hex RGB format, like 'FF0000'; leave blank for default black. Positive rotation, in degrees, is counterclockwise. Returns:
- <empty string>: ok
- "ERROR_INVALID_FONTSIZE": specified font size is invalid
- "ERROR_INVALID_FONTCOLOR": fontcolor format is invalid
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function AddTextParagraph(text As String, size As String, color As String) As String
Add text to the current page. The text is reformatted (left aligned) to fit inside the current bounding box (see SetTextBoundingBox method to set). Starting point for the text is the current x and y position, see SetTextCurrentX and SetTextCurrentY to set. If the text doesn't fit into the box an error ERROR_OVERFLOW is returned and the excess text can be read with GetTextOverflow. Specify size (in centimeters) and optionally color. Color must be specified in hex RGB format, like 'FF0000'; leave blank for default black. Returns:
- <empty string>: ok
- "ERROR_INVALID_FONTSIZE": specified font size is invalid
- "ERROR_OVERFLOW": some part of the text didn't fit into the bounding box
- "ERROR_INVALID_FONTCOLOR": fontcolor format is invalid
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function EndPDF() As String
Finishes the PDF and closes the file. You can now start another PDF without destroying the control and reinstantiating it. Returns:
- <empty string>: ok
- "ERROR_OPEN_OUTPUT_FILE": the control couldn't open or write to the output file
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function GetSerial() As String
Get the unique machine id. You'll need it to receive a valid unlock key from http://www.abspdf.com. Returns:
- unique machine id
Function GetTextCurrentX() As String
Returns the the current x writing position used for the AddTextParagraph method. Returns:
- x position in cm
Function GetTextCurrentY() As String
Returns the the current y writing position used for the AddTextParagraph method. Returns:
- y position in cm
Function GetTextOverflow() As String
If AddTextParagraph returns an ERROR_OVERFLOW this method returns the text that didn't fit inside the bounding box. Returns:
- overflowing text
Function GetTextWidth(text As String, size As String) As String
Estimate the width in cm of specified text (at specified size) in the destination PDF. Requires a page to have been started. Returns:
- text width (cm)
- "ERROR_INVALID_FONTSIZE": specified font size is invalid
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function SetFont(fontname As String, bold As String, italics As String) As String
Sets the font for subsequent text operations until changed. Valid fontnames for corefonts (or specify full pathname to a TTF font to be embedded): "courier", "helvetica", "times", "symbol", "zapfdingbats". Set 'bold' and/or 'italics' to 1 to obtain the desired variation. Unicode strings will often require a TTF font supporting the whole Unicode range. Returns:
- <empty string>: ok
- "ERROR_UNSUPPORTED_FONT": specified font name is unsupported
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function SetFont(fontname As String, bold As String, italics As String) As String
Sets the font for subsequent text operations until changed. Valid fontnames: 'courier', 'helvetica', 'times', 'symbol', 'zapfdingbats'. Valid fontnames: 'courier', 'helvetica', 'times', 'symbol', 'zapfdingbats'. Set 'bold' and/or 'italics' to 1 to obtain the desired variation. Returns:
- <empty string>: ok
- "ERROR_UNSUPPORTED_FONT": specified font name is unsupported
- "ERROR_UNDEFINED_PAGE": there's no current pdf page; there' a current PDF but no page has been started yet
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function SetInfo(author As String, title As String, creator As String, subject As String, keywords As String) As String
Sets the PDF file information: author, title, creator, subject, keywords. Returns:
- <empty string>: ok
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function SetTextBoundingBox(left_cm As String, right_cm As String, top_cm As String, bottom_cm As String) As String
Sets the left, right, top and bottom margins (distance in cm from the border of the physical page) of the bounding box to be used by the AddTextParagraph method. Default: 1 cm in every direction. Returns:
- <empty string>: ok - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function SetTextAutoLineFeed(autolinefeed As String) As String
Sets 0 or 1 to deactivate or activate auto line feed after AddTextParagraph. Default: active. Returns:
- <empty string>: ok - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function SetTextCurrentX(x_current_cm As String) As String
Sets the current x writing position for the AddTextParagraph method. Default: left margin of the bounding box or the last writing position ending. Returns:
- <empty string>: ok - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function SetTextCurrentY(y_current_cm As String) As String
Sets the current y writing position for the AddTextParagraph method. Default: top margin of the bounding box or the last writing position ending. Returns:
- <empty string>: ok - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function SetTextLeading(leading_cm As String) As String
Sets the leading in cm between text baselines, to be used by the AddTextParagraph method. Default: 1.5 cm. Returns:
- <empty string>: ok - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function StartPDF(pdf_pathname As String) As String
Start a new PDF, with the specified filename. Returns:
- <empty string>: ok
- "ERROR_OPEN_OUTPUT_FILE": the control couldn't open or write to the output file
Function StartPage(size As String, orientation As String) As String
Start a new PDF page. You can specify a valid size (4A|2A|A0|A1|A2|A3|A4|A5|A6|4B|2B|B0|B1|B2|B3|B4|B5|B6|LETTER|BROADSHEET|LEDGER|TABLOID|LEGAL) and orientation (PORTRAIT|LANDSCAPE). Returns:
- <empty string>: ok
- "ERROR_INVALID_ORIENTATION": the orientation specified is invalid
- "ERROR_INVALID_SIZE": the size specified is invalid
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function StartPageFromFile(pathname As String, page_number As String) As String
Start a new PDF page, using a page from an existing PDF file. Page numbering starts from 1. Returns:
- <empty string>: ok
- "ERROR_SOURCE_PDF_NOT_FOUND": the source PDF file couldn't be found
- "ERROR_OPEN_PDF_SOURCE_FILE": there was an error opening the PDF file or the PDF file was invalid
- "ERROR_PDF_PAGE_OUT_OF_RANGE": the selected page doesn't exist in the PDF file
- "ERROR_UNDEFINED_PDF": there's no current pdf; no PDF has been started yet - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive) - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Function Unlock(username As String, company As String, key As String) As String
Unlock the module with a valid key, see http://www.abspdf.com for information. Returns:
- <empty string>: ok
- "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match all the information supplied (please note that check is case sensitive)
- "ERROR_INSUFFICIENT_LICENSE_FOR_SERVER_OS": a normal client license isn't able to unlock the control on a server installation, please obtain the correct license for your server environment - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_UNREGISTERED_VERSION": the control is being used in free trial mode - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Copyright
absolutePDF - Creator Easy is a Copyright 2004-2006 of the absolutePDF Team.
All rights reserved.
The software is given "as is". No responsibility shall be assumed by the authors for loss or damage, whether real or consequential, arising from its use. By using the software you explicitly agree to hold the authors blameless for any such losses or damages.
Please visit http://www.abspdf.com for more information.
|