' Copyright (c) 2003 UJIHARA Kazuya. All rights reserved. ' ' Redistribution and use in source and binary forms, with or without ' modification, are permitted provided that the following conditions ' are met: ' ' 1. Redistributions of source code must retain the above copyright ' notice, this list of conditions and the following disclaimer. ' ' 2. Redistributions in binary form must reproduce the above copyright ' notice, this list of conditions and the following disclaimer in ' the Documentation and/or other materials provided with the ' distribution. ' ' 3. The end-user Documentation included with the redistribution, ' if any, must include the following acknowledgment: ' "This product includes software developed by ' Kazuya Ujihara ." ' Alternately, this acknowledgment may appear in the software itself, ' if and wherever such third-party acknowledgments normally appear. ' ' THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ' WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ' OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ' DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ' ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ' LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF ' USE, DATA, OR PROFITS OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ' ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ' OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ' OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ' SUCH DAMAGE. ' ==================================================================== ' ' This code is free software. It may only be copied or modified ' if you include the following copyright notice: ' ' --> Copyright 2001 by Bruno Lowagie <-- ' ' This code is part of the 'iText Tutorial'. ' You can find the complete tutorial at the following address: ' http:'www.lowagie.com/iText/tutorial/ ' ' This code is distributed in the hope that it will be useful, ' but WITHOUT ANY WARRANTY without even the implied warranty of ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ' ' itext@lowagie.com Imports java.io Imports com.lowagie.text Imports com.lowagie.text.pdf Public Class Chap0201a Public Shared Sub Main(ByVal args As String()) Console.WriteLine("Chapter 2 example 1: Horizontal space in Paragraphs") ' step 1: creation of a document-object Dim Document As New Document() ' step 2: ' we create a writer that listens to the document ' and directs a PDF-stream to a file PdfWriter.getInstance(Document, New FileOutputStream("Chap0201a.pdf")) ' step 3: we open the document Document.open() ' step 4: we add content to the document Dim fonts(13) As Font fonts(13) = FontFactory.getFont(FontFactory.COURIER, 7, Font.NORMAL) fonts(12) = FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD) fonts(11) = FontFactory.getFont(FontFactory.COURIER, 8, Font.ITALIC) fonts(10) = FontFactory.getFont(FontFactory.COURIER, 13, Font.BOLD Or Font.ITALIC) fonts(9) = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL) fonts(8) = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD) fonts(7) = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.ITALIC) fonts(6) = FontFactory.getFont(FontFactory.HELVETICA, 11, Font.BOLD Or Font.ITALIC) fonts(5) = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL) fonts(4) = FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD) fonts(3) = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.ITALIC) fonts(2) = FontFactory.getFont(FontFactory.TIMES_ROMAN, 32, Font.BOLD Or Font.ITALIC) fonts(1) = FontFactory.getFont(FontFactory.SYMBOL, 5, Font.NORMAL) fonts(0) = FontFactory.getFont(FontFactory.ZAPFDINGBATS, 5, Font.NORMAL) Dim i As Integer For i = 0 To 13 Dim Chunk As New Chunk("This is some text in some", fonts(i)) Document.add(New Phrase(Chunk)) Document.add(New Phrase(New Chunk(" font. ", fonts(i)).setTextRise(IIf(i Mod 2 = 0, -6, 6)))) Next Document.add(New Phrase(New Chunk("This text is underlined ", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE)))) Document.add(New Phrase(New Chunk("This font is of type ITALIC | STRIKETHRU ", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.ITALIC Or Font.STRIKETHRU)))) Dim ck As New Chunk(" This text has a yellow background color ", FontFactory.getFont(FontFactory.HELVETICA, 12)) ck.setBackground(New java.awt.Color(&HFF, &HFF, &H0)) Document.add(New Phrase(ck)) Document.add(New Chunk("text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text")) Dim img As Image = Image.getInstance("pngnow.png") ck = New Chunk(img, 0, 0) Dim p1 As New Phrase("This is an image (not) hanging into the above text") p1.add(ck) p1.add(" just here.") Document.add(p1) p1 = New Phrase() ck = New Chunk(" As we can see the clashing is fixed for Images and") : ck.setBackground(New java.awt.Color(&HFF, &HFF, &H0)) : p1.add(ck) ck = New Chunk(" oversized font chunks", fonts(2)) : ck.setBackground(New java.awt.Color(&HFF, &HFF, &H0)) : p1.add(ck) ck = New Chunk(", but no change of leading is introduced by ") : ck.setBackground(New java.awt.Color(&HFF, &HFF, &H0)) : p1.add(ck) ck = New Chunk("risen ", fonts(7)) : ck.setBackground(New java.awt.Color(&HFF, &HFF, &H0)) : p1.add(ck) ck = New Chunk("(i.e. ") : ck.setBackground(New java.awt.Color(&HFF, &HFF, &H0)) : p1.add(ck) ck = New Chunk("subscript").setTextRise(-9) : ck.setBackground(New java.awt.Color(&HFF, &HFF, &H0)) : p1.add(ck) ck = New Chunk(" or ") : ck.setBackground(New java.awt.Color(&HFF, &HFF, &H0)) : p1.add(ck) ck = New Chunk("superscirpt").setTextRise(9) : ck.setBackground(New java.awt.Color(&HFF, &HFF, &H0)) : p1.add(ck) ck = New Chunk(") text! ") : ck.setBackground(New java.awt.Color(&HFF, &HFF, &H0)) : p1.add(ck) Document.add(p1) Document.add(New Chunk(" text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text")) ck = New Chunk(img, 0, -19) p1 = New Phrase("This is an image (not) hanging in the subsequent text") p1.add(ck) p1.add(" just here.") Document.add(p1) Document.add(New Chunk("text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text")) ck = New Chunk(img, 0, -7) p1 = New Phrase("This is an image aligned to 'its' baseline ") p1.add(ck) p1.add(" just here.") Document.add(p1) Document.add(New Chunk("text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text")) ' step 5: we close the document Document.close() End Sub End Class