Nothing Special   »   [go: up one dir, main page]

PDFinclude Documentation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

PDFinclude

Version 2.4
Documentation

Prepared by:
PRO-SYS Consultants Ltd.
Gordon Campbell
November 12, 2003
This document is included as a component of the PDFinclude
Open-Source initiative. PDFinclude has been submitted to the
FreeFrameWork project and therefore is now available as per the
FreeFrameWork license.

PRO-SYS Document – PDFinclude Documentation

Any questions regarding this document or others should be forwarded to:

PRO-SYS Consultants Ltd.


7220 Montana Road
Richmond, BC, CANADA
V7C 4K3
Phone: 1-604-377-5050 or 1-780-993-0704

E-mail: sleung@epro-sys.com or gcampbell@epro-sys.com

Progress and OpenEdge are registered trademarks of Progress


Software Corporation.

Adobe PDF is a registered trademark of Adobe Solutions Incorporated.

PDFlib, PSP are registered trademarks of PDFlib GmbH.

2017-03-10 PDFinclude V2.4 Documentation ii


Document Change Log

As documents are revised, important information is added or removed. Enter


changes in this table so readers know what has changed.
Refer to this table to make sure you haven’t missed the latest information.
Date
yy/mm/dd Changed By Description of Change Reason for Change

02/10/14 G Campbell Change some functions to To allow older versions of


procedures Progress (eg: V8.x and V9.1A)
to be able to use PDFinclude.
They were reaching the 64K
Segment limitiation.
02/11/04 G Campbell Added two new procedures Additional functionality.
pdf_reset_all and
pdf_reset_stream
03/10/24 G Campbell Missing function and It has been awhile since the
procedure documentation. documentation was updated.
This release includes all
Converted PDFinclude to run changes up to and included
as include file or as a October 24, 2003.
PERSISTENT (or SUPER)
procedure.

Updated PDFinclude section


to outline new argument of
pdf_inc.i.

Plus included comments on


how to implement page
Headers and Footers.
03/11/17 G Campbell Added pdf_Encrypt Improved Functionality
procedure (uses external
produce called PSP from
PDFlib GmbH)

04/01/05 G Campbell Added ability to perform Improved Functionality.


encryption without external Improved Documentation.
product. Currently only uses
40-bit encryption
04/06/10 G Campbell Added docs for pdf_rgb Improved Functionality

This is the document change log for Project: PDFinclude Documentation.


Table of Contents
1. Introduction.............................................................................. 6
2. PDFinclude ............................................................................... 7
2.1 Overview ............................................................................................................................ 7
3. Procedure List ......................................................................... 9
pdf_close ....................................................................................................................................... 9
pdf_Encrypt ................................................................................................................................... 9
pdf_load_font .............................................................................................................................. 11
pdf_Font_Diff............................................................................................................................... 12
pdf_load_image........................................................................................................................... 13
pdf_line ........................................................................................................................................ 13
pdf_link ........................................................................................................................................ 13
pdf_move_to ............................................................................................................................... 14
pdf_new ....................................................................................................................................... 14
pdf_new_page ............................................................................................................................. 15
pdf_place_image ......................................................................................................................... 15
pdf_rect ....................................................................................................................................... 16
pdf_reset_all ................................................................................................................................ 16
pdf_reset_stream ........................................................................................................................ 17
pdf_rgb ........................................................................................................................................ 17
pdf_set_BottomMargin ................................................................................................................ 17
pdf_set_dash............................................................................................................................... 18
pdf_set_font ................................................................................................................................ 18
pdf_set_info................................................................................................................................. 19
pdf_set_LeftMargin ..................................................................................................................... 19
pdf_set_Orientation ..................................................................................................................... 19
pdf_set_PageHeight .................................................................................................................... 20
pdf_set_PageWidth ..................................................................................................................... 20
pdf_set_PaperType ..................................................................................................................... 20
pdf_set_parameter ...................................................................................................................... 21
pdf_set_TextBlue ........................................................................................................................ 22
pdf_set_TextGreen ..................................................................................................................... 23
pdf_set_TextRed ......................................................................................................................... 23
pdf_set_TopMargin ..................................................................................................................... 23
pdf_set_VerticalSpace ................................................................................................................ 24
pdf_skip ....................................................................................................................................... 24
pdf_skipn ..................................................................................................................................... 24
pdf_stroke_color.......................................................................................................................... 24
pdf_stroke_fill .............................................................................................................................. 25
pdf_text ....................................................................................................................................... 25
pdf_text_at .................................................................................................................................. 26
pdf_text_boxed_xy ...................................................................................................................... 26
pdf_text_center ........................................................................................................................... 26
pdf_text_color.............................................................................................................................. 27
pdf_text_render ........................................................................................................................... 27
pdf_text_rotate ............................................................................................................................ 27
pdf_text_to .................................................................................................................................. 28
pdf_text_xy .................................................................................................................................. 28
pdf_Watermark ........................................................................................................................... 28
pdf_Wrap_Text ........................................................................................................................... 29
4. Function List .......................................................................... 31
pdf_Angle .................................................................................................................................... 31

2017-03-10 PDFinclude V2.4 Documentation 4


pdf_BottomMargin ....................................................................................................................... 31
pdf_Font ...................................................................................................................................... 31
pdf_get_info ................................................................................................................................ 31
pdf_get_NumFittingChars ........................................................................................................... 32
pdf_get_parameter ...................................................................................................................... 32
pdf_get_wrap_length ................................................................................................................... 32
pdf_GraphicX .............................................................................................................................. 33
pdf_GraphicY .............................................................................................................................. 33
pdf_GraphicY .............................................................................................................................. 33
pdf_ImageDim ............................................................................................................................. 33
pdf_Orientation ............................................................................................................................ 34
pdf_Page ..................................................................................................................................... 34
pdf_PageFooter .......................................................................................................................... 34
pdf_PageHeader ......................................................................................................................... 35
pdf_PageHeight .......................................................................................................................... 35
pdf_PageWidth ........................................................................................................................... 35
pdf_PaperType ............................................................................................................................ 36
pdf_PointSize .............................................................................................................................. 36
pdf_Render ................................................................................................................................. 37
pdf_text_width ............................................................................................................................. 37
pdf_TextBlue ............................................................................................................................... 37
pdf_TextGreen ............................................................................................................................ 38
pdf_TextRed................................................................................................................................ 38
pdf_TextX .................................................................................................................................... 38
pdf_TextY .................................................................................................................................... 38
pdf_TotalPages ........................................................................................................................... 39
pdf_TopMargin ............................................................................................................................ 39
pdf_VerticalSpace ....................................................................................................................... 39
5. Internal Procedures and Functions ...................................... 40
6. How to Implement Page Headers and Footers .................... 42
7. How to Implement Compression .......................................... 44
8. How to Implement Encryption .............................................. 45
9. Sports2000 Samples.............................................................. 46
9.1 Hello World ....................................................................................................................... 46
9.2 Hello World – Compressed and Encrypted ...................................................................... 46
9.3 Text Positioning ................................................................................................................ 46
9.4 Customer Listing .............................................................................................................. 47
9.5 Formatted Item Listing ..................................................................................................... 50
Appendix A – Embedding Fonts................................................... 53
Appendix B – Creating AFM File .................................................. 54
1. Introduction
PDFinclude is a Progress ® include file developed by PRO-SYS Consultants Ltd (PRO-SYS) to
allow Progress developers to output reports in Adobe PDF file format without having to use third-
party tools or utilities.

PDFinclude is a stand-alone component that defines a toolset of Progress functions that aid in the
output of a PDF file … without having to generate a separate text file first.

PDF files can be read by PDF viewers such as Adobe Reader and PDFView.

The PDF file format is fast becoming an industry-standard for electronic document viewing. The
PDF format allows for documents that can be accessed by a broad range of hardware and
software devices (including PDAs and Internet browsers).

PDFinclude utilizes Progress code that is compliant with versions 8 and 9 of the Progress 4GL.

Some of the benefits of using PDFinclude are:

Consistency By using the PDF file format, you can present a representation of the
output file in a consistent manner. Use the same PDF file across
multiple devices, platforms and/or software packages.

Easy Implementation Since PDFinclude is written in Progress the ability to implement into
your existing (or new) code is easy and seamless. No external calls
are required to third-party products (such as a Perl script).

PDFinclude can also be used with Progress Versions 8 and 9 on


UNIX and Windows platforms.

Secure Report Output The PDF file format is a secure format that cannot be easily changed
therefore sensitive reports can be distributed to users without the
worry of them changing reported material.

Configurable By offering a multitude of different Progress-written PDF related


functions, you can easily configure and determine the outputs
content, object placement and look-and-feel.

Report Viewer Supplied Since PDF is becoming an industry-standard file format, many
document viewers already exist (such as Adobe’s Acrobat Reader).
This reduces your development effort by not having to create a
separate Report Viewer.

2017-03-10 PDFinclude V2.4 Documentation 6


2. PDFinclude
2.1 Overview

As previously mentioned, PDFinclude is written in Progress and consists of a set of functions.


These functions are used in combination to create an output file in PDF format. The list of
procedures and functions and their uses can be viewed in Section 3 and Section 4.

Due to the complexity of the PDF specification and our requirement of having PDF easy to
implement, building a PDF document with PDFinclude involves two different planes … or Spaces
as they are called within the PDF specification. The two spaces are the Text Space and the
Graphic Space. Each of the spaces are defined further in preceding sections but the following
items outline the basic space functions.

Text Space: The Text Space allows you to manipulate and control the where and how text
will appear on the document. The Text Space starts on the top-left hand
corner of the page and moves across and downward. Similar to how current
reports are developed with Progress.

Graphic Space: The Graphic Space allows you to manipulate and control the drawing of non-
textual object such as JPEG Images, Rectangles, Lines, etc. The Graphic
Space start at the bottom-left corner of the page and move up and across.

By manipulating and controlling the Spaces, you can create elegant documents that are directly
derived within your Progress application.

