function Event.OnBeginConvert(Page, Message, Job) end
function Event.OnBeginSecure(Page, Message, Job) end
function Event.OnEndConvert(Page, Message, Job) end
-- Required for debugging (must be last statement) Pdfing.Debug()as the last statement of a script. This runs your script in debugging mode, but is not required (and will be ignored) when running in PDFing.
Fields of table: Page | ||
---|---|---|
Field Name | Type | Comments |
getlines() | function |
getlines(frompage [, fromline, toline]) Returns a table containing the specified lines of text. The field named: n in the returned table contains the number of text-lines in the table. The other fields in this table each contain one line of text and may be referenced by the lua index operator: [1] through [n]. |
writeline() | function |
writeline(page, line, text) Write the contents of the text parameter to the specified page and line of a new intermediate file. This new file is the one that will be converted to a PDF file. Each line of text within a page can only be written once and all pages must be written in page sequence. This function can only be used with "un-transformed" *SCS spooled-files. Please consult the author of PDFing before using this function! |
linecount | number (readonly) | The number of lines in the spooled-file page in process. |
lineno | number (readonly) | The line number of the spooled-file text line in process. |
pagecount | number (readonly) | The number of pages in the spooled-file. |
pageno | number (readonly) | The page number of the spooled-file in process. |
maxline | number (readonly) | The maximum number of lines in any page of text. |
maxpos | number (readonly) | The maximum number of positions in any line of text. |
text | string (readonly) | The text from the spooled-file text line in process. |
texts[] | table of strings | A Lua table of text lines from the spooled-file page in process. A particular line of text can be refenced by the index operator, for example: texts[2] |
Fields of table: Message | ||
---|---|---|
Field Name | Type | Comments |
|
function |
Message.addtoset(filename, [before]) Call this function to add a file to a set of files. The first parameter is the file-name, the second (optional) parameter controls whether the file is added to the set after (0) or before (1) the files of this job. For example: Message.addtoset("D:\\Temp\\another.pdf", 1) You may specify an alternative file-name, to be used when the the file is sent by email, for example: Message.addtoset("D:\\Temp\\another.pdf>alias", 1) The file received by email will then be: alias.pdf. |
|
function |
Message.holdfonttabs(tab1, tab2, ...) Call this function to de-activate specified tabs on the [Fonts] of the selected markup. Each of the (one or more) parameters specifies a tab-number to be de-activated. |
|
function |
Message.lookupaddress(mail_list, [code], [separator]) Call this function to return a list of email addresses from a mail-list. The first parameter is the name of a mail-list, the second (optional) parameter is the code used to select addresses and the third (optional) parameter is the separator character inserted between each address. If you want this function to return all addresses in a mail-list, omit the second parameter or pass nil. |
|
string | Specifies the name (not including extension) of a Markup file which will be used for this job's processing parameters. If you specify a single asterisk "*", this re-sets all processing parameters to their configuration default values. |
|
boolean |
Specify 0 - Do not create PDF file from the spooled-file.
Specify 1 - Create a PDF file from the spooled-file. |
|
boolean |
Specify 0 - Do not create an ASCII-text file from the spooled-file.
Specify 1 - Create an ASCII-text file from the spooled-file. |
|
boolean |
Specify 0 - Do not create an RTF file from the spooled-file.
Specify 1 - Create an RTF file from the spooled-file. |
|
boolean |
Specify 0 - Do not create an Excel file from the spooled-file.
Specify 1 - Create an Excel file from the spooled-file. |
|
string | Specifies the name (not including extension) of a "template" excel file for use when converting a spooled-file to excel. |
|
boolean |
Specify 0 - Do not create a ZIP archive for attached files.
Specify 1 - Create a ZIP archive for attached-files. |
|
string | Specifies the name of the ZIP archive file. (Overrides Message.docname) |
|
string | Specifies the password for the ZIP archive file. |
|
string | Specifies the name-prefix of the file(s) when saved to disk or attached to email. |
|
string | Specifies the title of the PDF file. |
|
string | Specifies the subject of the PDF file. |
|
string | Specifies the author of the PDF file. |
|
string | Specifies the key-words of the PDF file. |
|
boolean |
Specify 0 - Do not set file-properties.
Specify 1 - Set file-properties using PDF title, subject and author. |
|
string | Specifies the owner/master password for the PDF file. |
|
string | Specifies the user password for the PDF file. |
|
boolean |
Specify 0 - Use 40 bit strength encryption.
Specify 1 - Use 128 bit strength of encryption. |
|
boolean |
Specify 0 - Do not allow users to print the PDF file.
Specify 1 - Allow users to print the PDF file. |
|
boolean |
Specify 0 - Do not allow users to change the PDF file.
Specify 1 - Allow users to change the PDF file. |
|
boolean |
Specify 0 - Do not allow users to copy the contents of the PDF file.
Specify 1 - Allow users to copy the contents of the PDF file. |
|
boolean |
Specify 0 - Do not allow users to add notes to the PDF file.
Specify 1 - Allow users to add notes to the PDF file. |
|
number |
Specify 0 - Do not "digitally-sign" the PDF file.
Specify greater than 0 - Specifies the number of a valid signing-certificate. |
|
string | Specifies the subject text of the email. |
|
string | Specifies the body text of the email. Each line of text must be separated by CRLF pair. If you specify a single asterisk "*", then the body text is set to NULL. |
|
string | Specifies the destination of the converted spooled-file. If this value is an email address or addresses then an email with attachments will be sent to these addresses. Each recipient should be separated by a semi-colon. If you specify a single asterisk "*" this sets the destination to all blanks. |
|
string | Specifies the name of the mail-list. An email with attached files will be sent to every address in this list. |
|
string | Specifies the recipient(s) of a "notification" email. Each recipient should be separated by a semi-colon. If you specify a single asterisk "*" this sets the notification recipient to all blanks. |
|
string | Specifies the name of the mail-list. A "notification" email will be sent to every address in this list. |
|
boolean |
Specify 0 - Do not attach files to notification email.
Specify 1 - Attach files to notification email. |
|
string | Specifies the reply-to email address of the email. |
|
boolean |
Specify 0 - Do not ask mail recipients for receipt message
Specify 1 - Ask mail-recipients for receipt message. |
|
boolean |
Specify 0 - Do not HOLD emails before sending.
Specify 1 - HOLD emails before sending. |
|
string | Specifies the name of the printer. |
|
number | Specifies the number of copies to print. |
|
number |
Specifies whether printing is to be in color or in monochrome.
Specify 0 to use the default setting of the printer. Specify 1 to force monochrome printing. Specify 2 to force color printing. |
|
string | Specifies the tray for paper input, either by name or number. |
|
string | Specifies the bin for printed paper output, either by name or number. |
|
number |
Specifies whether printing is to be double-sided.
Specify 0 to use the default setting of the printer. Specify 1 to force vertical duplex. Specify 2 to force horizontal duplex. Specify 3 to switch double-sided printing off. |
|
string |
Specifies the range of pages to be printed. This can be a single page
("2") or a range ("2-9") or a starting page ("2-").
The page-numbers must be valid or printing will fail.
By default, all pages are printed. |
|
number |
Specifies printing quality in dots-per-inch.
Specify 0 to use the default setting of the printer. |
|
boolean |
Specifies the action PDFing should take if the address-code is not found.
Specify 0 (false) if PDFing should send the message to the default destination. Specify 1 (true) if PDFing should hold the message before sending to the default destination. |
|
boolean |
Specifies the action PDFing should take after bursting a spooled-file.
Specify 0 (false) if PDFing should continue to process this spooled-file. Specify 1 (true) if PDFing should not process this spoooled-file after it has been burst. |
|
number |
Specify -9 to ignore any previously saved PCL macro-file.
Specify -2 to apply any previously saved PCL macro-file to this spooled-file. This is the default value. Specify -1 to delete any previously saved temporary PCL macro-file, after applying it to this spooled-file. Specify 0 to delete any previously saved temporary PCL macro-file, before processing this spooled-file. Specify 1 to temporarily save this spooled-file as PCL macro-file which will then be added to the start of any *AFPDS or *USERASCII spooled-files subsequently received by PDFing Specify 2 to add this spooled-file to a previously saved temporary PCL macro-file which will be then added to the start of any later AFPDS or *USERASCII spooled-files subsequently received by PDFing. |
|
string | Specifies the name of a PCL macro-file previously saved in the \Markup directory. This macro-file is added to the start of this *AFPDS or *USERASCII spooled-file before it is processed by PDFing. |
|
string | Specifies a series of parameters, each separated by CRLF pair. These parameters control how PCL is converted to PDF. |
|
boolean |
Specifies the which component PDFing should use to convert *AFPDS and *USERASCII spooled-files.
Specify 0 (false) if PDFing should use the latest version of the component. Specify 1 (true) if PDFing should use an older version of the component. |
|
boolean | Specify 1 (true) if you want your lua script to handle "bursting". Your script must also include an implementation for function Event.OnBurstPage |
|
string | Specifies the name (without extension) of the address-book which will be searched by address-code when looking up email addresses. If you specify a single asterisk "*" then any value specified for field addrcode will be processed as an email address. |
|
string | Specifies the code that will be used to look up the address(es) of email recipient(s). Replaces "special characters" &C at run-time. |
|
string | Specifies the text that determined where a spooled-file was "burst" into a series of documents. Replaces "special characters" &B at run-time. |
|
string | Specifies the full path name of the user supplied file that should be copied and attached to emails. |
|
string | Specifies the full path name of the user supplied file that should be moved and attached to emails. |
|
string |
Specifies any non-standard file-extension(s) necessary to process
any user-supplied-files that may be attached to emails. For example:
Message.attachextensions = ".csv" |
|
string | Specify one or more text-lines (delimited by \r\n) containing one or more processing "tags". A new copy of the current job will be created for each text-line. The "tag" strings in the text-line specify how this new job should be be processed by PDFing. |
|
string | Specify the name of a file, which will contain a copy of the control-file for this job. The control-file(LP*.con) will be copied once the job is complete or encounters an error. |
Fields of table: Job | ||
---|---|---|
Field Name | Type | Comments |
|
string | Sequential job-number (supplied by PDFing) |
|
string | Host name of the system that wrote the spooled-file. |
|
string | Name of the "remote" output-queue that wrote the spooled-file. |
|
string | Name of the user that created the spooled-file. |
|
string | Name of the spooled-file. |
|
string | Date and time (YYYMMDDHHNNSS) when spooled-file recived by PDFing. |
|
string |
Name of the work-file containing the spooled-file text.
If the file-extension is .lpr then this the "raw" spooled-file text. If the file-extension is .inx then this the "translated" spooled-file text. |
|
boolean |
1 = true
- Spooled-file data includes OS400 attributes such as form-type, user-date, etc.
0 = false - Spooled-file data does not include OS400 attributes. The spooled--file will include OS400 attributes only when the remote output-queue is specified as DESTTYPE(*OS400) TRANSFORM(*NO) or our
"transform exit program" for PDFing is used.
|
|
string |
Name of the job that created the spooled-file.
Only valid when os4attributes equals 1. |
|
string |
Number of the job that created the spooled-file.
Only valid when os4attributes equals 1. |
|
string |
Number of the spooled-file.
Only valid when os4attributes equals 1. |
|
string |
Form-type of the spooled-file.
Only valid when os4attributes equals 1. |
|
string |
User-data of the spooled-file.
Only valid when os4attributes equals 1. |
|
string |
Name of the device-file that created the spooled-file.
Only valid when os4attributes equals 1. |
|
string |
Name of the program that created the spooled-file.
Only valid when os4attributes equals 1. |
|
string |
Date and time (YYYMMDDHHNNSS) when spooled-file created.
Only valid when os4attributes equals 1. |
|
boolean |
1 = true
- Spooled-file has been transformed by OS400.
0 = false - Spooled-file has not been transformed by OS400. |
|
number | Number of pages in spooled-file |
|
string | Name of the markup file used to process the spooled-file |
|
string | Destination of the spooled-file. |
|
string | Notify address of the spooled-file. |
|
boolean |
1 = true
- Email will be held, and must be released before it will be sent.
0 = false - Email will be sent automatically. |
|
string | Special free-form text sent with spooled-file |
|
string | Language code sent with the spooled-file. |
|
boolean |
1 = true
- This spooled-file is the result of "Burst" of another spooled-file.
0 = false - This spooled-file is NOT the result of "Burst" of another spooled-file. |
|
string |
Addressing Code (extracted from spooled-file text).
Only valid after conversion. |
|
string |
Bursting text (extracted from spooled-file text).
Only valid after conversion. |
|
boolean |
1 = true
- Spooled-file is a "clone" of an original spooled-file.
0 = false - Spooled-file is not a "clone" of an original spooled-file. |
|
number | Sequence number of "cloned" spooled-file |
|
number | Macro processing-type specified by the EHP= "tag". Default value is -2. |
|
string | Macro name specified by the EHN= "tag". |
|
string | Name of selected printer. |
|
number | Number of copies to print. |
|
string |
Full file path of the PDF file created by this job.
Only valid after conversion. |
|
string |
Full file path of the ASCII file created by this job.
Only valid after conversion. |
|
string |
Full file path of the RTF file created by this job.
Only valid after conversion. |
|
string |
Full file path of the Excel file created by this job.
Only valid after conversion. |
|
string | Base path to files created by this job. |
|
string |
Name of the Windows directory from which PDFingScript.lua is loaded.
Always valid. |
|
string |
Name of the temporary Windows directory \Temp used by PDFing.
A different sub-directory will be used when debugging. |
function printhello() -- start function definition of "printhello" print("hello") end -- end function definition -- call function printhello() -- >> "hello"
=
+ - / * ^
..
== ~= < > <= >=These operators return nil as false and a none nil value as true.
and or notLike Lua control structures, all logical operators consider nil as false and anything else as true. The conjunction operator and returns nil if its first argument is nil; otherwise, it returns its second argument. The disjunction operator or returns its first argument if it is different from nil; otherwise, it returns its second argument. Both and and or use short-cut evaluation, that is, the second operand is evaluated only if necessary.
{}
[i]The index value i may be a number or a string. An array is a Lua table without field names, so the expression a[1] refers to the first element in array a , a[2] refers to the second element, and so on.
if logical-expression then block-of-statements end if logical-expression then block-of-statements else block-of-statements endLua also provides iterative control structures while and for. LuateX scripts do not usually require iteration and these control structures should be used with caution.
-- begin Lua script ------------------------------------ -- This script is not for spreadsheet creation ! -- Example (1) of PDFingScript.lua -- Author: David Fowle (dfowle@pdfing.com) -- Date: 5th July 2003 -------------------------------------------------------------- -- Event Function (before conversion begins) function Event.OnBeginConvert(Page, Message, Job) -- Set mail-subject and body from spooled-file text, depending on spooled-file name if (Job.spooledfile == "MailBody") then Message.createpdf = 0 -- do not want any attachments Message.creatertf = 0 Message.createasc = 0 Message.createexl = 0 Message.createzip = 0 Message.mailsubject = Page.texts[1] Message.mailbody = "" for i = 2, 9, 1 do -- gets lines 2 thru 9 of the spooled-file text Message.mailbody = Message.mailbody .. Page.texts[i] Message.mailbody = Message.mailbody .. "\r\n" end return end end -- end Lua script -------------------------------------
-- begin Lua script ------------------------------------ -- This script is not for spreadsheet creation ! -- Example (2) of PDFingScript.lua -- Author: David Fowle (dfowle@pdfing.com) -- Date: 5th July 2003 -------------------------------------------------------------- -- Event Function (before conversion begins) function Event.OnBeginConvert(Page, Message, Job) if (Job.spooledfile == "ReplacePdf") then -- Depending on spooled-file Message.docname = "TestCopy" -- set attached file name Message.usercopyfile = "C:\\Temp\\Copied.pdf" -- add new field Message.createpdf = 1 -- make sure that pdf is sent by email Message.creatertf = 0 Message.createasc = 0 Message.createexl = 0 Message.createzip = 0 return end end -------------------------------------------------------------- -- Event Function (after conversion ends) function Event.OnEndConvert(Page, Message, Job) -- if new field not nil - replace PDF generated from spooled-file if (Message.usercopyfile) then Message.copyuserattachment = Message.usercopyfile end end -- end Lua script --------------------------------------------------------------