HP3000-L Archives

May 2002, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Lars Appel <[log in to unmask]>
Reply To:
Lars Appel <[log in to unmask]>
Date:
Sun, 5 May 2002 01:33:47 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (72 lines)
A while ago, Mark Wonsil wrote...

>This just popped up in one of the XML newsgroups.  It's a Java class library
>that lets you create PDF files on the fly.  It should work on the 3000 since
>it only requires JDK 1.2.
>
>http://www.lowagie.com/iText/
>iText is a library that allows you to generate PDF files on the fly.

And he was right. It does seem to work on MPE/iX thanks to Java.

I just gave it a try today (first on my PC, then on MPE/iX) and it
seems to be fairly straightforward to use for at least simple tasks
like reading a plain text file and generating a PDF from it...

I used the small example (attached below) to read a plain text file
like /SYS/PUB/HPSWINFO or a spoolfile (without the CCTL) and write
the contents to a landscape formatted PDF with 10pt Courier font...

 : # get spoolfile to bytestream, avoiding %000 in CCTL
 : /bin/sh "-c 'tr ""\000"" "" "" < /HPSPOOL/OUT/O4711 > o4711.txt' "

 : # generate PDF from the plain text file using iText
 : setvar classpath "!hpcwd:!hpcwd/iText.jar"
 : java MyTest o4711.txt o4711.pdf

A big thanks to Mark Wonsil for sharing the URL to iText !!

:) Lars


_ _ _ _ _ cut here _ _ _ _ _


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();
  }

}

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2