OK, here is my test code;
In this test, the word "Test" is printed first with a document.add() and
then in a VerticalText, one in normal glyph and the second one withe bold
glyph.
Of course, at the end, I'd like to create the text in the VerticalText by
adding different Phrases elements with different colors or glyphs.
I got my book yesterady, but unfortunately the example p.365 doesn't mix
different glyphs.
import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
public class Encoding_example2 {
public static final String FONT
= "c:/windows/fonts/arial.ttf";
public static final String RESULT
= "encoding_example.pdf";
public void createPdf(String filename) throws IOException,
DocumentException {
String myTestString = "Test";
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(filename));
document.open();
// Test 1 with document.add( new Phrase )
BaseFont bf = BaseFont.createFont(FONT,
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED);
Font font0 = new Font( bf, 10 );
Font font1 = new Font( bf, 10, Font.BOLD );
document.add( new Phrase( myTestString+"\n", font0 ) );
document.add( new Phrase( myTestString+"\n", font1 ) );
// Test 2 with VerticalText
bf = BaseFont.createFont(FONT, BaseFont.IDENTITY_V,
BaseFont.EMBEDDED);
font0 = new Font( bf, 10 );
font1 = new Font( bf, 10, Font.BOLD );
VerticalText vt = new VerticalText(writer.getDirectContent());
vt.setVerticalLayout(150, 800, 50, 20, 1);
Phrase myPhrase = new Phrase(myTestString+" \n", font0);
vt.addText(myPhrase);
vt.go();
vt = new VerticalText(writer.getDirectContent());
vt.setVerticalLayout(160, 800, 50, 20, 1);
myPhrase = new Phrase(myTestString+" \n", font1);
vt.addText(myPhrase);
vt.go();
document.close();
}
public static void main(String[] args)
throws IOException, DocumentException {
new Encoding_example2().createPdf(RESULT);
}
}
And here is a copy of the result pdf.
<http://itext-general.2136553.n4.nabble.com/file/n4656923/Encoding_example2.png>
Thanks again for your time.
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/How-to-insert-bold-text-in-VerticalText-tp4656887p4656923.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php