× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I'm having problems with the following java program which should convert an 
AS/400 spooled file into an Adobe PDF file. I created a CL that calls the java 
class file and passes it the parameters for the spool file to convert. When I 
run the program it runs for a few minutes then drops back to a command line and 
the folloing message is displayed.

Spooled file SPOOLTEST conversion failed.

This is the first Java program that I've tried running on the AS/400. I'm not 
sure how to go about debugging it to see where it's failing. I tried using 
strdbg giving it the ifs path and java class name but it was unable to find the 
source. Both the .java  and .class files are in the same ifs directory. Which 
is where they were when I compiled the .java file.


No other output gets generated as far as I can see. I did a wrkjob on the 
session and looked for all spooled files created and didn't see anything. I 
expected the output to go to qprint.

Any help with this would be very much appreciated.


**** Joblog ****
SPLTOPDF FILE(spooltest) JOB(072811/QSECOFR/SPLTOPDFCL) SPLNBR(1) PDFPATH
('/spltopdf') PDF(SPL) NOTES(TEST) 
Current directory changed.                        
Object not found.  Object is /spltopdf/SPL.log.                                 
         
Member M000000004 added to file TMPSPOOL in QGPL.     
237 records copied to file TMPSPOOL in QGPL.          
Current directory changed.                            
Object STDOUT in library QTEMP not found.             
File STDOUT created in library QTEMP.                 
Member STDOUT added to file STDOUT in QTEMP.          
Member STDOUT file STDOUT in QTEMP cleared.           
Command ended normally with exit status 0.            
Member M000000004 removed from file TMPSPOOL in QGPL. 
Object not found.  Object is /spltopdf/SPL.log.       
Spooled file SPOOLTEST conversion failed.            

**** Java Source ****
// name: spltopdf.java
// Parameters:
//   PDFPATH        Folder where to create PDF
//   PDFNAME        The PDF name
//   ROWS           The number of rows of spooled file
//   COLS           The number of columns of spooled file
//   FOOTERcomments Comments written in PDF footer
//   LIBRARY        The library where the work file belongs
//   FILE           The work file name
//   MEMBER         The member of the work file where has been copied the 
spooled file
import java.io.*;
import com.ibm.as400.access.*;

// Import the iText Free Java-PDF library, http://www.lowagie.com/iText
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.BaseFont;

