Search in sources :

Example 1 with ExceptionConverter

use of com.lowagie.text.ExceptionConverter in project adempiere by adempiere.

the class SmjPdfReport method onOpenDocument.

//simpleLine
/**
	 * predefine los valores del pie de pagina ** predefined values ​​footer
	 * 
	 * @param writer
	 * @param document
	 */
public void onOpenDocument(PdfWriter writer, Document document) {
    total = writer.getDirectContent().createTemplate(100, 100);
    total.setBoundingBox(new Rectangle(-20, -20, 100, 100));
    try {
        helv = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
Also used : ExceptionConverter(com.lowagie.text.ExceptionConverter) Rectangle(com.lowagie.text.Rectangle) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with ExceptionConverter

use of com.lowagie.text.ExceptionConverter in project drools by kiegroup.

the class EndPage method onEndPage.

public void onEndPage(PdfWriter writer, Document document) {
    try {
        // TODO this image never existed
        Image image = Image.getInstance(DroolsDocsBuilder.class.getResource("guvnor-webapp.png"));
        image.setAlignment(Image.RIGHT);
        image.scaleAbsolute(100, 30);
        Rectangle page = document.getPageSize();
        PdfPTable head = new PdfPTable(2);
        PdfPCell cell1 = new PdfPCell(image);
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setBorder(0);
        head.addCell(cell1);
        PdfPCell cell2 = new PdfPCell(new Phrase(currentDate, DroolsDocsComponentFactory.HEADER_FOOTER_TEXT));
        cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell2.setBorder(0);
        head.addCell(cell2);
        head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        head.writeSelectedRows(0, -1, document.leftMargin(), page.getHeight() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
Also used : ExceptionConverter(com.lowagie.text.ExceptionConverter) PdfPCell(com.lowagie.text.pdf.PdfPCell) PdfPTable(com.lowagie.text.pdf.PdfPTable) Rectangle(com.lowagie.text.Rectangle) Phrase(com.lowagie.text.Phrase) Image(com.lowagie.text.Image) BadElementException(com.lowagie.text.BadElementException) DocumentException(com.lowagie.text.DocumentException)

Aggregations

ExceptionConverter (com.lowagie.text.ExceptionConverter)2 Rectangle (com.lowagie.text.Rectangle)2 BadElementException (com.lowagie.text.BadElementException)1 DocumentException (com.lowagie.text.DocumentException)1 Image (com.lowagie.text.Image)1 Phrase (com.lowagie.text.Phrase)1 PdfPCell (com.lowagie.text.pdf.PdfPCell)1 PdfPTable (com.lowagie.text.pdf.PdfPTable)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1