Search in sources :

Example 1 with ExceptionConverter

use of com.itextpdf.text.ExceptionConverter in project specify by rhebecaabreu.

the class ModelPDFRodape method onEndPage.

public void onEndPage(PdfWriter writer, Document document) {
    PdfPTable table = new PdfPTable(3);
    try {
        table.setWidths(new int[] { 24, 24, 2 });
        table.setTotalWidth(527);
        table.setLockedWidth(true);
        table.getDefaultCell().setFixedHeight(20);
        table.getDefaultCell().setBorder(Rectangle.TOP);
        table.addCell(topo);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(String.format("Pagina %d de", writer.getPageNumber()));
        PdfPCell cell = new PdfPCell(Image.getInstance(total));
        cell.setBorder(Rectangle.TOP);
        table.addCell(cell);
        table.writeSelectedRows(0, -1, 34, document.bottomMargin(), writer.getDirectContent());
    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }
}
Also used : ExceptionConverter(com.itextpdf.text.ExceptionConverter) PdfPCell(com.itextpdf.text.pdf.PdfPCell) PdfPTable(com.itextpdf.text.pdf.PdfPTable) DocumentException(com.itextpdf.text.DocumentException)

Example 2 with ExceptionConverter

use of com.itextpdf.text.ExceptionConverter in project trainning by fernandotomasio.

