Export a spool to a PDF file

page d'accueil
Boite à outils

Cette page a été mise à jour le14 septembre 2009
Contact

Welcome page
Tools box

Target :

        convert a text spool to a PDF file. 

Characteristics :

        RPG and CL only, no JAVA. 

What will not do :

        Do not convert AFPDS, GDDM or IPDS spools. Because most spools are text only.
        Do not take care of PRTF attributes such as underline : heart of this tool is CPYFRMSPLF.
        Do not define external fonts (IE use only internal PDF Reader fonts)

Note : in the SystemI News dated 2008-08, the is a supplement about document management.
At the bottom of page 3 you can read "The native PDF support is now shipped as a bonus licensed program ...
Needs : 5761-SS1, Option 03 and 33 ; 5761-TS1, Base and option 01
5761-TS1 is the AFP to PDF transform licensed program.
I will test this as soon as I work on i6.1

Sample :

        SPlf2pdf.pdf      

Versionning 

last version : How to upload to my 400

CHGPFM FILE(JPLTOOLS) MBR(SPLF2PDF ) SRCTYPE(CMD ) EXPDATE(*NONE) SHARE(*NO) TEXT('TRANSFORM A SPOOL FILE TO A PDF FILE ') 
CHGPFM FILE(JPLTOOLS) MBR(SPLF2PDFC ) SRCTYPE(CLP ) EXPDATE(*NONE) SHARE(*NO) TEXT('Transform a spool into a PDF ')
CHGPFM FILE(JPLTOOLS) MBR(SPLF2PDFR ) SRCTYPE(RPGLE ) EXPDATE(*NONE) SHARE(*NO) TEXT('Transform a spool into a PDF ')



CRTCMD CMD(SPLF2PDF) PGM(*LIBL/SPLF2PDFc) SRCFILE(JPLTOOLS) SRCMBR(SPLF2PDF) THDSAFE(*YES) REPLACE(*YES)

CRTCLPGM PGM(SPLF2PDFC) SRCFILE(JPLTOOLS) USRPRF(*USER) REPLACE(*YES)

CRTPF FILE(QTEMP/QSPLDTA) RCDLEN(382)
CRTRPGMOD MODULE(SPLF2PDFR) SRCFILE(JPLTOOLS) OPTION(*NODEBUGIO *SRCSTMT *SECLVL *SHOWCPY *EXPDDS) DBGVIEW(*ALL)
CRTPGM PGM(SPLF2PDFR) BNDSRVPGM(JP4PDFS) BNDDIR(QC2LE) ACTGRP(JPLTOOLS) USRPRF(*USER) OPTION(*DUPPROC *DUPVAR)

SPLF2PDF uses also

SPLF2PDF is a now classic tool, but this one, I have write it completely myself. It is based on How to make a PDF file with RPG

the easiest way to use SPLF2PDF is from the WRKSPLF screen : copy & paste the file name (5 attributes) to the command, then F4
wrksplf

F4


Transform a spool into a PDF, screenshot, file name

Transform a spool into a PDF, screenshot, MARGINS

Transform a spool into a PDF, screenshot, LOGO
SPLF2PDF FILE(QPSUPRTF) SPLNBR(5) JOBNAME(QPADEV000F) JOBUSER(LAMONTRE) JOBNBR(991383) 
IFSROOT(HOME) IFSDIR(LAMONTRE)
LOGO('/home/lamontre/jpl.jpg')
WATERMARK('WAterMArk' HELVETICA *NO *NO 72 200 000 00)

After command run, You can retrieve the PDF in the IFS :

WrkLnk

Copy it to a PC folder, for example with Navigator, and open it. That's all.

Copy with Navigator

Questions I've received about this tool

I can not see the end of the lines in the PDF - solved 2008-03-30

there is a rounding error in some calculation :

In SPLF2PDFR, near line 600, replace the calculation of xmax and ymax with :
 //‚ 132 100 

xMax = splinfo.PAGE_WIDTH /%float(splinfo.CHAR_PER_INCH)*720;

// 66 60

yMax = splinfo.PAGE_length /%float(splinfo.LINES_PER_INCH)*720;

May I have to install IFS ?

No, In fact you don't have choice : IFS is a mandatory element of I5/OS : QSYS is a subfolder of IFS.

IFS welcomes many file systems, QSYS is one of them. At the same level, you can also find QDLS, QNTC, QOpenSys, ... QSYS is an EBCDIC system. The IFS root is an ASCII system. Forgot what type exactly, but it's an Unix wise system.
Each system has it's own rules :
QSYS is EBCDIC, non hierarchical (IE a library can not contains a library, but QSYS which is the root library), unique names are on Library + Object + Object-type
QDLS is pseudo-ASCII, like old MSDOS, hierarchical (IE a directory can contains a directory), unique names are on complete path name, a name is max 11 chars long ; 8 for file and 3 for extension
IFS is Unix like : accepts many variants of ASCII, hierarchical, name length limit exists, but never encountered, unique names are on complete path, ...
So, the IFS name of an object in QSYS is also unique : for example the SPLF2PDFR program in the JPLTOOLS library is named /qsys.lib/jpltools.lib/splf2pdfr.pgm