Before using of the following procedures or functions, you must add “{ pdf_inc.i }” to your Progress
program.

As of PDFinclude Version 2, pdf_inc.i now accepts an argument. The argument allows you to
specify whether you want to add the pdf_inc.p as a SUPER procedure or not. The following table
outlines the possible options.

Argument Sample Description

blank { pdf_inc.i } This will run pdf_inc.p as a SUPER


procedure and associate the
procedure handle with the SESSION
handle.

This is the default action.

THIS-PROCEDURE { pdf_inc.i “THIS-PROCEDURE” } This will run pdf_inc.p as a SUPER


procedure and associate the
procedure handle with the THIS-
PROCEDURE handle.

Anything Else { pdf_inc.i “NOT SUPER” } This will run pdf_inc.p as a


PERSISTENT procedure and will not
create the procedure as SUPER.

This is an available option for V9 (not


recommended) but is the only option
for V8. If this option is used then the
procedure calls must have the
following added to each call – IN
h_PDFinc.

For example, you originally had:

RUN pdf_new (“Spdf”).

now with this option you must


change your call to:

RUN pdf_new IN h_PDFinc (“Spdf”).

2017-03-10 PDFinclude V2.4 Documentation 8


3. Procedure List
pdf_close

Parameters: Stream Name as Character - Stream name as identified in pdf_new

Sample Call: RUN pdf_close (“Spdf”)

Description:

This procedure closes the identified PDF stream and generates the PDF document that was
identified in the pdf_new procedure.

pdf_Encrypt

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Master Password as Character - The PDF document’s Master Password
User Password as Character - The PDF document’s User Password
Access List as Character - List identifying Access Rights
Encryption Key as Integer - 40 or 128 Bit Encryption Key Length
Encryption Mode as Character - COM, SHARED or OS
Silent Encryption as Logical - TRUE OR FALSE

Sample Call: RUN pdf_Encrypt (“Spdf”,”gord1”,”gord”,””,128,”COM”,TRUE)

Description:

This procedure allows you to encrypt a generated PDF document. The call to this procedure can
occur anywhere between the appropriate pdf_new and pdf_close procedures.

This procedure call integrates with PDFpsp.w (another external procedure). PDFpsp.w uses a
commercial product called Pretty Safe PDF (PSP) from PDFlib GmbH. The PSP product can be
downloaded from www.pdflib.com. PRO-SYS has is a reseller of all PDFlib GmbH products and
we offer PEG members a discount. For more information go to www.epro-sys.com. The discounts
will only be applied by PRO-SYS. PDFlib GmbH will not honour the discounts, so orders must be
directed to PRO-SYS Consultants Ltd.

The following table outlines the parameters in further detail:

Parameter Description

Stream Name Must be a valid Stream Name as created in the procedure – see calls to
‘pdf_new’ to identify valid stream names.
Master Password The Master Password must be a maximum of 32 characters. A ‘blank’
password is valid.

The Master Password allows you to associate a password to protect the


documents security settings. This password must be entered to access
the Document Security. This password also allows entry to the documents
contents.

User Password The User Password must be a maximum of 32 characters. A ‘blank’


password is valid.

The User Password allows you to associate a password to protect the


documents contents. This password must be entered to access the
Document.

Access List The Access list can be ‘blank’ or a comma-delimited list of access
prevention rights. If ‘blank’, the document has full access rights (default).
If ‘non-blank’, then only specific items will be allowed when the document
is viewed. The following table outlines the valid entries for the comma-
delimited list:

Code Description

noprint Prevent Printing of the File


nohiresprint Prevent High Resolution Printing
nomodify Prevent Adding Form Fields & Other Changes
nocopy Prevent Copying and Extracting Text or Graphics
noannots Prevent Adding or Changing Comments or Form
Fields
noforms Prevent Filling of Form Fields
noaccessible Prevent Extraction of Text or Graphics
noassemble Prevent Inserting/Deleting/Rotating Page, Bookmarks

Encryption Key This value can either be 40 or 128. This value represents the length of the
Length Encryption Key (in bits). 128 Bit encryption is currently the strongest
encryption available.

Encryption Mode PSP can be run via a few different options. The options available vary by
Operating System. The following table outlines the values and the
Operating System that they can be used with.

Mode OS Description

COM Windows Uses the COM version of PSP.


Accessed via a COM-Handle.
SHARED Windows, *NIX Uses the DLL (for Windows) or Shared
Library (for *NIX). Accessed via
Functions calls defined in PSP.i and
PSPbind.p.
OS Windows, *NIX Uses the command line PSP tool.
Accessed via an OS-COMMAND call.

2017-03-10 PDFinclude V2.4 Documentation 10


Silent Encryption Either a TRUE or FALSE value.

If TRUE, then the Encryption routine (PDFpsp.w) is called without any


interaction. The Encryption is performed silently based on the passed
parameters.

If FALSE then the Encryption routine (PDFpsp.w) is called expecting the


user to enter some values. The Access Rights are defaulted to the
supplied list but the Master and User passwords are ignored. This user
must enter these values. The following screen print illustrates the
interactive encryption screen:

Silent Encryption

pdf_load_font

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Font Name as Character - Unique Font Name (no spaces)
Font File as Character - Location of TTF Font File (uses PROPATH)
Font AFM File as Character - Location of AFM file (uses PROPATH)
Font DIF File as Character - Location of DIF file (uses PROPATH)

Sample Call: RUN pdf_load_font


(“Spdf”,”Code39”,”c:\windows\fonts\Code39.ttf”,”.\code39.afm”,””)
Description:

This procedure allows you to load and embed external fonts for later use. You can ‘use’ a font by
using the pdf_set_font procedure.

The DIF file is optional and is only used if you want to remap some of the characters. The DIF file
should have a format similar to the following:

65 /SF100000
66 /SF110000
67 /SF010000
68 /SF030000
69 /SF040000
70 /SF080000
71 /SF090000
72 /SF060000
73 /SF070000
74 /SF050000
75 /SF430000
76 /SF240000
77 /SF510000
78 /SF520000
79 /SF390000
80 /SF220000
81 /SF210000
82 /SF250000
83 /SF500000
84 /SF490000
85 /SF380000
86 /SF280000
87 /SF270000
88 /SF260000
89 /SF360000
90 /SF370000

The first entry represents the character to replace and the second entry represents the Postscript
name of character to replace it with. The Postscript character names can be found at:
http://partners.adobe.com/asn/tech/type/opentype/appendices/wgl4.jsp

pdf_Font_Diff

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Font Name as Character - Name of a valid Font
Character Number as Integer - Integer value of the Character to change
Postscript Name as Integer - Postscript Character name

Sample Call: RUN pdf_font_diff (“Spdf”, 190,”/nsuperior”)

Description:

2017-03-10 PDFinclude V2.4 Documentation 12


This procedure allows you to dynamically change the character mapping for a given character in a
specified Font Name. This is useful when you have previously created text files that include high
ASCII character values that are used for graphic line drawing. For example, you use ASCII
character 196 to ‘draw’ a horizontal line. When you look at the actual text file you won’t see a
horizontal line you will see a funny looking binary character. Using this procedure, you can
redefine how PDFinclude handles that character … you can have it remapped to a horizontal line
(Postscript name is SF100000).

pdf_load_image

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Image Name as Character - Unique Font Name (no spaces)

Sample Call: RUN pdf_load_image (“Spdf”,”ProSysLogo”,”logo.jpg”)

Description:

This procedure allows you to load and embed and external JEPG image. You can ‘use’ the
image by using the pdf_place_image procedure. Currently, only JPEG images can be loaded
using this procedure.

pdf_line

Parameters: Stream Name as Character - Stream name as identified in pdf_new


From Column Point as Integer - A non-zero integer value representing the
lines columnar starting point
From Row Point as Integer - A non-zero integer value representing the
lines row starting point
To Column Point as Integer - A non-zero integer value representing the
lines columnar ending point
To Row Point as Integer - A non-zero integer value representing the
lines row ending point
Line Weight as Integer - A non-zero integer value representing the
width that the line should be drawn with (a
higher number indicates a thicker line)

Sample Call: RUN pdf_line (“Spdf”,10,10,10,600,2)

Description:

This procedure allows you to draw a line from a given starting point to a specified end point. You
can determine the color of the line by using the pdf_stroke_color procedure. You can also change
the appearance of the line by using the pdf_set_dash procedure.

pdf_link
Parameters: Stream Name as Character - Stream name as identified in pdf_new
From X as Integer - A non-zero integer value representing the
X axis starting point
From Y as Integer - A non-zero integer value representing the
Y axis starting point
Link Width as Integer - How wide should the link boundry be?
Link Height as Integer - How high should the link boundry be?
Link Text as Character - Text to appear when link is hovered over
Text Red as Integer - Red value of RGB Colour
Text Green as Integer - Green value of RGB Colour
Text Blue as Integer - Blue value of RGB Colour
Link Border as Integer - Non-negative integer for the border width
Link Style as Character - Display style of link

Sample Call: RUN pdf_line (“Spdf”,10,10,10,600,2)

Description:

This procedure allows you to place a rectangular link boundry into a PDF document. This can be
useful when used with linking a Customer ID to another document that lists all Customer Invoices.
The link boundry could also be placed around an image (such as a logo image) that once clicked,
could redirect someone to your corporate webpage.

Possible Style values are:


N – No highlighting (blank)
I – Invert the contents of the link
O – Invert the links border
P – Display a ‘down’ (or Pushed) appearance

pdf_move_to

Parameters: Stream Name as Character - Stream name as identified in pdf_new


To Column Point as Integer - A non-zero integer value representing a
columnar location that you want to move the
Graphic State cursor to
To Row Point as Integer - A non-zero integer value representing a row
location that you want to move the Graphic
State cursor to

Sample Call: RUN pdf_line (“Spdf”,10,10)

Description:

