The code attached is used to create the pdf document.  The text file I
am reading is a SQL*Plus report with report headings, column heading,
etc.  

public class PDF4 {

  public static void main(String[] args) {
    //FileReader fr = null;
    BufferedReader br = null;

    String str = "";
    int c;
    //try {
    //  fr = new FileReader("h:\\mwhite\\pdf2.txt");
    //  br = new BufferedReader(fr);
    //}
    try {
      Reader in = new InputStreamReader(new FileInputStream(
          "h:\\mwhite\\pdf4.txt"));
      while ( (c = in.read()) != -1) {
        str = str + ( (char) c);
      }

    }
    catch (Exception e) {
      System.out.println("Cannot read file.");
    }


    System.out.println("Chapter 1 example 1: Hello World");

    // step 1: creation of a document-object
    //Document document = new Document();
    Document document = new Document(PageSize.LETTER.rotate());

    try {

      // step 2:
      // we create a writer that listens to the document
      // and directs a PDF-stream to a file

      PdfWriter.getInstance(document, new
FileOutputStream("PDF4.pdf"));

      // step 3: we open the document
      document.open();

      // step 4: we add a paragraph to the document
      Paragraph p = new Paragraph(str,
                                 
FontFactory.getFont(FontFactory.COURIER, 8));
      p.setAlignment(p.ALIGN_CENTER);
      document.add(p);
      //document.add(new
Paragraph(str,FontFactory.getFont(FontFactory.COURIER, 8)));

    }
    catch (DocumentException de) {
      System.err.println(de.getMessage());
    }
    catch (IOException ioe) {
      System.err.println(ioe.getMessage());
    }

    // step 5: we close the document
    document.close();
  }

}

>>> "Paulo Soares" <[EMAIL PROTECTED]> 12/05/03 10:26AM >>>
Maybe if you tell us what's the text format, where it comes from, what
font and size are you using, how are you putting the text in the pdf
then, and only then, will you get a better answer.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Monya White [SMTP:[EMAIL PROTECTED] 
> Sent: Friday, December 05, 2003 12:40
> To:   Paulo Soares
> Subject:      RE: [iText-questions] Convert proformatted text to PDF
whilepreserving page breaks
> 
> Thanks.  So, what's the best way to do this???
> 
> >>> "Paulo Soares" <[EMAIL PROTECTED]> 12/05/03 05:27 AM >>>
> The problem is the way you are doing it.
> 
> Best Regards,
> Paulo Soares
> 
> > -----Original Message-----
> > From:       [EMAIL PROTECTED] 
> [SMTP:[EMAIL PROTECTED] On Behalf Of
Monya
> White
> > Sent:       Thursday, December 04, 2003 18:49
> > To: [EMAIL PROTECTED] 
> > Subject:    [iText-questions] Convert proformatted text to PDF
while
> preserving page breaks
> > 
> > Hello
> > 
> > I have a preformatted text file that I am trying to convert to a
PDF. 
> > It is working except that the page breaks in the text file are not
> > preserved.  Instead, the PDF file seems to have it's own page
> breaking. 
> > Is there any way to get around this?
> > 
> > Thanks for your help.
> > Monya White
> > 
> > 
> > -------------------------------------------------------
> > This SF.net email is sponsored by: SF.net Giveback Program.
> > Does SourceForge.net help you be more productive?  Does it
> > help you create better code?  SHARE THE LOVE, and help us help
> > YOU!  Click Here: http://sourceforge.net/donate/ 
> > _______________________________________________
> > iText-questions mailing list
> > [EMAIL PROTECTED] 
> > https://lists.sourceforge.net/lists/listinfo/itext-questions 
> 


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to