List of usage examples for com.lowagie.text.pdf BaseFont HELVETICA
String HELVETICA
To view the source code for com.lowagie.text.pdf BaseFont HELVETICA.
Click Source Link
From source file:classroom.intro.HelloWorld05.java
public static void main(String[] args) { // step 1//from w w w .java2 s. co m Document document = new Document(); try { // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); // step 3 document.open(); // step 4 PdfContentByte cb = writer.getDirectContent(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.saveState(); // q cb.beginText(); // BT cb.moveText(36, 806); // 36 806 Td cb.moveText(0, -18); // 0 -18 Td cb.setFontAndSize(bf, 12); // /F1 12 Tf cb.showText("Hello World"); // (Hello World)Tj cb.endText(); // ET cb.restoreState(); // Q } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // step 5 document.close(); }
From source file:classroom.intro.HelloWorld06.java
public static void main(String[] args) { // step 1// ww w . jav a2 s . c o m Document document = new Document(); try { // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); // step 3 document.open(); // step 4 PdfContentByte cb = writer.getDirectContent(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.beginText(); cb.setTextMatrix(36, 788); cb.setFontAndSize(bf, 12); cb.showText("Hello World"); cb.endText(); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // step 5 document.close(); }
From source file:classroom.intro.HelloWorld07.java
public static void main(String[] args) { // step 1//from w w w . ja v a 2s . c om Document document = new Document(); try { // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); // step 3 document.open(); // step 4 PdfContentByte cb = writer.getDirectContent(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.beginText(); cb.setFontAndSize(bf, 12); cb.showTextAligned(Element.ALIGN_LEFT, "Hello World", 36, 788, 0); cb.endText(); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // step 5 document.close(); }
From source file:classroom.intro.HelloWorld08.java
public static void main(String[] args) { Document.compress = false;/*w w w . ja va 2s.c o m*/ // step 1 Document document = new Document(); try { // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); // step 3 document.open(); // step 4 PdfContentByte cb = writer.getDirectContent(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.beginText(); cb.setFontAndSize(bf, 12); cb.moveText(88.66f, 788); cb.showText("ld"); cb.moveText(-22f, 0); cb.showText("Wor"); cb.moveText(-15.33f, 0); cb.showText("llo"); cb.endText(); PdfTemplate tmp = cb.createTemplate(250, 25); tmp.beginText(); tmp.setFontAndSize(bf, 12); tmp.moveText(0, 7); tmp.showText("He"); tmp.endText(); cb.addTemplate(tmp, 36, 781); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // step 5 document.close(); }
From source file:classroom.intro.HelloWorld09.java
public static void main(String[] args) { Document.compress = false;/* ww w. ja va 2 s . com*/ BaseFont bf = null; // step 1 Document document = new Document(); try { // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT1)); // step 3 document.open(); // step 4 PdfContentByte cb = writer.getDirectContent(); bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.beginText(); cb.setFontAndSize(bf, 12); cb.moveText(88.66f, 788); cb.showText("ld"); cb.moveText(-22f, 0); cb.showText("Wor"); cb.endText(); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // step 5 document.close(); try { PdfReader reader = new PdfReader(RESULT1); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT2)); PdfContentByte cb1 = stamper.getUnderContent(1); cb1.beginText(); cb1.setFontAndSize(bf, 12); cb1.setTextMatrix(51.33f, 788); cb1.showText("llo"); cb1.endText(); PdfContentByte cb2 = stamper.getOverContent(1); PdfTemplate tmp = cb2.createTemplate(250, 25); tmp.beginText(); tmp.setFontAndSize(bf, 12); tmp.moveText(0, 7); tmp.showText("He"); tmp.endText(); cb2.addTemplate(tmp, 36, 781); stamper.close(); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:classroom.newspaper_a.Newspaper03.java
public static void main(String[] args) { try {/*from w w w . j a va2 s .c om*/ PdfReader reader = new PdfReader(NEWSPAPER); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT)); PdfContentByte canvas = stamper.getOverContent(1); canvas.saveState(); canvas.setRGBColorFill(0xFF, 0xFF, 0xFF); canvas.rectangle(LLX1, LLY1, W1, H1); canvas.rectangle(LLX2, LLY2, W2, H2); canvas.fillStroke(); canvas.restoreState(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); putText(canvas, MESSAGE, bf, LLX1, LLY1, URX1, URY1); putText(canvas, MESSAGE, bf, LLX2, LLY2, URX2, URY2); stamper.close(); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:com.actelion.research.spiritapp.ui.util.PDFUtils.java
License:Open Source License
public static void addHeader(PdfWriter writer, String header) { class MyFooter extends PdfPageEventHelper { com.lowagie.text.Font ffont; @Override//ww w . j a v a 2 s.c o m public void onEndPage(PdfWriter writer, Document document) { try { ffont = new com.lowagie.text.Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED), 6f, com.lowagie.text.Font.ITALIC); } catch (Exception e) { e.printStackTrace(); return; } String date = FormatterUtils.formatDateTime(new Date()); PdfContentByte cb = writer.getDirectContent(); ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, new Phrase(header, ffont), document.left(), document.top() + 5, 0); ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase("Page " + writer.getCurrentPageNumber(), ffont), (document.right() - document.left()) / 2 + document.leftMargin(), document.bottom() - 5, 0); ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, new Phrase(date, ffont), document.right(), document.bottom() - 5, 0); } } writer.setPageEvent(new MyFooter()); }
From source file:com.aryjr.nheengatu.testes.AbsolutePosition.java
License:Open Source License
public static void main(final String[] args) { // System.out.println("My First PdfPTable"); final Document document = new Document(); try {/*www. ja v a 2s . co m*/ final PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("/home/aryjr/MyFirstTable.pdf")); document.open(); // PdfPTable table = createTable(); // document.add(table); // table.writeSelectedRows(0, -1, 50, 200, // writer.getDirectContent()); final PdfContentByte cb = writer.getDirectContent(); cb.concatCTM(1f, 0f, 0f, -1f, 0f, 0f); // Paragraph text = new Paragraph("Ary Junior", // FontFactory.getFont(Style.DEFAULT_FONT_FAMILY, // Style.DEFAULT_FONT_SIZE, Font.NORMAL, Style.DEFAULT_FONT_COLOR)); final BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.beginText(); cb.setFontAndSize(bf, 12); cb.showText("Ary Junior"); cb.endText(); Runtime.getRuntime().exec("acroread /home/aryjr/MyFirstTable.pdf"); } catch (final DocumentException de) { System.err.println(de.getMessage()); } catch (final IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:com.gp.cong.logisoft.lcl.report.FreightInvoiceLclPdfCreator.java
@Override public void onOpenDocument(PdfWriter writer, Document document) { total = writer.getDirectContent().createTemplate(100, 100); total.setBoundingBox(new Rectangle(-20, -20, 100, 100)); try {//from w ww .ja v a 2s. c o m helv = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); } catch (Exception e) { log.info("onOpenDocument failed on " + new Date(), e); throw new ExceptionConverter(e); } }
From source file:com.logiware.accounting.reports.ArDisputeReportCreator.java
@Override public void onOpenDocument(PdfWriter writer, Document document) { pageTemplate = writer.getDirectContent().createTemplate(20, 10); pageTemplate.setBoundingBox(new Rectangle(-20, -20, 20, 50)); try {//from w ww. j a v a 2 s . c om helvFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); } catch (DocumentException e) { log.info("onOpenDocument failed on " + new Date(), e); } catch (IOException e) { log.info("onOpenDocument failed on " + new Date(), e); } }