This procedure allows you to dynamically change Graphic State locations within the PDF stream.

pdf_new

Parameters: Stream Name as Character - Stream name as identified in pdf_new


File Name as Character - The name of the PDF file to generate (as it

2017-03-10 PDFinclude V2.4 Documentation 14


will be stored on the Operating System)

Sample Call: RUN pdf_new (“Spdf”,”c:\sports2000\sample.pdf”)

Description:

This procedure initiates a new PDF stream to create with PDFinclude. The stream name must be
unique and is used by most all other PDFinclude functions and procedures. By adding a stream
name to each of the functions and procedures, we allow you to create multiple (unlimited) PDF
documents from within a single Progress procedure.
When creating a new stream, this procedure loads the PDF Base 14 fonts (a defined set of fonts
including Courier, Helvetica, etc) plus it includes setup of the following default parameters:

Parameter Name Default Value

Orientation Portrait
PaperType LETTER
PageWidth 612
PageHeight 792
Render 0
TextX 0
TextY 0
Font Courier
FontSize 10
GraphicX 0
GraphicY 0
VerticalSpace 10
LeftMargin 10
TopMargin 50

pdf_new_page

Parameters: Stream Name as Character - Stream name as identified in pdf_new

Sample Call: RUN pdf_new_page (“Spdf”)

Description:

This procedure initiates a creates a new PDF page to write output to. It also resets the current
TextX, TextY, GraphicX and GraphicY parameters.

Note: The Progress default paging is not used, as is the Header, Footer, Page-Top, Page-
Bottom, Page-Number, and Line-Counter options. Using PDFinclude requires that you control all
output.

pdf_place_image
Parameters: Stream Name as Character - Stream name as identified in pdf_new
Image Name as Character - Valid Image name as pre-loaded with
pdf_load_image function
Graphic Column as Integer - Non-zero integer value identifying the
columnar location to begin drawing the image
Graphic Row as Integer - Non-zero integer value identifying the row
location to begin drawing the image
Width as Integer - Non-zero integer value representing the
width to render the image at
Height as Integer - Non-zero integer value representing the
height to render the image at

Sample Call: RUN pdf_place_image (“Spdf”, “ProSysLogo”,200,16)

Description:

This procedure places a previously loaded image onto the current PDF page at the specified
location.

pdf_rect

Parameters: Stream Name as Character - Stream name as identified in pdf_new


From Column as Integer - Non-zero integer value identifying the
columnar location to begin drawing the
rectangle
From Row as Integer - Non-zero integer value identifying the row
location to begin drawing the rectangle
Width as Integer - Non-zero integer value representing the
width to render the rectangle at
Height as Integer - Non-zero integer value representing the
height to render the rectangle at
Sample Call: RUN pdf_rect (“Spdf”, 10,10,200,16)

Description:

This procedure draws a rectangle onto the current PDF page at the specified location using the
specified width and height.

pdf_reset_all

Parameters: None
Sample Call: RUN pdf_reset_all.

Description:

This procedure clears all PDF content for all defined PDF streams.

2017-03-10 PDFinclude V2.4 Documentation 16


pdf_reset_stream

Parameters: Stream Name as Character - Stream name as identified in pdf_new

Sample Call: RUN pdf_reset_all.

Description:

This procedure clears all PDF content for the named PDF stream.

pdf_rgb

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Target Procedure Name - Must be one of: pdf_text_color,
as Character pdf_stroke_color, pdf_stroke_fill
RGB Color code as Character - Must be either a six digit Hex RGB color
code, preceded by ‘0x’, or ‘#’, or a nine digit
decimal RGB color code, of the format
RRRGGGBBB.

Sample Call: RUN pdf_rgb (“Spdf”, “pdf_text_color”, “0x006466”) /* Hex Teal Green*/
RUN pdf_rgb (“Spdf”, “pdf_text_color”, “000100102”) /* Decimal Teal Green*/

Description:

This procedure accepts a six digit Hex RGB color code (preceded by ‘0x’, or ‘#’, format
RRGGBB), or a Nine digit decimal RGB color code (format RRRGGGBBB) and converts it into the
three PDF RGB colors. It then runs the Target Procedure, passing in these three PDF colors.

pdf_set_BottomMargin

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Margin as Integer - An integer value for the top of the Margin

Sample Call: RUN pdf_set_BottomMargin (“Spdf”, 80)

Description:

This procedure allows you to set the height of the Bottom Margin. As soon as the Text Y location
goes greater than the Bottom Margin then a new PDF page is created. This is useful for
formatting a document as it ensures that you don’t run text to the bottom of the PDF page.

This procedure is also used in conjunction with the PageFooter functionality (explained
elsewhere). That is, if a PageFooter is defined and the Text Y location is greater than the Bottom
Margin, then the PageFooter is automatically output to the PDF document.
pdf_set_dash

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Points On as Integer - An integer value representing how many
points to display
Points Off as Integer - An integer value representing how many
points not to display

Sample Call: RUN pdf_set_dash (“Spdf”, 1,0)

Description:

This procedure allows you to take a solid line (or rectangle) and adjust it to look like a dashed line.
The On/Off parameter options allows you to define the appearance of the dashed line. You may
want to have one short line appear (eg: On=1) then have a fairly large space where the line
doesn’t appear at all (eg: Off=10).

pdf_set_font

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Font Name as Character - The name of a valid Font (either one of the
PDF 14 Base fonts or a font previously loaded
by the pdf_load_font function)
Font Size as Decimal - The size to display the font with

Sample Call: RUN pdf_setfont (“Spdf”, “Code39”,10)

Description:

This procedure allows you to set how the following text will be displayed. All text following this
procedure will appear using the set font until the Font is set back to another font.

The following table defines the names of the PDF Base14 Fonts.

Note: Only 12 are defined right now. We still need to add the WingDings and Symbol Fonts.

Font Name Description

Courier Fixed-Width Courier Font


Courier-Bold Bolded Fixed-Width Courier Font
Courier-Oblique Italicized Fixed-Width Courier Font
Courier-BoldOblique Bolded and Italicized Proportional-Width Helvetica Font
Helvetica Proportional-Width Helvetica Font
Helvetica-Bold Bolded Proportional-Width Helvetica Font
Helvetica-Oblique Italicized Proportional-Width Helvetica Font
Helvetica-BoldOblique Bolded and Italicized Proportional-Width Helvetica Font
Times Proportional-Width Times Roman Font
Times-Bold Bolded Proportional-Width Times Roman Font
Times-Italic Italicized Proportional-Width Times Roman Font
Times-BoldItalic Bolded and Italicized Proportional-Width Times Roman Font

2017-03-10 PDFinclude V2.4 Documentation 18


pdf_set_info

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Attribute Name as Character - The name of a valid attribute that can be set
Attribute Value as Character - The value you want to assign to the specified
Attribute

Sample Call: RUN pdf_set_info (“Spdf”,”Author”,”Gordon Campbell”)

Description:

This procedure allows you to set values that help you define attributes about the PDF document
itself. The following table outlines the settable attributes:

Attribute Description

Author Who created the document


Producer What is the primary producer of the document (eg: PDFinclude)
Creator What created the document (eg: The name of your procedure)
Keywords Keywords that will help identify the contents of the PDF document
Subject Any phrase that would describe the contents of the document
eg: Accounts Payable
Title Any phrase that would describe the contents of the document
eg: Vendor Listing

pdf_set_LeftMargin

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Margin Value as Character - The value you want to assign to the Left
Margin

Sample Call: RUN pdf_set_LeftMargin (“Spdf”,10)

Description:

This procedure allows you to set the number of points that the document will be indented from the
left-hand edge of the pages boundaries (identified by Page Height and Page Width).

pdf_set_Orientation

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Orientation as Character - How you would like the page oriented

Sample Call: RUN pdf_set_Orientation (“Spdf”,”Landscape”)

Description:
This procedure allows you to define how the page should be displayed … upright (Portrait) or
lengthwise (landscape). This value can be set before or after the Page Height or Page Width has
been set but must be set before the call to the pdf_new_page procedure.

Possible Values: Portrait or Landscape (Portrait is the default)

pdf_set_PageHeight

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Page Height as Integer - How tall is the page?

Sample Call: RUN pdf_set_PageHeight (“Spdf”,792)

Description:
This procedure allows you to define how tall (or wide if using Landscape orientation) the page
should be. This value can be set before or after the Page Width or Orientation has been set but
must be set before the call to the pdf_new_page procedure. As soon as this procedure is used,
the Paper Type is set to “CUSTOM”.

Possible Values: Any realistic integer value greater than zero

pdf_set_PageWidth

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Page Width as Integer - How wide is the page?

Sample Call: RUN pdf_set_PageHeight (“Spdf”,612)

Description:
This procedure allows you to define how wide (or tall if using Landscape orientation) the page
should be. This value can be set before or after the Page Height or Orientation has been set but
must be set before the call to the pdf_new_page function. As soon as this procedure is used, the
Paper Type is set to “CUSTOM”.

Possible Values: Any realistic integer value greater than zero

pdf_set_PaperType

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Page Type as Character - Enter a valid Paper Type

Sample Call: RUN pdf_set_PageType (“Spdf”,”LETTER”)

Description:

2017-03-10 PDFinclude V2.4 Documentation 20


This procedure allows you to select Paper Types that have predefined height and widths. The
following table outlines the valid Paper Types and their associate page dimensions.

Paper Type Width Height

A0 2380 3368
A1 1684 2380
A2 1190 1684
A3 842 1190
A4 595 842
A5 421 595
A6 297 421
B5 501 709
LETTER 612 792
LEGAL 612 1008
LEDGER 1224 792

The Widths and Heights identified in the preceding table are based on the Portrait orientation. If
you were to change the Orientation to ‘Landscape’ then the Width and Height columns would be
reversed.

pdf_set_parameter

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Parameter Name as Character - name of parameter to set
Parameter Value as Character - value to set parameter to

