Here are a few session snippets that show how Java and the iText Open Source package from Bruno Lowagie can be used on MPE/iX to convert flat files or spoolfiles (without the CCTL info) to PDF with a fairly simple little program. Have fun, Lars Appel, May 2002 MPE/iX:hello lars.appel HP3000 Release: C.70.00 User Version: C.70.00 SUN, MAY 5, 2002, 1:38 PM MPE/iX HP31900 C.39.06 Copyright Hewlett-Packard 1987. All rights reserved. :print hpswinfo.pub.sys ;end=10 ******************************************************************* ** ** ** *** MPE/iX MIT C.70.00 *** ** ** POWERPATCH C7001 P6 ** ** THU, MAR 1, 2001, 5:02 PM ** ** ** ** LIST OF HEWLETT PACKARD COMMERCIAL SOFTWARE PRODUCTS ** ** INTEGRATED FOR DATECODE : '4103' ** ** ** ******************************************************************* :java -version java version "JavaVM-1.3.0" Java(TM) 2 Runtime Environment, Standard Edition (build A.30.00 built on 11/28/00-10:09) Classic VM (build A.30.00 02/05/01-15:43, build green threads, HP JIT) :# note that I am using Java 1.3 on MPE/iX 7.0 PowerPatch 1 here, but :# I guess the examples would also work on older MPE or Java versions :newdir iText Created directory "ITEXT.WORK.APPEL". :chdir iText CWD is "ITEXT.WORK.APPEL". :# I am using GNU wget to download the iText.jar library directly from :# the internet to my 3000. This is more convenient than using a PC as :# intermediate stage, but that doesn't mean you cannot or should not :# be able to use your own preferred downloading / file transfer method. : /bin/sh -L ######################################################################## MPE/iX Shell and Utilities (A.50.02) COPYRIGHT (c) Hewlett-Packard Company 1992, All Rights Reserved. ######################################################################## shell/iX> type wget wget is /usr/local/bin/wget shell/iX> wget --version GNU Wget 1.5.3 Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Written by Hrvoje Niksic . shell/iX> export http_proxy=http://my-web-proxy.hp.com:8088 shell/iX> wget http://www.lowagie.com/iText/downloads/iText.jar --13:40:55-- http://www.lowagie.com:80/iText/downloads/iText.jar => `iText.jar' Connecting to my-web-proxy.hp.com:8088... connected! Proxy request sent, awaiting response... 200 OK Length: 511,732 [text/plain] 0K -> .......... .......... .......... .......... .......... [ 10%] 50K -> .......... .......... .......... .......... .......... [ 20%] 100K -> .......... .......... .......... .......... .......... [ 30%] 150K -> .......... .......... .......... .......... .......... [ 40%] 200K -> .......... .......... .......... .......... .......... [ 50%] 250K -> .......... .......... .......... .......... .......... [ 60%] 300K -> .......... .......... .......... .......... .......... [ 70%] 350K -> .......... .......... .......... .......... .......... [ 80%] 400K -> .......... .......... .......... .......... .......... [ 90%] 450K -> .......... .......... .......... .......... ......... [100%] 13:40:57 (458.90 KB/s) - `iText.jar' saved [511732/511732] shell/iX> ls -l -rw-rw---- 1 LARS.APPEL APPEL 511732 Apr 26 14:11 iText.jar shell/iX> exit :# Now I used one of my favorite PC editors like PFE or Proton and :# Samba/iX to create the little Java program "MyTest.java" below, :# saving the file in "Unix format" to avoid the Windows/DOS CR+LF. :print ./MyTest.java ;page=0 import java.io.*; import com.lowagie.text.*; import com.lowagie.text.pdf.*; class MyTest { public static void main(String[] args) throws Exception { String inputFile = args[0]; // eg "myfile.txt" String outputFile = args[1]; // eg "myfile.pdf" BufferedReader r = new BufferedReader(new FileReader(inputFile)); Document document = new Document(PageSize.A4.rotate()); PdfWriter.getInstance(document, new FileOutputStream(outputFile)); document.open(); Font courier10pt = FontFactory.getFont(FontFactory.COURIER, 10); String str; while ( (str = r.readLine()) != null) { document.add(new Paragraph( str.equals("") ? " " : str, courier10pt)); } document.close(); r.close(); } } :# Let's set the CLASSPATH for Java and compile the MyTest program... :setvar classpath "!hpcwd:!hpcwd/iText.jar" :javac MyTest.java :listfile ./@ ,2 CODE ------------LOGICAL RECORD----------- ----SPACE---- FILENAME SIZE TYP EOF LIMIT R/B SECTORS #X MX 1B BA 1427 2147483647 1 16 1 * MyTest.class 1B BA 763 2147483647 1 16 1 * MyTest.java 1B BA 511732 2147483647 1 2000 4 * iText.jar :# Now let's get a bytestream copy of HPSWINFO and convert it to PDF... :xeq /bin/tobyte "-at /SYS/PUB/HPSWINFO hpswinfo.txt" :java MyTest hpswinfo.txt hpswinfo.pdf :listfile ./hp@ ,2 CODE ------------LOGICAL RECORD----------- ----SPACE---- FILENAME SIZE TYP EOF LIMIT R/B SECTORS #X MX 1B BA 11405 2147483647 1 48 1 * hpswinfo.pdf 1B BA 15785 2147483647 1 64 1 * hpswinfo.txt :# The easiest way to view the .txt and .pdf files is from a PC via Samba/iX :# Now let's stream a little test job and get the $STDLIST spoolfile to PDF... :stream >!job store,lars.appel >!chdir iText >!file x=$null >!store ./@; *x; show >!eoj #J94 >: :listspf SPOOLID JOBNUM FILEDES PRI COPIES DEV STATE RSPFN OWNER #O3346 J94 $STDLIST 8 1 LP READY LARS.APPEL [snip] :# Notice that the spoolfile will have CCTL info (try PRINTSPF output), :# but we will not capture that stuff in our bytestream or PDF result. :# Also let's use HPLASTSPID and a few helper vars for convenience... :showvar hplastspid HPLASTSPID = O3346 :setvar spf, "/HPSPOOL/OUT/"+hplastspid :setvar txt, dwns(hplastspid)+".txt" :setvar pdf, dwns(hplastspid)+".pdf" :# Let's make sure that the file does not get NUL chars somehwere, :# as those might confuse Posix or C based programs, which tend to :# use ASCII NUL as string terminator... :xeq /bin/sh " -c 'tr ""\000"" "" "" < !spf > !txt' " : java MyTest !txt !pdf :listfile ./o@ ,2 CODE ------------LOGICAL RECORD----------- ----SPACE---- FILENAME SIZE TYP EOF LIMIT R/B SECTORS #X MX 1B BA 2147 2147483647 1 16 1 * o3346.pdf 1B BA 2149 2147483647 1 16 1 * o3346.txt :# The easiest way to view the .txt and .pdf files is from a PC via Samba/iX :# Note that by reading the spoolfile with a Posix based tool like /bin/tr, :# the CCTL information will already be stripped out fairly early during the :# process, so the resulting PDF file will not show it in the first column. :# If you prefer to have the CCTL info visible in the PDF file, you can try :# a slightly modified approach that combines /bin/tobyte and /bin/tr to get :# the input file for the PDF conversion step. The benefit of /bin/tobyte is :# that the CCTL bytes will be visible in the first column of each line, but :# you should make sure to get rid of the ASCII NUL chars by using /bin/tr :# to replace them with blanks (happens to match CCTL %040 by the way ;-) :# Well, that's it. So long and bye bye :-) :chdir .. CWD is "/APPEL/WORK". :purgedir iText ;tree Purge ALL files below and including "ITEXT.WORK.APPEL"? (ALL/NO)all :bye CPU=35. Connect=19. SUN, MAY 5, 2002, 1:57 PM.