public class spltopdf extends Object{
public static void main(String[] parameters){
if (parameters.length == 8 ){
   try { 
      String PDFPATH = parameters[0];
      String PDFNAME = parameters[1];
      String ROWS = parameters[2];
      String COLS = parameters[3];
      String FOOTERcomments = parameters[4];
      String LIBRARY = parameters[5];
      String FILE = parameters[6];
      String MEMBER = parameters[7];

      int RecordLength = Integer.valueOf(COLS).intValue();
      AS400 as400 = new AS400();

      // Define the work file (the first field is the control char FCFC)
      CharacterFieldDescription rFCFC = new CharacterFieldDescription(new 
AS400Text(1, as400), "rFCFC");
      CharacterFieldDescription rLINE = new CharacterFieldDescription(new 
AS400Text(RecordLength, as400), "rLINE");
      RecordFormat TmpSpool = new RecordFormat("TmpSpool");

      TmpSpool.addFieldDescription(rFCFC);
      TmpSpool.addFieldDescription(rLINE);
 
      QSYSObjectPathName filename = new QSYSObjectPathName(LIBRARY, FILE, 
MEMBER, "MBR");
      SequentialFile file = new SequentialFile(as400, filename.getPath());

      file.setRecordFormat(TmpSpool);
      file.open(SequentialFile.READ_ONLY, 100, 
SequentialFile.COMMIT_LOCK_LEVEL_NONE);

      System.out.println("Start Creation of "+ PDFPATH+PDFNAME+".pdf");
      try {      
         // Create the courier.ttf font object
  BaseFont courier = BaseFont.createFont("courier.ttf", BaseFont.IDENTITY_H, 
BaseFont.EMBEDDED);
  Font font = new Font(courier, 10f); // The fontsize is 10

         float f = courier.getWidthPoint("0123456789", 10f); // length of 10 
fixed characters width  
        float Xpoints =  Float.valueOf(COLS).floatValue() * f / 10 + 72 ; // 
the page width in pixels

         // leading = the space between two lines, that is 1.5 times the 
fontsize
         int leading = 15 ;
         float Ypoints =  (Float.valueOf(ROWS).floatValue() + 5) * leading + 72 
; //The page height in pixels

         // Create the Rectangle object in a certain color and use this as 
pageSize
    Rectangle pageSize = new Rectangle(Xpoints, Ypoints);
         pageSize.setBackgroundColor(new java.awt.Color(0xFF, 0xFF, 0xDE));
         Document document = new Document(pageSize,36,36,36,36); // The four 
margins have 36 pixels (0.5 of inch)

         // Create an instance of the com.lowagie.text.Document object
  PdfWriter.getInstance(document, new FileOutputStream(PDFPATH+PDFNAME+".pdf"));
  document.addTitle("Was created with Java on iSeries");
  document.addSubject("Example of fixed width fonts like Courier");
  document.addKeywords("SpltoPDF");
  document.addCreator("MM");
  document.addAuthor("MM");
  document.addHeader("Expires", "0");

         // Add footer with notes
  HeaderFooter footer = new HeaderFooter(new 
Paragraph(leading,FOOTERcomments,font), false);
  footer.setAlignment(Element.ALIGN_RIGHT);
  document.setFooter(footer);

         // Add watermak to the middle right place of the page and scale to fit 
according to the margin size
         // Change the layout of the watermark according to the needed standards
  try {
            float ImageScale = 36; 
     Watermark watermark = new
           Watermark(Image.getInstance("watermark.jpg"), Xpoints-ImageScale, 
(Ypoints-ImageScale)/2);
            watermark.scaleToFit(ImageScale,ImageScale);
     document.add(watermark); 
  }  catch(Exception e) {
            System.out.println("watermark.jpg not found");
            System.exit(0);
         }

  document.open();
         Record data = file.readNext(); // Read first record of work file
         boolean FirstTime = true;
  String NewPage = "1";
  String SpaceBeforeOneLine = "0";
  String SpaceBeforeTwoLines = "-";
  String fcfc = " ";
         String linef = "";
         while (data != null) {
           if (FirstTime) FirstTime = false; else fcfc = (String) 
data.getField("rFCFC");
            linef =  (String) data.getField("rLINE");
            // According to the value of control char FCFC create new line, 
lines or page
            if ( fcfc.compareTo(NewPage)==0 ) {
                document.newPage(); }
            if ( fcfc.compareTo(SpaceBeforeOneLine)==0 ) {
                document.add(new Paragraph(leading, " ", font)); }
            if ( fcfc.compareTo(SpaceBeforeTwoLines)==0 ) {
                document.add(new Paragraph(leading, " ", font));
                document.add(new Paragraph(leading, " ", font));
            }
            document.add(new Paragraph(leading, linef, font)); // add a spooled 
file line to PDF
            data = file.readNext(); // Read next record of work file
  }
         document.close();
         // Create an EventLog file as success sign
         EventLog myLog = new EventLog(PDFPATH+PDFNAME+".log");
         myLog.log("OK");
         as400.disconnectAllServices(); 
      } catch(DocumentException de) {
         System.out.println(de.getMessage());
         System.exit(0);
      } catch(IOException ioe) {
         System.out.println(ioe.getMessage());
         System.exit(0);
      }
   }  catch (Exception e) {
      System.out.println("Could not read the work file");
      System.out.println(e.getMessage());
      System.exit(0);
   }
} else {
   System.out.println("");
   System.out.println("Parameters are not correct.");
   System.out.println("");
   System.out.println("Command syntax is: spltopdf path name rows cols notes 
library file member");
   System.out.println("");
   System.out.println("Syntax example is: spltopdf /mypdf order 66 198 Demo 
qgpl tmpspool m000001");
   System.out.println("");
}
System.exit(0);}
}








As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.