Sample Call: RUN pdf_set_parameter (“Spdf”,”Compress”,”True”)

Description:
This procedure allows you to set parameters associated with the specified PDF stream. The
following table outlines the valid parameter names and potential values (please note that with
using 40-bit encryption only certain parameters are useful or work).

Parameter Name Description

Compress The parameter allows you to specify that you want to compress the data
streams. Compression occurs before encryption.

Possible Values: TRUE or FALSE


Encrypt This parameter allows you to encrypt your data streams. Encryption
does not change the size of the data streams.

Possible Values: TRUE or FALSE


UserPassword This parameter allows you to add a User password to the document.
This password must be entered whenever the document is opened.

Possible Values: Any alpha-numeric character combination. Max 32


characters.
MasterPassword This parameter allows you to add a Master password to the document.
This password must be entered when trying to modify the security
settings.

Possible Values: Any alpha-numeric character combination. Max 32


characters.
EncryptKey This parameter allows you to specify the level of encryption. Currently
only handles 40-bit Encryption and is automatically set when the
‘Encrypt’ parameter is set to ‘TRUE’.

Possible Values: 40

(128 bit will be the other possible value in future versions)


AllowPrint This parameter allows you to specify whether the PDF document is
printable or not.

Possible Values: TRUE or FALSE


AllowCopy This parameter allows you to specify whether elements (such as text or
Graphics) can be copied or not.

Possible Values: TRUE or FALSE


AllowModify This parameter allows you to specify whether elements (such as Form
objects) can be modified or not.

Possible Values: TRUE or FALSE


AllowAnnots This parameter allows you to specify whether Annotations are allowed or
not.

Possible Values: TRUE or FALSE


AllowForms This parameter allows you to specify whether Forms processing can be
performed or not.

Possible Values: TRUE or FALSE


AllowExtract This parameter allows you to specify whether Extraction can be
performed or not.

Possible Values: TRUE or FALSE


AllowAssembly This parameter allows you to specify whether Assembly can be
performed or not.

Possible Values: TRUE or FALSE

pdf_set_TextBlue

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Value as Decimal - Value to set Blue option on RGB Colours

Sample Call: RUN pdf_set_TextBlue (“Spdf”,1.0)

Description:

2017-03-10 PDFinclude V2.4 Documentation 22


This procedure allows you to individually change the Blue value of the current RGB colour
scheme. That is, if you had previously set the font to Black (eg: Red=0, Blue=0, Green=0) then
you can easily change it to use blue text by running the sample call (as above). Then you can
easily set it back to black by using ‘RUN pdf_set_TextBlue (“Spdf”,0.0)’.

Possible Values: Any realistic decimal value between 0.0 and 1.0.

pdf_set_TextGreen

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Value as Decimal - Value to set Green option on RGB Colours

Sample Call: RUN pdf_set_TextGreen (“Spdf”,1.0)

Description:
This procedure allows you to individually change the Green value of the current RGB colour
scheme. That is, if you had previously set the font to Black (eg: Red=0, Blue=0, Green=0) then
you can easily change it to use green text by running the sample call (as above). Then you can
easily set it back to black by using ‘RUN pdf_set_TextGreen (“Spdf”,0.0).

Possible Values: Any realistic decimal value between 0.0 and 1.0.

pdf_set_TextRed

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Value as Decimal - Value to set Red option on RGB Colours

Sample Call: RUN pdf_set_TextRed (“Spdf”,1.0)

Description:
This procedure allows you to individually change the Red value of the current RGB colour
scheme. That is, if you had previously set the font to Black (eg: Red=0, Blue=0, Green=0) then
you can easily change it to use red text by running the sample call (as above). Then you can
easily set it back to black by using ‘RUN pdf_set_TextRed (“Spdf”,0.0)’.

Possible Values: Any realistic decimal value between 0.0 and 1.0.

pdf_set_TopMargin

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Margin Value as Character - The value you want to assign to the Top
Margin

Sample Call: RUN pdf_set_TopMargin (“Spdf”,50)


Description:

This procedure allows you to set the number of points that the document will be indented from the
top edge of the pages boundries (identified by Page Height and Page Width)

pdf_set_VerticalSpace

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Vertical Space as Integer - The value you want to assign to Vertical
Space

Sample Call: RUN pdf_set_VerticalSpace (“Spdf”,10)

Description:

This procedure allows you to set the number of points that represents the vertical spacing of lines.
A value of 12 is typical for Portrait oriented documents while 10 is fairly common for Landscape
oriented documents.

pdf_skip

Parameters: Stream Name as Character - Stream name as identified in pdf_new

Sample Call: RUN pdf_skip (“Spdf”)

Description:

This procedure will skip to the next line in the Text Space. This also updates the current TextX
and TextY attributes for the stream.

pdf_skipn

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Number of Lines as Integer - Number of lines to skip

Sample Call: RUN pdf_skipn (“Spdf”,2)

Description:

This procedure will skip n number of lines in the Text Space. This also updates the current TextX
and TextY attributes for the stream. This saves you calling pdf_skip multiple times.

pdf_stroke_color

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Red as Decimal - A decimal value not less than 0 and no

2017-03-10 PDFinclude V2.4 Documentation 24


greater than 1. Represents the Red
component of an RGB color value
Green as Decimal - A decimal value not less than 0 and no greater
than 1. Represents the Green component of
an RGB color value
Blue as Decimal - A decimal value not less than 0 and no greater
than 1. Represents the Blue component of an
RGB color value

Sample Call: RUN pdf_stroke_color (“Spdf”,1.0,0.0,0.0)

Description:

This procedure allows you to change the color PDF objects that are stroked. These include
stroked text (see pdf_text_render), lines, and rectangle borders.

pdf_stroke_fill

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Red as Decimal - A decimal value not less than 0 and no
greater than 1. Represents the Red
component of an RGB color value
Green as Decimal - A decimal value not less than 0 and no greater
than 1. Represents the Green component of
an RGB color value
Blue as Decimal - A decimal value not less than 0 and no greater
than 1. Represents the Blue component of an
RGB color value

Sample Call: RUN pdf_stroke_fill (“Spdf”,1.0,0.0,0.0)

Description:

This procedure allows you to change the color PDF objects that are filled. These include filled text
(see pdf_text_render), and rectangles.

pdf_text

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Text as Character - Any string value

Sample Call: RUN pdf_text (“Spdf”,”Hello World”)

Description:

This procedure allows you to place the passed text string at the current TextX and TextY Text
Space points.
pdf_text_at

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Text as Character - Any string value
Column as Integer - Any non-zero integer value

Sample Call: RUN pdf_text_at (“Spdf”,”Hello World”,60)

Description:

This procedure allows you to place the passed text string at column 60 (determined by current
PointSize * passed Column Value) on the current Text row (TextX).

Note: The column value entered here is determined by the actual row that you would like to see
the text appear beginning at. That is, assuming a PointSize of 10, instead of entering 600 to have
the text begin at Column 60, just enter 60.

pdf_text_boxed_xy

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Text as Character - Any string value
Column as Integer - Any non-zero integer value
Row as Integer - Any non-zero value
Width as Integer
Height as Integer
Justify as Character - Currently Unused
Weight as Integer - Weight of Boxes line

Sample Call: RUN pdf_text_boxed_xy (“Spdf”,”Hello World”,10,100,15,105,”LEFT”,1)

Description:

This procedure allows you to specifically place the passed text string at the passed Row and
Column. A box will be placed around the text.

Note: The column and row values passed to this function should represent the actual PDF points.
That is , unlike pdf_text_at, if you want to have the text appear at point 600 then enter 600 (not
60).

pdf_text_center

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Text as Character - Any string value
Column as Integer - Any non-zero integer value
Rowas Integer - Any non-zero integer value

Sample Call: RUN pdf_text (“Spdf”,”This is Centered Text”,50,100)

Description:

2017-03-10 PDFinclude V2.4 Documentation 26


This centers the passed text on the given X,Y point.

pdf_text_color

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Red as Decimal - A decimal value not less than 0 and no
greater than 1. Represents the Red
component of an RGB color value
Green as Decimal - A decimal value not less than 0 and no
greater than 1. Represents the Green
component of an RGB color value
Blue as Decimal - A decimal value not less than 0 and no
greater than 1. Represents the Blue
component of an RGB color value

Sample Call: RUN pdf_textcolor (“Spdf”,1.0,0.0,0.0)

Description:

This procedure allows you to set the color that the following text displays should appear in.

pdf_text_render

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Render Type as Integer - An integer value representing how to render
the text
Sample Call: RUN pdf_text_render (“Spdf”, 0)

Description:

This procedure allows you to define how the text will be rendered. There are four possible values
and they are outlined below.

Render Type Description

0 Fill Text
1 Stroke Text
2 Fill, then Stroke Text
3 Neither Fill nor Stroke Text (invisible)

pdf_text_rotate

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Angle as Integer - Angle to rotate and display text in

Sample Call: RUN pdf_skip (“Spdf”, 90)


Description:

This procedure will set the rotation angle for displaying text in. This must be run before you
display the text you want rotated.

Possible Values are:


0 – 0 Degrees (default)
90 – 90 Degrees
180 – 180 Degrees
270 – 270 Degrees

pdf_text_to

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Text as Character - Any string value
Column as Integer - Any non-zero value

Sample Call: RUN pdf_text_to (“Spdf”,”Hello World”,30)

Description:
This procedure allows you to place the passed text string right-aligned to the specified column
(determined by current PointSize * passed Column Value) on the current Text row (TextX).

Note: The column value entered here is determined by the actual row that you would like to see
the text appear beginning at. That is, assuming a PointSize of 10, instead of entering 600 to have
the text begin at Column 60, just enter 60.

pdf_text_xy

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Text as Character - Any string value
Column as Integer - Any non-zero value
Row as Integer - Any non-zero value

Sample Call: RUN pdf_text_xy (“Spdf”,”Hello World”,10,100)

Description:
This procedure allows you to specifically place the passed text string at the passed Row and
Column.

