PDF Printing via JZOS

General discussion on the JZOS batch launcher and toolkit
Post Reply
ek1975
Posts: 23
Joined: Tue Sep 30, 2008 10:04 pm

PDF Printing via JZOS

Post by ek1975 »

Hello Listers, I am looking for some pointers here to see how I can do it the best way possible?

Currently we use JZOS to execute a Java/iText application to create PDF's in batch. Our users want to print the pdf as soon as it is created. I have a bunch of PDF files on the USS side. We also have some software on the mainframe which detects PDF and converts it to a PCL and sends it to a printer.

As a test, I uploaded a PDF file as an MVS dataset (to the mainframe). Then I ran my usual JCL specifying the MVS dataset and the printer id and I got my PDF printed.

If I want to incorporate this into my app, I could copy the PDF from the USS side in to the MVS and then submit my JCL... (Although if I have more than one record, I haven't thought about that part!!!)

Would there be a better way of doing it? Someway to print the USS file directly to the Printer, thereby eliminating copying the file to the MVS side and also elminate my JCL...
Thank you for your time
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

It seems to me that the question really has to do with the program that converts the PDF to PCL and prints it. Will it support pointing the DD to an HFS path?
ek1975
Posts: 23
Joined: Tue Sep 30, 2008 10:04 pm

Post by ek1975 »

I tried substituting the HSF PATH for the DSN option. The JCl abended on "NO INPUT BLKSIZE/LRECL" for the HFS file. I am googling on that stuff now.

Also I think I may have confused you here and I'm sorry (I'm new to Java and JZOS). So let me try again.
1) I have created a PDF file called test001.pdf using Java/iText on the mainframe (This is the file the user wants a "silent print" on).
2) Just for some manual testing, I saved this file on windows & then manually uploaded it to the mainframe in binary form calling the file DP$XXX.TEST001.PDF
3) Now I executed the following JCL and the pdf got printed correctly to the printer PRINTER3

//DP$XXX01 JOB (ACCT1),'BATCH PRINT',MSGLEVEL=(1,1),
// CLASS=D,MSGCLASS=H,NOTIFY=DP$XXX
//STEP010 EXEC PGM=IEBGENER
//*SYSUT1 DD PATH='/uss/iofiles/test001.pdf'
//SYSUT1 DD DISP=SHR,DSN=DP$XXX.TEST001.PDF
//SYSUT2 DD SYSOUT=A,DEST=PRINTER3
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY


Now in order to automate this, what I would like to do is call a method after the itext package creates the PDF by calling another method that will print the PDF. And the following is the code I've copied from the JZOS samples to accomplish the printing part. But I think it's doing character conversion here because it won't print. I don't think it's doing a binary copy when /uss/iofiles/test001.pdf gets sent to "DD OUTPUT".