But go back to our PDF. PDF is an ASCII file. So it will be written somewhere in the IFS in an ASCII system. I strongly suggest for the first test of SPLF2PDF to choose "home" as root. home is a folder at the root of IFS, automatically provided by the system.

I have issue with IFSROOT and IFSFOLDER. Can you provide some sample ?
I have the message "No such path or directory" somewhere in the joblog after calling SPLF2PDF !

these parameters are used inside SPLF2PDF to build the complete IFS path. This is done precisely in the RTVIFSNAM command. I have do this to define in only one place the name of the root of all the files I extract from my SystemI .
Currently, the value *COMMON is converted to '/ExtractionExcel' ... because the first use of RTVIFSNAM was for SQL2XLS.

If this naming don't match your needs, either update RTVIFSNAM ... or hard code the root directory in the command call.

SPLF2PDF FILE(QPPGMDMP) 
SPLNBR(5) 
JOBNAME(QPADEV0002) 
JOBUSER(LAMONTRE) 
JOBNBR(092294) 
IFSROOT(HOME) 
IFSFILE('resolved issue.pdf')

The machines I've done my testing on have all had the CCSID set to 285 for the UK, but I've just come to try it on another machine with a CCSID of 65535 and I've got a problem. All the '[' in the source are being converted to '£' when it does the ascii conversion so the resulting PDF files are unreadable and I'm sure it's to do with the CCSID. 

Do you have any idea what I could change in your source so it would allow for the default CCSID of 65535? Although I think the correct answer is to change the CCSID of the machine I am worried that if I do other software might be affected. 

Your issue is exactly the CCSID. 
Trying to make PDF builder running under ccsid 65535 is not a goog idea. it's such as if you ask to go back to V3R0M5. 
But changing all the machine, it's surely a big error. Updating a machine to work correctly with CCSID is a long process that need to be very carefull. 

You have a solution to avoid the issue : 

  1. rtvjoba : get current ccsid 
  2. chgjoba : set the current job to a correct ccsid (IE 285) 
  3. run the SPLF2PDF command 
  4. go back to original ccsid 

I strongly suggest to use the same CCSID for the job that runs SPLF2PDF and for the source file that contains rpg code of SPLF2PDFR. This will mask many issues.

I’m trying to use your program to convert spoolfile to pdf. I looked in the source code and found this statement,

pdfWrite('%'+PdfFile.Version+'%âãÏÓ'+CRLF);

The weir character before +CRLF, is it suppose to be something else?

this line is correct, it's to explain to FTP that the file is a binary file and must be transmitted in binary mode. When FTP is in automatic mode, it choose itself to transmit as text or as bin by exploring the first n chars of a file to transmit. This may not generate an error.
If, when opened with notepad, the first line of the PDF file don't look as
%PDF-1.4%âãÏÓ
there is a CCSID convertion error. In this case, have a look at previous issue.

The command runs correctly, but when I open the PDF file, there is only one page, and it is empty.
I found the problem. For my company, qtemp is not on top of the library list. So when program try to read qspldta. It read the one from other library. I need to add ovrdbf cmd in your cl. It works perfectly.

You are true,  I also update the code on the site : embbed the call to SPLF2PDFR with an OVRDBF
OVRDBF FILE(QSPLDTA) TOFILE(QTEMP/QSPLDTA) 
CALL PGM(SPLF2PDFR) PARM(&FILE &SPLNBR &JOBNAME +
&JOBUSER &JOBNBR &IFS &STRPAGE &ENDPAGE)
DLTOVR FILE(QSPLDTA)

One more question, when I open the pdf that created by your program, it has 2 separate panes, one for the picture and the other one for Options. I know that I can click x to close the Options plane. But is there anyway to make it not shown at the time I open the pdf ?

yes, but it is today hard coded in the /copy. Into JP4PDF1 (or JP4INC depending of the date your downloaded the /COPY), Search for PdfCloseRoot. You will find this code :

PdfWrite('/Outlines '+PdfWObj(pdfroot.outlines)+'R ' 
+ '/PageMode /UseOutlines ');

You can change /UseOutlines to the other admitted values :

UseNone Neither document outline nor thumbnail images visible
UseOutlines Document outline visible
UseThumbs Thumbnail images visible
FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible

But this modification will be appplied to all PDF-generator programs as soon as you recompile them.

I will take care of adding an optional parameter to this procedure, and provide an option on the SPLF2PDF command to tune this option.

I will keep you advised on this page, at the top, in the Versionning list.

solved 2008-03-30 : new parameter PAGEMODE

 

The source code is provided as an open source tool under the GNU General Public License, version 2.  In summary, this license specifies:

By clicking the download link you acknowledge and agree to the terms of the license.

Download the (zipped) SAVF containing the JPLTOOLS : the source file, the message file, the bnddir

THIS TOOLBOX IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROVIDER OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS TOOLBOX, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.