Note: The column and row values passed to this procedure should represent the actual PDF
points. That is , unlike pdf_text_at, if you want to have the text appear at point 600 then enter 600
(not 60).

pdf_Watermark

2017-03-10 PDFinclude V2.4 Documentation 28


Parameters: Stream Name as Character - Stream name as identified in pdf_new
Text as Character - Text value to display
Font as Character - Name of Font to display Text in
FontSize as Integer - How large the text should appear
Red as Decimal - Value to set Red option for text Colour
Blue as Decimal - Value to set Blue option for text Colour
Green as Decimal - Value to set Green option for text Colour
X as Integer - X location to display text at
Y as Integer - Y location to display text at

Sample Call: RUN pdf_set_TextRed


(“Spdf”,
“Sample Report”,
“Courier”,
16,
1.0,
0.0,
0,0,
100,
500)

Description:
This procedure allows you to place a text watermark into the PDF document. The watermark will
appear only on the Page where it is issued, so if you want to have it appear on all pages ensure
that the command is reissued whenever a new page is issued.

pdf_Wrap_Text

Parameters: Stream Name as Character - Stream name as identified in pdf_new


Text as Character - Text value to display
From Column as Integer - Column at which to start Text output
To Column as Integer - Column to stop Text Output
Alignment as Character - how to align the text – left or right aligned?
Max Y as Integer - OUTPUT variable

Sample Call: RUN pdf_set_TextRed


(“Spdf”,
“This is a lot of text that could include line breaks etc”,
10,
20,
“left”,
OUTPUT CurrentY).

Description:
This procedure allows you to place text into the PDF document within a from/to column location.
If the text is longer than the from/to location then it will automatically wrap the text to the next line
and place the remaining text within the same from/to location as the previous line. This is useful
when printing character fields that have been input via an Editor widget.
2017-03-10 PDFinclude V2.4 Documentation 30
4. Function List
pdf_Angle

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_Angle (“Spdf”)

Description:

This function returns the currently set angle that is being used for the Text Rotation.

pdf_BottomMargin

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_BottomMargin (“Spdf”)

Description:

This function returns the currently set value of the PDF pages Bottom Margin.

pdf_Font

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Character
Sample Call: pdf_Font (“Spdf”)

Description:

This function returns the currently selected font that is being used to display text.

pdf_get_info

Arguments: Stream Name as Character - Stream name as identified in pdf_new


Attribute Name as Character - One of the valid Attributes (see below)
Returns: Character
Sample Call: pdf_get_info (“Spdf”)

Description:
This function returns the value of the specified Document Information attribute.
Possible attributes are listed in the table below:

Attribute Description

Author Who created the document


Creator What created the document (eg: PDFinclude or the name of your
procedure)
Keywords Keywords that will help identify the contents of the PDF document
Subject Any phrase that would describe the contents of the document
eg: Accounts Payable
Title Any phrase that would describe the contents of the document
eg: Vendor Listing

pdf_get_NumFittingChars

Arguments: Stream Name as Character - Stream name as identified in pdf_new


Text as Character - Text value to check
Required Width as Integer - Maximum width required

Returns: Integer
Sample Call: pdf_get_NumFittingChars
(“Spdf”,
“This is my text example”,
10).

Description:

This function returns the index of the last character that will fit into the specified width. It does this
by summing each characters AFM width (as specified in the tt_pdf_font.font_width array) and
comparing with the required width (converted into these same units).

pdf_get_parameter

Arguments: Stream Name as Character - Stream name as identified in pdf_new


Parameter Name as Character - One of the valid parameter names
Returns: Character
Sample Call: pdf_get_parameter (“Spdf”,”Encrypt”)

Description:

This function returns the value of the specified Document parameter. For a list of valid document
parameters see the ‘pdf_set_parameter’ procedure.

pdf_get_wrap_length

Arguments: Stream Name as Character - Stream name as identified in pdf_new


Text as Character - Text value to check
Width as Integer - Maximum width required

2017-03-10 PDFinclude V2.4 Documentation 32


Returns: Integer
Sample Call: pdf_get_NumFittingChars
(“Spdf”,
“This is my text example”,
10).

Description:

You can use the function to see how long a piece of text WOULD be if you were to wrap it.

pdf_GraphicX

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_GraphicX (“Spdf”)

Description:

This function returns the value of the current X (Column) location of the Graphic State.

pdf_GraphicY

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_GraphicY (“Spdf”)

Description:

This function returns the value of the current Y (Column) location of the Graphic State.

pdf_GraphicY

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_GraphicY (“Spdf”)

Description:

This function returns the value of the current Y (Column) location of the Graphic State.

pdf_ImageDim
Arguments: Stream Name as Character - Stream name as identified in pdf_new
Image Name as Character - Image name as defined with a
pdf_load_image
Dimenstion Type as Character - Either HEIGHT or WIDTH

Returns: Integer
Sample Call: pdf_ImageDim (“Spdf”,”Logo”,”HEIGHT”)

Description:

This function returns the value of the Image Dimension that was requested with Dimension Type
input parameter. This is useful because when you load the image you don’t know the Image
Width or Height. With this function you can determine either.

pdf_Orientation

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Character
Sample Call: pdf_Orientation (“Spdf”)

Description:

This function returns the value of the Orientation parameter. The Orientation parameter is used to
define how the page appears.

Possible Values: Portrait or Landscape

pdf_Page

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_Page (“Spdf”)

Description:

This function returns the value of the current Page parameter. The Page parameter is
incremented after every call to a pdf_new_page.

pdf_PageFooter

Arguments: Stream Name as Character - Stream name as identified in pdf_new


Proc Handle as Handle - Handle to ‘called from’ procedure
Footer Name as Character - Footer procedure name from calling procedure

Returns: Logical
Sample Call: pdf_PageFooter (“Spdf”, THIS-PROCEDURE:HANDLE, “PageFooter”)

2017-03-10 PDFinclude V2.4 Documentation 34


Description:

This function notified PDFinclude that the calling report procedure has a Page Footer procedure
associated with it. If this has been set (with a non-blank value) then whenever a text element is to
be displayed below the Bottom Margin (set by pdf_set_BottomMarging) this procedure (eg:
PageFooter) will be called.

pdf_PageHeader

Arguments: Stream Name as Character - Stream name as identified in pdf_new


Proc Handle as Handle - Handle to ‘called from’ procedure
Header Name as Character - Header procedure name from calling procedure

Returns: Logical
Sample Call: pdf_PageHeader (“Spdf”, THIS-PROCEDURE:HANDLE, “PageHeader”)

Description:

This function notified PDFinclude that the calling report procedure has a Page Header procedure
associated with it. If this has been set (with a non-blank value) then on each call to
pdf_new_page this procedure (eg: PageHeader) will be called.

pdf_PageHeight

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_PageHeight (“Spdf”)

Description:

This function returns the value of the current Page Height parameter. The Page Height parameter
is used to determine the page boundaries. The Page Height parameter can either be set directly
by using pdf_set_PageHeight or indirectly by calling pdf_PaperType.

pdf_PageWidth

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_PageWidth (“Spdf”)

Description:
This function returns the value of the current Page Width parameter. The Page Width parameter
is used to determine the page boundaries. The Page Width parameter can either be set directly
by using pdf_set_PageWidth or indirectly by calling pdf_PaperType.

pdf_PaperType

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Character
Sample Call: pdf_PaperType (“Spdf”)

Description:

This function returns the value of the current Paper Type parameter. The Paper Type parameter
is used to determine the page boundaries. The Paper Type parameter is set by calling
pdf_set_parameter and selecting a valid Paper Type or by calling pdf_set_PageHeight or
pdf_set_PageWidth. Calling either of the two latter functions will set the Paper Type to
‘CUSTOM’.
Valid Paper Types are:

Paper Type Width Height

A0 2380 3368
A1 1684 2380
A2 1190 1684
A3 842 1190
A4 595 842
A5 421 595
A6 297 421
B5 501 709
LETTER 612 792
LEGAL 612 1008
LEDGER 1224 792

The Widths and Heights identified in the preceding table are based on the Portrait orientation. If
you were to change the Orientation to ‘Landscape’ then the Width and Height columns would be
reversed.

pdf_PointSize

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_PointSize (“Spdf”)

Description:

2017-03-10 PDFinclude V2.4 Documentation 36


This function returns the value of the current Point Size parameter. The Point Size parameter is
used to determine how large a text object will be drawn on the PDF page. The Point Size is set by
calling the pdf_set_Font function.

pdf_Render

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_Render (“Spdf”)

Description:

This function returns the value of the current Text Rendering parameter. The Test Rendering
parameter is used to determine how the text will be drawn on the PDF page. The Text Rendering
parameter is set by calling the pdf_Text_Render function.
The following table outline the possible values for the Text Rendering parameter:

Render Type Description

0 Fill Text
1 Stroke Text
2 Fill, then Stroke Text
3 Neither Fill nor Stroke Text (invisible)

pdf_text_width

Arguments: Stream Name as Character - Stream name as identified in pdf_new


Text Value as Character - The text you want to determine the width of

Returns: Integer
Sample Call: pdf_text_width (“Spdf”,”End of Report”)

Description:
This function allows you to determine the length (in points) of the passed text string. The width is
calculated as follows:
width = (LENGTH(text value) * individual character lengths / 1000) * pdf_PointSize(PDF Stream)

The individual character lengths may differ for each character within a given font. The
accumulation of the total character widths divided by 1000 then multiplied by the current font Point
Size. This function is useful when used in conjunction with the pdf_text_boxed_xy function
(allowing you to determine how wide the box around the text should be).

pdf_TextBlue

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Decimal
Sample Call: pdf_TextBlue (“Spdf”)
Description:
This function allows you to determine what the current Blue value of the current RGB setting is.

pdf_TextGreen

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Decimal
Sample Call: pdf_TextGreen (“Spdf”)

