Search in sources :

Example 31 with Paragraph

use of com.itextpdf.text.Paragraph in project opentheso by miledrousset.

the class WritePdf method writeHieraTermRecursif.

/**
 * fonction recursive qui sert a ecrire tout les fils des term
 *
 * @param id
 * @param indentation
 * @param paragraphs
 * @param idToDoc
 */
private void writeHieraTermRecursif(String id, String indentation, ArrayList<Paragraph> paragraphs, HashMap<String, ArrayList<String>> idToDoc) {
    indentation += ".......";
    ArrayList<String> childList = idToChildId.get(id);
    if (childList == null) {
        return;
    }
    for (String idFils : childList) {
        String name = idToNameHashMap.get(idFils);
        if (name == null) {
            name = "";
        }
        paragraphs.add(new Paragraph(indentation + name + " (" + idFils + ")", textFont));
        writeHieraTermInfo(idFils, indentation, paragraphs, idToDoc);
        writeHieraTermRecursif(idFils, indentation, paragraphs, idToDoc);
    }
}
Also used : Paragraph(com.itextpdf.text.Paragraph)

Example 32 with Paragraph

use of com.itextpdf.text.Paragraph in project summer-bean by cn-cerc.

the class Barcode128Template method output.

@Override
public void output(Document document, PdfWriter writer) throws DocumentException, IOException {
    PdfContentByte cb = writer.getDirectContent();
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    // 设置中文字体和字体样式
    Font f8 = new Font(bfChinese, fontSize, Font.NORMAL);
    DataSet dataSet = this.getDataSet();
    dataSet.first();
    while (dataSet.fetch()) {
        // 条码信息
        Barcode128 code128 = new Barcode128();
        code128.setBarHeight(barHeight);
        String code = dataSet.getString("Code_");
        code128.setCode(code);
        // 反算条码宽度
        int length = code.length();
        float x = 125 / ((length + 2) * 11 + 2f);
        code128.setX(x);
        document.add(code128.createImageWithBarcode(cb, null, null));
        // 描述信息
        Paragraph paragraph = new Paragraph(dataSet.getString("Name_"), f8);
        paragraph.setAlignment(Element.ALIGN_CENTER);
        document.add(paragraph);
    }
}
Also used : Barcode128(com.itextpdf.text.pdf.Barcode128) DataSet(cn.cerc.jdb.core.DataSet) BaseFont(com.itextpdf.text.pdf.BaseFont) PdfContentByte(com.itextpdf.text.pdf.PdfContentByte) Font(com.itextpdf.text.Font) BaseFont(com.itextpdf.text.pdf.BaseFont) Paragraph(com.itextpdf.text.Paragraph)

Example 33 with Paragraph

use of com.itextpdf.text.Paragraph in project summer-bean by cn-cerc.

the class BarcodeTemplate method output.

@Override
public void output(Document document, PdfWriter writer) throws DocumentException, IOException {
    PdfContentByte cb = writer.getDirectContent();
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    // 设置中文字体和字体样式
    Font f8 = new Font(bfChinese, fontSize, Font.NORMAL);
    DataSet dataSet = this.getDataSet();
    dataSet.first();
    while (dataSet.fetch()) {
        // 商品名称
        if (dataSet.getCurrent().hasValue("Name_"))
            document.add(new Paragraph(dataSet.getString("Name_"), f8));
        // 商品条码
        BarcodeEAN codeEAN = new BarcodeEAN();
        codeEAN.setBarHeight(barHeight);
        codeEAN.setCode(dataSet.getString("Code_"));
        document.add(codeEAN.createImageWithBarcode(cb, null, null));
        codeEAN.setGuardBars(false);
    }
}
Also used : BarcodeEAN(com.itextpdf.text.pdf.BarcodeEAN) DataSet(cn.cerc.jdb.core.DataSet) BaseFont(com.itextpdf.text.pdf.BaseFont) PdfContentByte(com.itextpdf.text.pdf.PdfContentByte) Font(com.itextpdf.text.Font) BaseFont(com.itextpdf.text.pdf.BaseFont) Paragraph(com.itextpdf.text.Paragraph)

Example 34 with Paragraph

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

the class DOC001PDF method buildFrontispicio.

