Thursday, May 17th 2012, 5:04pm UTC+2

You are not logged in.

  • Login
  • Register

Posts: 95

Location: Oberirsen - Germany

Occupation: Software Engineer

1

Sunday, April 12th 2009, 10:51am

How to create PDF-Documents with Jabaco and iText

Hello community,
there is a phantastic library, call iText, to create PDF documents. You find it here: http://www.lowagie.com/iText/. It is a free Java library to generate PDF files on the fly. Now a small snippet how to use it with Jabaco after you add the JAR file to your classpath:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'-Variables---------------------------------------------------------
    Dim Doc As com#lowagie#text#Document
    Dim Out As java#io#FileOutputStream
    Dim Head As com#lowagie#text#HeaderFooter
    Dim hPhrase As com#lowagie#text#Phrase
    Dim Foot As com#lowagie#text#HeaderFooter
    Dim fPhrase As com#lowagie#text#Phrase
    Dim Par As com#lowagie#text#Paragraph

  '-Create Document---------------------------------------------------
    Set Doc = New Document(com#lowagie#text#PageSize.A4, 50, 50, 50, 50)
    Set Out = New FileOutputStream("C:\Dummy\JabacoPDFDemo.pdf")
    com#lowagie#text#pdf#PdfWriter.getInstance Doc, Out

  '-Define Header-----------------------------------------------------
    Set hPhrase = New Phrase("Jabaco - PDF-Demo")
    Set Head = New HeaderFooter(hPhrase, False)
    Head.setBorder(com#lowagie#text#Rectangle.BOTTOM)
    Doc.setHeader(Head)

  '-Define Footer-----------------------------------------------------
    Set fPhrase = New Phrase("Seite ")
    Set Foot = New HeaderFooter(fPhrase, True)
    Foot.setAlignment(Element.ALIGN_CENTER)
    Foot.setBorder(com#lowagie#text#Rectangle.TOP)
    Doc.setFooter(Foot)

  Doc.open()

  '-Write Paragraphs in Document--------------------------------------
    Set Par = New Paragraph("Dies ist ein Test")
    Doc.add(Par)
    Doc.newPage()
    Doc.add(Par)

  Doc.close()

It is a great library with a lot of possibilities and a very good online documentation with a lot of examples, look here: http://www.1t3xt.com/docs/book.php.
Cheers
Stefan

This post has been edited 4 times, last edit by "StefanSchnell" (Jan 26th 2011, 5:23am)


Posts: 95

Location: Oberirsen - Germany

Occupation: Software Engineer

2

Wednesday, January 26th 2011, 5:53am

Actual situation

Hello community,
the iText library has a new location, you find it now here:www.itextpdf.com.
The online documentation is not more available, the URL www.1t3xt.com is redirected to www.itextpdf.com. Look at the examples here.
My example above works only with version <= 2.1.7 and not with the actual version 5.x.
Cheers
Stefan

This post has been edited 1 times, last edit by "StefanSchnell" (Jan 26th 2011, 6:06am)


Posts: 95

Location: Oberirsen - Germany

Occupation: Software Engineer

3

Thursday, February 10th 2011, 12:38pm

How to create PDF-Documents with Jabaco and iText

Hello community,
here is a small new example. It works with iText 5.0.6.

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'-Variables-----------------------------------------------------------
    Dim Doc As com#itextpdf#text#Document
    Dim Par As com#itextpdf#text#Paragraph
    Dim Out As java#io#FileOutputStream

  '-Create Document-----------------------------------------------------
    Set Doc = New Document(com#itextpdf#text#PageSize.A4, 50, 50, 50, 50)
    Set Out = New FileOutputStream("C:\Dummy\JabacoPDFDemo.pdf")
    com#itextpdf#text#pdf#PdfWriter.getInstance Doc, Out

  Doc.open()
    Set Par = New Paragraph("Dies ist ein Test")
    Doc.add(Par)
    Doc.newPage()
    Doc.add(Par)
  Doc.close()


Cheers
Stefan

Rate this thread
WoltLab Burning Board