Description:
This function allows you to determine what the current Green value of the current RGB setting is.

pdf_TextRed

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Decimal
Sample Call: pdf_TextRed (“Spdf”)

Description:
This function allows you to determine what the current Red value of the current RGB setting is.

pdf_TextX

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_TextX(“Spdf”)

Description:

This function returns the current X (Column) location within the Text Space.

pdf_TextY

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_TextY (“Spdf”)

Description:

This function returns the current Y (Row) location within the Text Space.

2017-03-10 PDFinclude V2.4 Documentation 38


pdf_TotalPages

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Character
Sample Call: pdf_TotalPages (“Spdf”)

Description:

This function allows you to include the Total Number of Pages for the document directly into your
report. For instance, if you wanted to have 'Page n of x' as your Page footer then you can
implement this with pdf_TotalPages(streamname).

pdf_TopMargin

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_TopMargin (“Spdf”)

Description:

This function returns the current Top Margin point setting.

pdf_VerticalSpace

Arguments: Stream Name as Character - Stream name as identified in pdf_new

Returns: Integer
Sample Call: pdf_VerticalSpace (“Spdf”)

Description:

This function returns the current point size for the Vertical Space. The Vertical Space is used to
define the spacing between lines.
5. Internal Procedures and Functions
This section outlines the other procedures and functions that are used within PDFinclude. These
procedure and functions should not be used within programs as they may cause issues when
developing a PDF document.

Name Type Description

First_Marker Function Used in determination of Image Dimensions