the class TCAIcaerPageFooter method onEndPage.

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfPTable table = new PdfPTable(3);
    try {
        table.setWidths(new int[] { 20, 80, 20 });
        table.setTotalWidth(527);
        table.setLockedWidth(true);
        table.getDefaultCell().setFixedHeight(20);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        String anexo = "";
        if (writer.getPageNumber() > 1) {
            // }
            if (writer.getPageNumber() % 2 != 0) {
                table.addCell(new Phrase(header, new Font(Font.FontFamily.TIMES_ROMAN, 12)));
                table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
                PdfPCell anexoCell = new PdfPCell(new Phrase(String.format(anexo, writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
                anexoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                anexoCell.setBorder(Rectangle.NO_BORDER);
                table.addCell(anexoCell);
                table.addCell(new Phrase(String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
            } else {
                table.addCell(new Phrase(String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
                table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
                PdfPCell anexoCell = new PdfPCell(new Phrase(String.format(anexo, writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
                anexoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                anexoCell.setBorder(Rectangle.NO_BORDER);
                table.addCell(anexoCell);
                table.addCell(new Phrase(header, new Font(Font.FontFamily.TIMES_ROMAN, 12)));
            // table.getDefaultCell().setHorizontalAlignment(
            // Element.ALIGN_RIGHT);
            }
        }
        PdfPCell cell = new PdfPCell(Image.getInstance(total));
        cell.setBorder(Rectangle.NO_BORDER);
        // table.addCell(cell);
        table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent());
    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }
}
Also used : ExceptionConverter(com.itextpdf.text.ExceptionConverter) PdfPCell(com.itextpdf.text.pdf.PdfPCell) PdfPTable(com.itextpdf.text.pdf.PdfPTable) DocumentException(com.itextpdf.text.DocumentException) Phrase(com.itextpdf.text.Phrase) Font(com.itextpdf.text.Font)

Example 3 with ExceptionConverter

use of com.itextpdf.text.ExceptionConverter in project trainning by fernandotomasio.

the class CMPageFooter method onEndPage.

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfPTable table = new PdfPTable(3);
    try {
        table.setWidths(new int[] { 40, 80, 20 });
        table.setTotalWidth(450);
        table.setLockedWidth(true);
        table.getDefaultCell().setFixedHeight(18);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        String anexo = "";
        if ((writer.getPageNumber() % 2) == 0) {
            document.setMargins(85, 56, 56, 85);
        } else {
            document.setMargins(56, 85, 56, 85);
        }
    // if (writer.getPageNumber() > 6) {
    // 
    // if (writer.getPageNumber() % 2 != 0) {
    // table.addCell(new Phrase(header, new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // 
    // table.getDefaultCell().setHorizontalAlignment(
    // Element.ALIGN_RIGHT);
    // PdfPCell anexoCell = new PdfPCell(new Phrase(
    // String.format(anexo, writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // anexoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    // anexoCell.setBorder(Rectangle.NO_BORDER);
    // table.addCell(anexoCell);
    // 
    // //                    table.addCell(new Phrase(
    // //                            String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // 
    // 
    // } else {
    // table.addCell(new Phrase(
    // String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // table.getDefaultCell().setHorizontalAlignment(
    // Element.ALIGN_RIGHT);
    // PdfPCell anexoCell = new PdfPCell(new Phrase(
    // String.format(anexo, writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // anexoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    // anexoCell.setBorder(Rectangle.NO_BORDER);
    // table.addCell(anexoCell);
    // 
    // table.addCell(new Phrase(header, new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // //table.getDefaultCell().setHorizontalAlignment(
    // //      Element.ALIGN_RIGHT);
    // 
    // }
    // 
    // }
    // 
    // PdfPCell cell = new PdfPCell(Image.getInstance(total));
    // cell.setBorder(Rectangle.NO_BORDER);
    // //table.addCell(cell);
    // 
    // if((writer.getPageNumber() % 2) == 0){
    // table.writeSelectedRows(0, -1,
    // 56, 817, writer.getDirectContent());
    // }else{
    // table.writeSelectedRows(0, -1,
    // 85, 817, writer.getDirectContent());
    // }
    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }
}
Also used : ExceptionConverter(com.itextpdf.text.ExceptionConverter) PdfPTable(com.itextpdf.text.pdf.PdfPTable) DocumentException(com.itextpdf.text.DocumentException)

Example 4 with ExceptionConverter

use of com.itextpdf.text.ExceptionConverter in project trainning by fernandotomasio.

the class PageFooter method onEndPage.

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfPTable table = new PdfPTable(3);
    try {
        table.setWidths(new int[] { 24, 24, 2 });
        table.setTotalWidth(527);
        table.setLockedWidth(true);
        table.getDefaultCell().setFixedHeight(20);
        table.getDefaultCell().setBorder(Rectangle.BOTTOM);
        table.addCell(header);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(String.format("Pg %d de", writer.getPageNumber()));
        PdfPCell cell = new PdfPCell(Image.getInstance(total));
        cell.setBorder(Rectangle.BOTTOM);
        table.addCell(cell);
        table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent());
    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }
}
Also used : ExceptionConverter(com.itextpdf.text.ExceptionConverter) PdfPCell(com.itextpdf.text.pdf.PdfPCell) PdfPTable(com.itextpdf.text.pdf.PdfPTable) DocumentException(com.itextpdf.text.DocumentException)

Example 5 with ExceptionConverter

use of com.itextpdf.text.ExceptionConverter in project trainning by fernandotomasio.

the class PUDPageFooter method onEndPage.

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfPTable table = new PdfPTable(3);
    try {
        table.setWidths(new int[] { 40, 80, 20 });
        table.setTotalWidth(450);
        table.setLockedWidth(true);
        table.getDefaultCell().setFixedHeight(18);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        String anexo = "";
        if ((writer.getPageNumber() % 2) == 0) {
            document.setMargins(85, 56, 56, 85);
        } else {
            document.setMargins(56, 85, 56, 85);
        }
    // if (writer.getPageNumber() > 5) {
    // if (writer.getPageNumber() >= 11
    // && writer.getPageNumber() <= 14) {
    // anexo ="Anexo A - Relação dos Cursos Previstos";
    // } else if (writer.getPageNumber() >= 15
    // && writer.getPageNumber() <= 251) {
    // anexo = "Anexo B - Cronograma e Folha de Rosto";
    // } else if (writer.getPageNumber() == 252) {
    // anexo ="Anexo C - Modelo de Ficha de Indicação CNS014";
    // }
    // if (writer.getPageNumber() % 2 != 0) {
    // table.addCell(new Phrase("", new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // 
    // table.getDefaultCell().setHorizontalAlignment(
    // Element.ALIGN_RIGHT);
    // PdfPCell anexoCell = new PdfPCell(new Phrase(
    // String.format(anexo, writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // anexoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    // anexoCell.setBorder(Rectangle.NO_BORDER);
    // table.addCell(anexoCell);
    // 
    // table.addCell(new Phrase(
    // String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // 
    // 
    // } else {
    // table.addCell(new Phrase(
    // String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // table.getDefaultCell().setHorizontalAlignment(
    // Element.ALIGN_RIGHT);
    // PdfPCell anexoCell = new PdfPCell(new Phrase(
    // String.format(anexo, writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // anexoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    // anexoCell.setBorder(Rectangle.NO_BORDER);
    // table.addCell(anexoCell);
    // 
    // table.addCell(new Phrase("", new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // //table.getDefaultCell().setHorizontalAlignment(
    // //      Element.ALIGN_RIGHT);
    // 
    // }
    // PdfPCell cell = new PdfPCell(Image.getInstance(total));
    // cell.setBorder(Rectangle.NO_BORDER);
    // //table.addCell(cell);
    // table.writeSelectedRows(0, -1,
    // 34, 803, writer.getDirectContent());
    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }
}
Also used : ExceptionConverter(com.itextpdf.text.ExceptionConverter) PdfPTable(com.itextpdf.text.pdf.PdfPTable) DocumentException(com.itextpdf.text.DocumentException)

Aggregations

DocumentException (com.itextpdf.text.DocumentException)6 ExceptionConverter (com.itextpdf.text.ExceptionConverter)6 PdfPTable (com.itextpdf.text.pdf.PdfPTable)6 PdfPCell (com.itextpdf.text.pdf.PdfPCell)4 Font (com.itextpdf.text.Font)2 Phrase (com.itextpdf.text.Phrase)2