String inFileName = "/uss/iofiles/test001.pdf";
BufferedReader brdr = FileFactory.newBufferedReader(inFileName);
BufferedWriter bwtr = FileFactory.newBufferedWriter("//DD:OUTPUT");
try {
String line;
while ((line = brdr.readLine()) != null) {
bwtr.write(line);
bwtr.newLine();
}

And the following is the main JCL that starts the whole thing with the DD OUTPUT pointing to the same printer PRINTER3.

//DP$XXX01 JOB (ACCT1),'JZOS TEST',MSGCLASS=H,NOTIFY=&SYSUID
//JAVAJVM EXEC PGM=JVMLDM14,REGION=0M,
// PARM='jzostest'
//STEPLIB DD DSN=SYS1.SEALNKE,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//OUTPUT DD SYSOUT=A,DEST=PRINTER3
//STDENV DD *
APP_HOME=/uss/java/javaclass/
. /uss/java/jzosconfig.sh


I think if I can binary copy the raw data "test001.pdf" from the USS side to the DD OUTPUT, I have a shot. But I may be wrong... I would really appreciate your input. Thank you for your time again.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

The PDF is not a text file, so you should open it with a BufferedReader.

Here's something that should work to copy a PDF from a USS file to a DD:

Code: Select all

String inFileName = "/uss/iofiles/test001.pdf";
InputStream is = (new ZFile(inFileName, "rb")).getInputStream();
OutputStream os = (new ZFile("//DD:OUTPUT", "wb")).getOutputStream();
try {
    byte[] buf = new byte[8092];
    int nRead;
    while ((nRead = is.read(buf)) >= 0) {
      os.write(buf, 0, nRead);
    }
} finally {
  is.close();
  os.close();
}
ek1975
Posts: 23
Joined: Tue Sep 30, 2008 10:04 pm

Post by ek1975 »

Thanks for your reply. I got this error now.

JVMJZBL2010E Exception occurred invoking jzostest.main()
JVMJZBL2007E Stack trace follows:
com.ibm.jzos.ZFileException: /uss/iofiles/test001.pdf: Filename is not a valid MVS dataset or DD name

I am assuming it not something to do with "File not Found", since it's complaining about a valid MVS dataset name.... You have probably seen this error, so I just thought I'd share it with you. In the mean time, I'm going to see how I can specify a valid ZFS file in there. Thanks again
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Sorry, that was my mistake. The InputStream is of course not a ZFile!

Code: Select all

InputStream is = new FileInputStream(inFileName);
ek1975
Posts: 23
Joined: Tue Sep 30, 2008 10:04 pm

Post by ek1975 »

Thank you, this time the printer did print, but printed some junk - not a PDF. I looked at the SYSUT2 from the MVS JCL (which actually prints a PDF) and the DD OUTPUT from the Java method and it looks like the java program may be dropping characters...

The first 4 lines from SYSUT2 from the JCL looks like this with the ">" all lined up
& ST L ? ¦ < > / : < | + $
) > ? ¦ >
> > > >
> > > >

And the first 4 lines from DD OUTPUT looks like this (the second line is messed up and the ">" not lined up as seen here).
& ST L ? ¦ < > / : < | + $
> > > >
> > > >
> > > >

Could they be dropping characters or trying to drop CR-LF or something like that? Thanks for your help again.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

I don't think that the java program is dropping characters.
Try redirecting the DD to a dataset and see if the data is as it should be.

I really don't know anything about how PDFs are printed on z/OS, maybe that is the problem?
ek1975
Posts: 23
Joined: Tue Sep 30, 2008 10:04 pm

Post by ek1975 »

You are right again.... You have been doing this for a long time, haven't you? :-)

I directed DD OUTPUT to a dataset and then used the original JCL to print it and it printed fine. So sending DD OUTPUT directly to the printer seems to be the problem. I am not sure if I am missing any parms or anything else that could be added to the DD OUTPUT statement to get it working correctly. My other option would be to write the ZFS file to an MVS dataset and then submit a JCL to print to the internal reader.

I hate to make things more complex than they need to be. Do you think submitting a JCL to print the PDF to the internal reader is my best option? I really appreciate your feedback. Thank you for your suggestions and your time.
ek1975
Posts: 23
Joined: Tue Sep 30, 2008 10:04 pm

Post by ek1975 »

I specified the DCB parms for my OUTPUT DDNAME and the PDF prints correctly now...

I think I still may have to submit a JCL from Java to use this process via CICS.
justinnorth
Posts: 1
Joined: Mon Apr 07, 2014 9:19 am

Re: PDF Printing via JZOS

Post by justinnorth »

Hello, I see this string is several years old and I probably don't have much of a chance, but why not give it a whirl. . . . I am trying to do exactly what you are describing here. We are generating PDF's using iText in USS from CICS Java and need to print them. First, what product are you using to create PCL from the PDFs? Is it the IBM Infoprint Server with Transforms or something else? Also, could you just give a quick overview of what you came up with? I think I have most of the pieces figured out, but it's nice to get some input from someone who's done it. Thanks.
JosefMay
Posts: 1
Joined: Tue May 23, 2017 6:01 am

Re: PDF Printing via JZOS

Post by JosefMay »

justinnorth wrote:Hello, I see this string is several years old and I probably don't have much of a chance, but why not give it a whirl. . . . I am trying to do exactly what you are describing here. We are generating PDF's using iText in USS from CICS Java and need to print them. First, what product are you using to create PCL from the PDFs? Is it the IBM Infoprint Server with Transforms or something else? Also, could you just give a quick overview of what you came up with? I think I have most of the pieces figured out, but it's nice to get some input from someone who's done it. Thanks.
Top
Hu Justin did you ever figure out how to get it done?
Post Reply