Hex Function Used in determination of Image Dimensions
Nextbyte Function Used in determination of Image Dimensions
Next2Bytes Function Used in determination of Image Dimensions
Next_Marker Function Used in determination of Image Dimensions
ObjectSequence Function Used to increment the PDF Object Counter. The
objects represent different dictionaries within the PDF
document. The start and end bytes of each Object
must be stored so that the XREF dictionary can be
built correctly.
Pdf_Catalog Procedure This procedure creates the PDF Catalog Object.
Pdf_Content Procedure This procedure is the main content generator of the
PDF document.
Pdf_Definition Procedure This procedure creates the Page Dictionaries (and
Annotations) for the PDF document.
pdf_error Procedure This procedure is used to track errors that have
occurred during the building of the PDF document.
Sample errors include incorrectly defined parameter
options or incorrect stream names. Any errors are
displayed to the default Progress stream and the PDF
document is not generated.
pdf_set_Angle Procedure This procedure stores the value of the Angle as
defined in pdf_Text_Rotation so that it can be
retrieved via pdf_Angle.
Pdf_Encoding Procedure This procedure creates the PDF Encoding Object.
Pdf_Fonts Procedure This procedure creates the appropriate Font
Dictionaries for Base 14 fonts.
Pdf_FontType Function This function returns whether the current font is
FIXED or VARIABLE (Proportional)
Pdf_Get_Image_WH Procedure Used in determination of Image Dimensions
Pdf_Header Procedure Output the beginning of the PDF Document plus the
Document Information Object (Object #1)
Pdf_inc_ContentSequence Function This function increments the Object Sequence
(Object Number).
Pdf_init_param Procedure This procedure initializes the PDF document for a
given stream.
Pdf_Length Procedure This procedure writes the Length Object for another
associated Object. Example, a Page object would
have an associated Length Object.
Pdf_ListPages Procedure This procedure writes the Page Object Dictionary.
Pdf_LoadBase14 Procedure This procedure loads the Base 14 fonts, for a PDF
stream, so that the font can be used when generating
the PDF (eg: when using pdf_Set_font)
Pdf_Load_Fonts Procedure This procedure writes the Font Dictionaries for the
TTF Fonts that were embedded via pdf_load_font.

2017-03-10 PDFinclude V2.4 Documentation 40


Pdf_Load_Images Procedure This procedure writes the Image Dictionaries for the
JPEG Images that were embedded via
pdf_load_image.
Pdf_Load_Links Procedure This procedure writes the Annotation Dictionaries for
the links that were included via pdf_link.
Pdf_LoadParseAFMFile Procedure This procedure parses the AFM file specified in a
pdf_Load_font call.
Pdf_Replace_Text Procedure This procedure replaces any special characters in the
content that would result in an invalid PDF being
generated.
Pdf_Resources Procedure This procedure writes the Resource Object
Dictionary.
pdf_set_GraphicX Procedure This procedure sets the current graphic plane X axis
location whenever a graphic element is added to the
PDF document.
pdf_set_GraphicY Procedure This procedure sets the current graphic plane Y axis
location whenever a graphic element is added to the
PDF document.
pdf_set_page Procedure This procedure increment the PDF page number
whenever a new page is required.
pdf_set_TextX Procedure This procedure sets the current text plane X axis
location whenever a text element is added to the PDF
document.
pdf_set_TextY Procedure This procedure sets the current text plane Y axis
location whenever a text element is added to the PDF
document.
Pdf_Xref Procedure This procedure writes the XREF Object Dictionary.
Process_SOF Function Used in determination of Image Dimensions
Skip_Variable Function Used in determination of Image Dimensions
6. How to Implement Page Headers and Footers
In Version 1.3 of PDFinclude the ability to create Page Header and Page Footers was
implemented. Page Headers and Footers allow you to define code blocks that will appear
whenever a page is generated. The code blocks allow you to include both text and graphic
elements into your PDF document.

Page Headers appear whenever a call to pdf_new_page is issued. The Page Header is
generated before anything else can be included in the PDF content of the page, ensuring that the
Page Header content actually appears at the top of the page … unless you’ve used an element
that uses specific X/Y positioning (eg: pdf_text_xy or pdf_place_image), then that element can be
placed anywhere on the current page (useful if you wanted a watermark to appear on a page).

Page Footers appear only if you have set the Bottom Margin of the page (using
pdf_set_BottomMargin). If any text elements (except X/Y positional text elements) are going to be
displayed below the Bottom Margin setting, then the Page Footer code block is run and a call to
pdf_new_page is issued .. to automatically increment the PDF paging. Ensure that when you call
pdf_set_BottomMargin you set the value to something that will allow your Footer to appear
correctly. That is, if you set the value to low (say 10) you may not get a page footer, or if your
footer included graphic elements those elements may overlay some of the text.

To create Page Footers and Page Headers for a report, you need to create code blocks
(procedures) in your program that will generate the appropriate output. For example, the following
procedure illustrates a PageFooter:

PROCEDURE PageFooter:
/*------------------------------------------------------------------------------
Purpose: Procedure to Print Page Footer -- on all pages.
------------------------------------------------------------------------------*/
/* Display a Sample Watermark on every page */
RUN pdf_watermark ("Spdf","Customer List","Courier-Bold",34,.87,.87,.87,175,500).

RUN pdf_skip ("Spdf").


RUN pdf_set_dash ("Spdf",1,0).
RUN pdf_line ("Spdf", 0, pdf_TextY("Spdf") - 5, pdf_PageWidth("Spdf") - 20 ,
pdf_TextY("Spdf") - 5, 1).
RUN pdf_skip ("Spdf").
RUN pdf_skip ("Spdf").
RUN pdf_text_to ("Spdf", "Page: "
+ STRING(pdf_page("Spdf"))
+ " of " + pdf_TotalPages("Spdf"), 97).

vlines = 1. /* Restart our count for the linking */

END. /* PageFooter */

But this code won’t be run unless we communicate this procedure to PDFinclude. To do that you
need to make the appropriate call. The two calls (functions) that notify PDfinclude that you have
included headers and footers in your report are:

pdf_PageFooter (<stream name>,THIS-PROCEDURE:HANDLE, <Procedure Name>).


pdf_PageHeader (<stream name>,THIS-PROCEDURE:HANDLE, <Procedure Name>).

2017-03-10 PDFinclude V2.4 Documentation 42


So, for our footer example, we would need to include the following function call (after referencing
pdf_inc.i) in our program.
pdf_PageFooter (“Spdf”,THIS-PROCEDURE:HANDLE,"PageFooter").

This function call lets PDFinclude know that we have a footer procedure in our calling program.
7. How to Implement Compression
The ability to compress data streams was implemented in version 2.3 of PDFinclude.

PDFinclude uses the zlib library to implement Flate compression. Zlib is a free open-source
project and the binaries (or source) for many operating systems can be found at www.zlib.net.

Steps to implementing compression:


1. Download and install the appropriate binary from www.zlib.net

2. Open the file zlibbind.p Progress procedure in the PDFinclude download. Change the
zlib pre-processor to point to the appropriate DLL or Shared Library object.

3. Add the following command to each of the PDF documents that you wish to compress:

RUN pdf_set_parameter(<stream name>,”Compress”,”TRUE”).

This statement can be run anytime between the calls to ‘pdf_new’ and ‘pdf_close’. If you
happen to run the statement multiple times before ‘pdf_close’, then the last call will be
used to determine whether compression is to be used or not.

4. Run your code and you will see a reduction in your PDF filesize.

Currently, PDFinclude does not compress images. You can expect this in future versions.

2017-03-10 PDFinclude V2.4 Documentation 44


8. How to Implement Encryption
The ability to encrypt data streams was implemented in version 2.4 of PDFinclude. The
Encrypted of the data stream is performed after compression … if compression is used that is.

PDFinclude uses the external binaries and DLL or Shared Library objects to perform the
encryption. Initially the encryption was implemented using pure 4GL components but the
encryption was way too slow. For example, it would take almost 20 seconds to encrypt the simple
‘Hello World’ example …. a simple one-page Customer Listing was taking almost 50 seconds.
These timings were unacceptable, hence the requirement for external utilities.

The Windows DLL (procryptlib.dll) is included in the download.

If you are on a *NIX OS then you will need to compile the rc4.c object into a Shared Library (I
currently don’t have instructions on how to do that …. so if someone actually reads this then
please forward the instructions to me at gcampbell@epro-sys.com - TIA).

Steps to implementing encryption:

1. Copy pdfencrypt.p and pdfencryptlib.p to the same location as pdf_inc.p etc

2. Edit pdfencrypt.p and modify the pre-processor MD5LIB to point to the appropriate md5
routine.

On Windows: use the md5.exe binary included in the download


On *NIX: point to the appropriate *NIX command (eg: /usr/lib/md5sum)

3. Edit pdfencryptlib.p and modify the pre-processor pdfencryptlib to point to the


appropriate DLL or Shared Library object (this will contain the external function
‘endecrypt’)

4. Add the following command to each of the PDF documents that you wish to encrypt:

RUN pdf_set_parameter(<stream name>,”Encrypt”,”TRUE”).

This statement can be run anytime between the calls to ‘pdf_new’ and ‘pdf_close’. If you
happen to run the statement multiple times before ‘pdf_close’, then the last call will be
used to determine whether encryption is to be used or not.

You can also set the Allow*, UserPassword and/or MasterPassword document
parameters to determine the permissions (see ‘pdf_set_parameter’ procedure
documentation for more info) associated with the PDF document.

5. Run your procedures and see the encrypted (or protected) PDF document.

Currently PDFinclude only uses 40-Bit encryption.


9. Sports2000 Samples
This sections gives a couple of sample procedures to run against the Sports2000 database that is
typically supplied with the Progress Installation.

The Samples assume that:


1. You are connected to the Sports2000 database
2. You have pdf_inc.i in your PROPATH
3. You have Acrobat Reader (or some other PDF viewer) installed on you machine
4. You have the free Code39 BarCode downloaded from www.barcodetrader.com.
5. You have created the code39.afm file using ttf2pt1 (See Appendix B)
6. You will need to change the directories used for file storage and retrieval (eg: the samples
use c:\sports2000 you may use another directory for testing).

9.1 Hello World

The following sample produces a minimal PDF document. The output file is included in the Zipped
download and is called hello.pdf.

{ ./pdf_inc.i }
RUN pdf_new ("Spdf","c:\sports2000\PDFinc\hello.pdf").
RUN pdf_new_page("Spdf").
RUN pdf_text ("Spdf", "Hello World").
RUN pdf_close("Spdf").

9.2 Hello World – Compressed and Encrypted


The following sample produces a minimal PDF document that is both compressed and encrypted.

{ ./pdf_inc.i }
RUN pdf_new ("Spdf","c:\sports2000\PDFinc\hello-encrypt.pdf").
RUN pdf_new_page("Spdf").
RUN pdf_set_parameter("Spdf",”Encrypt”,”TRUE”).
RUN pdf_set_parameter("Spdf",”Compress”,”TRUE”).
RUN pdf_text ("Spdf", "Hello World").
RUN pdf_close("Spdf").

9.3 Text Positioning

The following sample produces a PDF document displaying the different type of Text options
available. The output file is included in the Zipped download and is called text.pdf.

{ ./pdf_inc.i }

RUN pdf_new ("Spdf","c:\sports2000\PDFinc\text.pdf").

2017-03-10 PDFinclude V2.4 Documentation 46


RUN pdf_new_page("Spdf").

/* Place some text */


RUN pdf_text ("Spdf", FILL("123456789 ",8)).
RUN pdf_skip ("Spdf").
RUN pdf_text_at ("Spdf", "Position AT Column 10",10).
RUN pdf_text_to ("Spdf", "Position TO Column 70",70).
RUN pdf_text ("Spdf", "Text placed at last X/Y Coordinate").
RUN pdf_skip ("Spdf").

/* Change the text color to red */


RUN pdf_text_color("Spdf",1.0,.0,.0).

RUN pdf_set_font("Spdf","Courier",14.0).
RUN pdf_text_xy ("Spdf","This is text placed using XY coordinates",100,500).
RUN pdf_set_font("Spdf","Courier",10.0).

/* Change the text color back to black */


RUN pdf_text_color("Spdf",.0,.0,.0).

/* Change the Rectangle border to red and the fill to white */


RUN pdf_stroke_color("Spdf",1.0,.0,.0).
RUN pdf_stroke_fill("Spdf",1.0,1.0,1.0).

/* Display a boxed text string */


RUN pdf_text_boxed_xy ("Spdf",
"This is BOXED text placed using XY coordinates",
100,
450,
pdf_text_width("Spdf", "This is BOXED text placed using XY coordinates"),
10,"Left",1).

RUN pdf_close("Spdf").

9.4 Customer Listing

This sample produces a Customer Listing that illustrates how to create a basic PDF report. The
output file is included in the Zipped download and is called custlist.pdf.

Copy the following code into your Editor and run.


/* custlist.p - sample PDF generation */

{ ./pdf_inc.i }

DEFINE VARIABLE Vlines AS INTEGER NO-UNDO.


DEFINE VARIABLE Vpage AS INTEGER NO-UNDO.
DEFINE VARIABLE Vold_Y AS INTEGER NO-UNDO.

/* Create stream for new PDF file */


RUN pdf_new ("Spdf","c:\sports2000\PDFinc\custlist.pdf").

/* Load Bar Code Font */


RUN pdf_load_font ("Spdf","Code39","c:\windows\fonts\code39.ttf","c:\sports2000\code39.afm").

/* Load PRO-SYS Logo File */


RUN pdf_load_image ("Spdf","ProSysLogo","c:\sports2000\pdfinc\prosyslogo.jpg",1354,166).

/* Set Document Information */


RUN pdf_set_info("Spdf","Author","Gordon Campbell").
RUN pdf_set_info("Spdf","Subject","Accounts Receivable").
RUN pdf_set_info("Spdf","Title","Customer List").
RUN pdf_set_info("Spdf","Keywords","Customer List Accounts Receivable").
RUN pdf_set_info("Spdf","Creator","PDFinclude").
RUN pdf_set_info("Spdf","Producer","custlist.p").

/* Instantiate a New Page */


RUN new_page.

/* Loop through appropriate record set */


FOR EACH customer WHERE NAME BEGINS "AB" NO-LOCK
BREAK BY State
BY CustNum:

/* Output the appropriate Record information */


RUN pdf_set_font ("Spdf","Courier-Oblique",10.0).
RUN pdf_text_at ("Spdf", customer.state,1).
RUN pdf_set_font ("Spdf","Courier",10.0).
RUN pdf_text_at ("Spdf", STRING(customer.CustNum,">>>9"),6).
RUN pdf_text_at ("Spdf", customer.NAME,12).
RUN pdf_text_at ("Spdf", customer.phone,44).
RUN pdf_text_to ("Spdf", STRING(customer.balance),80).

/* Display a BarCode for each Customer Number */


RUN pdf_set_font ("Spdf","Code39",10.0).

Vold_Y = pdf_TextY("Spdf"). /* Store Original Text Path */


RUN pdf_text_xy ("Spdf", STRING(customer.CustNum,"999999"),500, pdf_textY("Spdf")).
RUN pdf_set_TextY("Spdf",Vold_y). /* Reset Original Text Path */
RUN pdf_set_font ("Spdf","Courier",10.0).

/* Skip to Next Line */


RUN pdf_skip ("Spdf").

/* Process Line Counter */


Vlines = Vlines + 1.
IF Vlines = 60 THEN
RUN new_page.

IF LAST-OF(State) THEN DO:


IF Vlines + 2 > 60 THEN
RUN new_page.

2017-03-10 PDFinclude V2.4 Documentation 48


/* Put a red line between each of the states */
RUN pdf_skip ("Spdf").
RUN pdf_stroke_color ("Spdf",1.0,.0,.0).
RUN pdf_set_dash ("Spdf",2,2).
RUN pdf_line ("Spdf", pdf_LeftMargin("Spdf") , pdf_TextY("Spdf") + 5, pdf_PageWidth("Spdf") - 20 ,
pdf_TextY("Spdf") + 5, 1).
pdf_stroke_color ("Spdf",.0,.0,.0).
pdf_skip ("Spdf").

Vlines = Vlines + 2.
END. /* Last-of State */
END.

RUN end_of_report.

RUN pdf_close("Spdf").

/* -------------------- INTERNAL PROCEDURES -------------------------- */

PROCEDURE new_page:

/* Display Footer UnderLine */


IF Vpage > 0 THEN
RUN page_footer.

RUN pdf_new_page("Spdf").

Vpage = Vpage + 1.

/* Place Logo but only on first page of Report */


IF Vpage = 1 THEN DO:
RUN pdf_place_image ("Spdf","ProSysLogo",pdf_LeftMargin("Spdf"), pdf_TopMargin("Spdf") - 20
,179,20).
END.

/* Set Header Font Size and Colour */


RUN pdf_set_font ("Spdf","Courier-Bold",10.0).
RUN pdf_text_color ("Spdf",1.0,.0,.0).

/* Put a Rectangle around the Header */


RUN pdf_stroke_color ("Spdf", .0,.0,.0).
RUN pdf_stroke_fill ("Spdf", .9,.9,.9).
RUN pdf_rect ("Spdf", pdf_LeftMargin("Spdf"), pdf_TextY("Spdf") - 3, pdf_PageWidth("Spdf") - 30 ,
pdf_TextX("Spdf") + 12).

/* Output Report Header */


RUN pdf_text_at ("Spdf","St",1).
RUN pdf_text_at ("Spdf","Nbr",6).
RUN pdf_text_at ("Spdf","Customer Name",12).
RUN pdf_text_at ("Spdf","Phone Number",44).
RUN pdf_text_to ("Spdf","Balance",80).

/* Display Header UnderLine */


RUN pdf_skip ("Spdf").
RUN pdf_set_dash ("Spdf",1,0).
RUN pdf_line ("Spdf", pdf_LeftMargin("Spdf"), pdf_TextY("Spdf") + 5, pdf_PageWidth("Spdf") - 20 ,
pdf_TextY("Spdf") + 5, 2).
RUN pdf_skip ("Spdf").

/* Set Detail Font Colour */


RUN pdf_text_color ("Spdf",.0,.0,.0).
Vlines = 3.
END. /* new_page */

PROCEDURE page_footer:
RUN pdf_skip ("Spdf").
RUN pdf_set_dash ("Spdf",1,0).
RUN pdf_line ("Spdf", 0, pdf_TextY("Spdf") - 5, pdf_PageWidth("Spdf") - 20 , pdf_TextY("Spdf") - 5, 2).
RUN pdf_skip ("Spdf").
RUN pdf_skip ("Spdf").
RUN pdf_text_to ("Spdf","Page: " + STRING(Vpage), 97).
END. /* page_footer */

PROCEDURE end_of_report:
RUN page_footer.

/* Display Footer UnderLine and End of Report Tag (Centered) */


RUN pdf_skip ("Spdf").
RUN pdf_stroke_fill ("Spdf",1.0,1.0,1.0).
RUN pdf_text_boxed_xy ("Spdf", "End of Report", 250, pdf_TextY("Spdf") - 20,
pdf_Text_Width("Spdf","End Of Report"), 12, "Left",1).
END. /* end_of_report */

/* end of custlist.p */

9.5 Formatted Item Listing

This sample produces a Item Listing that illustrates how you can control the output of a fairly
custom PDF report. The output file is included in the Zipped download and is called itemlist.pdf.

Copy the following code into your Editor and run.

/* itemlist.p - sample PDF generation */

{ ./pdf_inc.i }

DEFINE VARIABLE Vitems AS INTEGER NO-UNDO.


DEFINE VARIABLE Vrow AS INTEGER NO-UNDO.
DEFINE VARIABLE Vcat-desc AS CHARACTER EXTENT 4 FORMAT "X(40)" NO-UNDO.

/* Create stream for new PDF file */


RUN pdf_new ("Spdf","c:\sports2000\PDFinc\itemlist.pdf").

/* Load Bar Code Font */


RUN pdf_load_font ("Spdf","Code39","c:\windows\fonts\code39.ttf","c:\sports2000\code39.afm").

/* Set Document Information */


RUN pdf_set_info("Spdf","Author","Gordon Campbell").
RUN pdf_set_info("Spdf","Subject","Inventory").
RUN pdf_set_info("Spdf","Title","Item Catalog").
RUN pdf_set_info("Spdf","Keywords","Item Catalog Inventory").
RUN pdf_set_info("Spdf","Creator","PDFinclude").
RUN pdf_set_info("Spdf","Producer","itemlist.p").

/* Instantiate a New Page */


RUN new_page.

/* Loop through appropriate record set */


FOR EACH ITEM NO-LOCK
BREAK BY ItemNum:

2017-03-10 PDFinclude V2.4 Documentation 50


RUN display_item_info.

/* Process Record Counter */


Vitems = Vitems + 1.
IF Vitems = 6 THEN
RUN new_page.

END.

RUN pdf_close("Spdf").

/* -------------------- INTERNAL PROCEDURES -------------------------- */

PROCEDURE display_item_info:

/* Draw main item Box */


RUN pdf_stroke_fill("Spdf",.8784,.8588,.7098).
RUN pdf_rect ("Spdf", pdf_LeftMargin("Spdf"), Vrow, pdf_PageWidth("Spdf") - 20 , 110).

/* Draw Smaller box (beige filled) to contain Category Description */


RUN pdf_rect ("Spdf", 350, Vrow + 10, 240, 45).

/* Draw Smaller box (white filled) to contain Item Picture (when avail) */
RUN pdf_stroke_fill("Spdf",1.0,1.0,1.0).
RUN pdf_rect ("Spdf", pdf_LeftMargin("Spdf") + 10, Vrow + 10, pdf_LeftMargin("Spdf") + 100 , 90).

/* Display Labels with Bolded Font */


RUN pdf_set_font("Spdf","Courier-Bold",10.0).
RUN pdf_text_xy ("Spdf","Part Number:", 140, Vrow + 90).
RUN pdf_text_xy ("Spdf","Part Name:", 140, Vrow + 80).
RUN pdf_text_xy ("Spdf","Category 1:", 140, Vrow + 40).
RUN pdf_text_xy ("Spdf","Category 2:", 140, Vrow + 30).
RUN pdf_text_xy ("Spdf","Qty On-Hand:", 350, Vrow + 90).
RUN pdf_text_xy ("Spdf","Price:", 350, Vrow + 80).
RUN pdf_text_xy ("Spdf","Category Description:", 350, Vrow + 60).

/* Display Fields with regular Font */


RUN pdf_set_font("Spdf","Courier",10.0).
RUN pdf_text_xy ("Spdf",STRING(item.ItemNuM), 230, Vrow + 90).
RUN pdf_text_xy ("Spdf",item.ItemName, 230, Vrow + 80).
RUN pdf_text_xy ("Spdf",item.Category1, 230, Vrow + 40).
RUN pdf_text_xy ("Spdf",item.Category2, 230, Vrow + 30).
RUN pdf_text_xy ("Spdf",STRING(item.OnHand), 440, Vrow + 90).
RUN pdf_text_xy ("Spdf",TRIM(STRING(item.Price,"$>>,>>9.99-")), 440, Vrow + 80).

/* Now Load and Display the Category Description */


RUN load_cat_desc.
RUN pdf_text_xy ("Spdf",Vcat-desc[1], 352, Vrow + 46).
RUN pdf_text_xy ("Spdf",Vcat-desc[2], 352, Vrow + 36).
RUN pdf_text_xy ("Spdf",Vcat-desc[3], 352, Vrow + 26).
RUN pdf_text_xy ("Spdf",Vcat-desc[4], 352, Vrow + 16).

/* Display text in Image Box */


RUN pdf_text_color("Spdf",1.0,.0,.0).
RUN pdf_text_xy ("Spdf","NO", 40, Vrow + 66).
RUN pdf_text_xy ("Spdf","IMAGE", 40, Vrow + 56).
RUN pdf_text_xy ("Spdf","AVAILABLE", 40, Vrow + 46).

RUN pdf_text_color("Spdf",.0,.0,.0).
/* Display the Product Number as a Bar Code */
RUN pdf_set_font("Spdf","Code39",14.0).
RUN pdf_text_xy ("Spdf",STRING(item.ItemNuM,"999999999"), 140, Vrow + 60).

Vrow = Vrow - 120.


END. /* display_item_info */

PROCEDURE new_page:
RUN pdf_new_page("Spdf").

/* Reset Page Positioning etc */


ASSIGN Vrow = pdf_PageHeight("Spdf") - pdf_TopMargin("Spdf") - 110
Vitems = 0.
END. /* new_page */

PROCEDURE load_cat_desc:
DEFINE VARIABLE L_cat AS CHARACTER NO-UNDO.

DEFINE VARIABLE L_loop AS INTEGER NO-UNDO.


DEFINE VARIABLE L_extent AS INTEGER NO-UNDO.

ASSIGN Vcat-desc = ""


L_cat = item.catdescr.
REPLACE(L_cat,CHR(13),"").
REPLACE(L_cat,CHR(10),"").

L_extent = 1.
DO L_Loop = 1 TO NUM-ENTRIES(L_cat," "):
IF (LENGTH(Vcat-desc[L_extent]) + LENGTH(ENTRY(L_loop,L_cat," ")) + 1) > 40
THEN DO:
IF L_extent = 4 THEN LEAVE.

L_extent = L_extent + 1.
END.

Vcat-desc[L_extent] = Vcat-desc[L_extent] + ENTRY(L_loop,L_cat," ") + " ".


END.
END. /* load_cat_desc */

/* end of itemlist.p */

2017-03-10 PDFinclude V2.4 Documentation 52


Appendix A – Embedding Fonts

As previously mentioned, you need to be legally responsible when embedding True Type Font
files into any documents. Most fonts are embeddable but not distributable. In order to ascertain
whether you can legally embed the TTF file you should download the Extended Font Viewer from
Microsoft.
The Extended Font Viewer can be obtained via the following link:
http://www.microsoft.com/typography/property/property.htm?fname=%20&fsize=

Once installed you can right-click on a TTF file, select the ‘Properties’ option and the following
screen (or very similar – dependant on Windows version) will appear.

Click on the “Embedding” tab. Here you will see the license options available for the Font file.
Basically, if it says that you have ‘Restricted License Embedding” then you cannot legally embed
the font file.
PRO-SYS is not legally responsible for any actions you take with embedding font files into your
PDF file.
Appendix B – Creating AFM File
The Adobe Font Metrics (AFM) file is used by PDFinclude to determine how the glyphs (or
characters) should appear when displayed by a PDF viewer (such as Adobe Acrobat).
The AFM file stores information such as glyph widths, is the font italicized, glyphs defined etc.
PDFinclude does not generate the AFM file for you. Instead you must resort to using a free utility
called ‘ttf2pt1’. This utility will read a TTF file and generate the AFM file.
To download ‘ttf2pt1’ go to the following link:
http://ttf2pt1.sourceforge.net/

The utility is written in C and must be compiled into binary executable format on whichever
platform you are running. PRO-SYS has a Windows binary executable copy available for free
distribution. Contact mailto:sales@epro-sys.com?subject=ttf2pt1 to obtain the download.
Note: PRO-SYS was unable to compile the 3.4.0 version but we were able to compile the 3.3.5
version.

Once installed and compiled, the process to create the AFM file is very simple. The following
command can be used as an example.
ttf2pt1 –A \windows\fonts\arial.ttf arial

The ‘–A’ is important. This option actually indicates to ttfpt1 that it must output an AFM file.
You may wish to read the documentation that comes with the download for a further
understanding of what ttf2pt1 is capable of.

PRO-SYS does not resell ttf2pt1 as a component of the PDFinclude package. If you have another
tool that generates AFM files then by all means use it.
PRO-SYS does not support ttf2pt1 and is not legally responsible for anything related to the utility.

2017-03-10 PDFinclude V2.4 Documentation 54

You might also like