private void buildFrontispicio(Document document, CurriculoMinimoDTO curriculoMinimo) throws DocumentException {
    Paragraph spaceParagraph = new Paragraph();
    spaceParagraph.add(new Phrase("\n"));
    document.add(spaceParagraph);
    document.add(spaceParagraph);
    document.add(spaceParagraph);
    document.add(spaceParagraph);
    document.add(spaceParagraph);
    Paragraph p1 = new Paragraph();
    p1.setAlignment(Element.ALIGN_CENTER);
    p1.add(new Phrase("MINISTÉRIO DA DEFESA", fontManager.getH1Font()));
    document.add(p1);
    Paragraph p2 = new Paragraph();
    p2.setAlignment(Element.ALIGN_CENTER);
    p2.add(new Phrase("COMANDO DA AERONÁUTICA", fontManager.getH1Font()));
    document.add(p2);
    Paragraph p3 = new Paragraph();
    p3.setAlignment(Element.ALIGN_CENTER);
    p3.add(new Phrase("DEPARTAMENTO DE CONTROLE DO ESPAÇO AÉREO", fontManager.getDefaultFont()));
    document.add(p3);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    try {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        String path = classLoader.getResource("aer.png").getPath();
        Image image = Image.getInstance(path);
        image.setAlignment(Element.ALIGN_CENTER);
        image.scalePercent(18.5f);
        document.add(image);
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(DOC001PDF.class.getName()).log(Level.SEVERE, null, ex);
    }
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    Paragraph p4 = new Paragraph();
    p4.setAlignment(Element.ALIGN_CENTER);
    p4.add(new Phrase("ENSINO", fontManager.getH0Font()));
    document.add(p4);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    PdfPTable t = new PdfPTable(1);
    t.setTotalWidth(286);
    t.setLockedWidth(true);
    PdfPCell unica = new PdfPCell();
    unica.setFixedHeight(140);
    unica.setPadding(10);
    unica.setVerticalAlignment(Element.ALIGN_MIDDLE);
    Paragraph p5 = new Paragraph();
    p5.setAlignment(Element.ALIGN_CENTER);
    p5.add(new Phrase(curriculoMinimo.getNumeroPublicacaoCM(), fontManager.getSmallXBoldFont()));
    Paragraph p6 = new Paragraph();
    p6.setAlignment(Element.ALIGN_CENTER);
    p6.add(new Phrase("CURRÍCULO MÍNIMO DO CURSO " + curriculoMinimo.getCurso().getDescricao(), fontManager.getSmallXBoldFont()));
    Paragraph p7 = new Paragraph();
    p7.setAlignment(Element.ALIGN_CENTER);
    p7.add(new Phrase(curriculoMinimo.getCurso().getCodigo(), fontManager.getSmallXBoldFont()));
    Paragraph p8 = new Paragraph();
    p8.setAlignment(Element.ALIGN_CENTER);
    p8.add(new Phrase(curriculoMinimo.getAnoPublicacaoCM(), fontManager.getSmallXBoldFont()));
    unica.addElement(p5);
    unica.addElement(Chunk.NEWLINE);
    unica.addElement(p6);
    unica.addElement(p7);
    unica.addElement(Chunk.NEWLINE);
    unica.addElement(p8);
    unica.addElement(Chunk.NEWLINE);
    t.addCell(unica);
    document.add(t);
    // document.add(Chunk.NEXTPAGE);
    // 
    // document.add(buildPrefacio(curriculoMinimo));
    document.add(Chunk.NEXTPAGE);
    document.add(Chunk.NEXTPAGE);
}
Also used : BadElementException(com.itextpdf.text.BadElementException) Phrase(com.itextpdf.text.Phrase) IOException(java.io.IOException) Image(com.itextpdf.text.Image) Paragraph(com.itextpdf.text.Paragraph)

Example 35 with Paragraph

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

the class DOC001PDF method buildReferencias.

private Chapter buildReferencias(CurriculoMinimoDTO curriculo) {
    Paragraph p = new Paragraph("REFERÊNCIAS", fontManager.getBoldFont());
    p.setAlignment(Element.ALIGN_CENTER);
    Chapter ch = new Chapter(p, 0);
    ch.setNumberDepth(0);
    ch.add(Chunk.NEWLINE);
    Paragraph p1 = new Paragraph("BRASIL. Comando da Aeronáutica. Comando-Geral do Pessoal. Norma de Sistema do Comando da Aeronáutica (NSCA) 5-1, de 23 de novembro de 2011. Norma disciplinando a confecção, controle e numeração de publicações do Comando da Aeronáutica. Boletim do Comando da Aeronáutica nº 225 de 29 de novembro de 2011.", fontManager.getDefaultFont());
    p1.setAlignment(Element.ALIGN_JUSTIFIED);
    ch.add(p1);
    ch.add(Chunk.NEWLINE);
    Paragraph p2 = new Paragraph("______. Comando da Aeronáutica. Departamento de Ensino da Aeronáutica. Instrução do Comando da Aeronáutica (ICA) 37-4, de 18 de março de 2010. Instrução referente à elaboração e revisão de currículos mínimos. Boletim do Comando da Aeronáutica nº 55, de 23 de outubro de 2010.", fontManager.getDefaultFont());
    p2.setAlignment(Element.ALIGN_JUSTIFIED);
    ch.add(p2);
    return ch;
}
Also used : Chapter(com.itextpdf.text.Chapter) Paragraph(com.itextpdf.text.Paragraph)

Aggregations

Paragraph (com.itextpdf.text.Paragraph)67 Chapter (com.itextpdf.text.Chapter)25 PdfPTable (com.itextpdf.text.pdf.PdfPTable)18 Phrase (com.itextpdf.text.Phrase)14 PdfPCell (com.itextpdf.text.pdf.PdfPCell)13 Font (com.itextpdf.text.Font)11 IOException (java.io.IOException)11 DocumentException (com.itextpdf.text.DocumentException)10 Section (com.itextpdf.text.Section)10 Document (com.itextpdf.text.Document)8 ArrayList (java.util.ArrayList)8 ListItem (com.itextpdf.text.ListItem)7 BaseFont (com.itextpdf.text.pdf.BaseFont)7 FileOutputStream (java.io.FileOutputStream)7 List (com.itextpdf.text.List)6 Chunk (com.itextpdf.text.Chunk)5 Image (com.itextpdf.text.Image)5 PdfWriter (com.itextpdf.text.pdf.PdfWriter)5 ObjetivoDisciplinaDTO (com.tomasio.projects.trainning.dto.ObjetivoDisciplinaDTO)5 SubunidadeDidaticaDTO (com.tomasio.projects.trainning.dto.SubunidadeDidaticaDTO)5