Search in sources :

Example 11 with Chapter

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

the class DOC005PDF method makeReport.

@Override
public void makeReport() {
    teachingDocumentsService = (TeachingDocumentsService) services.get("teachingDocumentsService");
    document = documentManager.getDocumentPortrait();
    os = documentManager.prepareDocument(document);
    writer = documentManager.getWritter();
    ChapterSectionTOC eventHandler = new ChapterSectionTOC();
    writer.setPageEvent(eventHandler);
    document.open();
    CSSResolver cssResolver = new StyleAttrCSSResolver();
    CssFile cssFile = null;
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    String cssStylePath = classLoader.getResource("doc3-styles.css").getPath();
    cssFile = XMLWorkerHelper.getCSS(classLoader.getResourceAsStream("doc3-styles.css"));
    cssResolver.addCss(cssFile);
    XMLWorkerFontProvider fontProvider = new XMLWorkerFontProvider(XMLWorkerFontProvider.DONTLOOKFORFONTS);
    String fontFilePath = classLoader.getResource("MyriadPro-Regular.otf").getPath();
    // fontProvider.register(fontFilePath);
    CssAppliers cssAppliers = new CssAppliersImpl(fontProvider);
    HtmlPipelineContext htmlContext = new HtmlPipelineContext(cssAppliers);
    htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
    PdfWriterPipeline pdf = new PdfWriterPipeline(document, writer);
    HtmlPipeline html = new HtmlPipeline(htmlContext, pdf);
    CssResolverPipeline css = new CssResolverPipeline(cssResolver, html);
    XMLWorker worker = new XMLWorker(css, true);
    p = new XMLParser(worker);
    try {
        String secaoIdParam = (String) params.get("secaoId");
        document.add(Chunk.NEXTPAGE);
        SecaoApostilaDTO secao = teachingDocumentsService.findSecaoApostila(Long.parseLong(secaoIdParam));
        Chapter ch = new Chapter(0);
        ch.setNumberDepth(0);
        if (secao.getContent() != null) {
            buildSection(ch, secao, p, document);
        }
        document.add(ch);
    } catch (DocumentException e) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
        throw new CoreException(e.getMessage());
    } catch (IOException ex) {
        Logger.getLogger(DOC005PDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        document.close();
    }
}
Also used : StyleAttrCSSResolver(com.itextpdf.tool.xml.css.StyleAttrCSSResolver) HtmlPipeline(com.itextpdf.tool.xml.pipeline.html.HtmlPipeline) Chapter(com.itextpdf.text.Chapter) CssFile(com.itextpdf.tool.xml.css.CssFile) IOException(java.io.IOException) CssResolverPipeline(com.itextpdf.tool.xml.pipeline.css.CssResolverPipeline) CssAppliersImpl(com.itextpdf.tool.xml.html.CssAppliersImpl) SecaoApostilaDTO(com.tomasio.projects.trainning.dto.SecaoApostilaDTO) XMLWorkerFontProvider(com.itextpdf.tool.xml.XMLWorkerFontProvider) XMLWorker(com.itextpdf.tool.xml.XMLWorker) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CSSResolver(com.itextpdf.tool.xml.pipeline.css.CSSResolver) StyleAttrCSSResolver(com.itextpdf.tool.xml.css.StyleAttrCSSResolver) CssAppliers(com.itextpdf.tool.xml.html.CssAppliers) PdfWriterPipeline(com.itextpdf.tool.xml.pipeline.end.PdfWriterPipeline) DocumentException(com.itextpdf.text.DocumentException) HtmlPipelineContext(com.itextpdf.tool.xml.pipeline.html.HtmlPipelineContext) XMLParser(com.itextpdf.tool.xml.parser.XMLParser)

Example 12 with Chapter

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

the class DOC002PDF method buildComplementacaoInstrucao.

private Chapter buildComplementacaoInstrucao(CurriculoMinimoDTO curriculo) throws DocumentException {
    Chapter ch = new Chapter(new Paragraph("COMPLEMENTAÇÃO DA INSTRUÇÃO", fontManager.getBoldFont()), 3);
    ch.add(Chunk.NEWLINE);
    PdfPTable tableComplementacaoInstrucao = buildComplamentacaoInstrucaoTable(curriculo);
    ch.add(tableComplementacaoInstrucao);
    ch.add(Chunk.NEWLINE);
    PdfPTable tableFlexibilidade = buildFlexibilidadeTable(curriculo);
    ch.add(tableFlexibilidade);
    return ch;
}
Also used : PdfPTable(com.itextpdf.text.pdf.PdfPTable) Chapter(com.itextpdf.text.Chapter) Paragraph(com.itextpdf.text.Paragraph)

Example 13 with Chapter

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

the class DOC002PDF method buildDisposicoesFinais.

private Chapter buildDisposicoesFinais(CurriculoMinimoDTO curriculo) {
    Chapter ch = new Chapter(new Paragraph("DISPOSIÇÕES FINAIS", fontManager.getBoldFont()), 8);
    ch.add(Chunk.NEWLINE);
    IReportUtil.fillChapter(ch, curriculo.getDisposicoesFinais2());
    return ch;
}
Also used : Chapter(com.itextpdf.text.Chapter) Paragraph(com.itextpdf.text.Paragraph)

Example 14 with Chapter

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

the class DOC002PDF method buildSumario.

private Chapter buildSumario(ArrayList<Paragraph> titles) throws DocumentException {
    Paragraph p = new Paragraph("SUMÁRIO", fontManager.getBoldFont());
    p.setAlignment(Element.ALIGN_CENTER);
    Chapter ch = new Chapter(p, 0);
    ch.setNumberDepth(0);
    ch.add(Chunk.NEWLINE);
    for (Paragraph title : titles) {
        ch.add(title);
    }
    return ch;
}
Also used : Chapter(com.itextpdf.text.Chapter) Paragraph(com.itextpdf.text.Paragraph)

Example 15 with Chapter

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

the class DOC002PDF method buildAbreviaturas.

private Chapter buildAbreviaturas(CurriculoMinimoDTO curriculo) {
    Paragraph p = new Paragraph("LISTA DE ABREVIATURAS", fontManager.getBoldFont());
    p.setAlignment(Element.ALIGN_CENTER);
    Chapter ch = new Chapter(p, 0);
    ch.setNumberDepth(0);
    ch.add(Chunk.NEWLINE);
    AbreviaturaDTO[] abreviaturas = teachingDocumentsService.findAllAbreviaturasByPUD(curriculo.getId());
    for (AbreviaturaDTO abreviatura : abreviaturas) {
        String item = abreviatura.getSigla() + " - " + abreviatura.getDescricao();
        Paragraph itemParagraph = new Paragraph(item, fontManager.getDefaultFont());
        itemParagraph.setAlignment(Element.ALIGN_LEFT);
        ch.add(itemParagraph);
    }
    return ch;
}
Also used : Chapter(com.itextpdf.text.Chapter) AbreviaturaDTO(com.tomasio.projects.trainning.dto.AbreviaturaDTO) Paragraph(com.itextpdf.text.Paragraph)

Aggregations

Chapter (com.itextpdf.text.Chapter)27 Paragraph (com.itextpdf.text.Paragraph)25 Section (com.itextpdf.text.Section)8 IOException (java.io.IOException)6 DocumentException (com.itextpdf.text.DocumentException)5 Document (com.itextpdf.text.Document)4 Font (com.itextpdf.text.Font)4 SecaoApostilaDTO (com.tomasio.projects.trainning.dto.SecaoApostilaDTO)4 FileOutputStream (java.io.FileOutputStream)4 PdfPTable (com.itextpdf.text.pdf.PdfPTable)3 PdfWriter (com.itextpdf.text.pdf.PdfWriter)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 DateFormat (java.text.DateFormat)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3 ModelPDFRodape (model.bean.ModelPDFRodape)3 Projeto (model.bean.Projeto)3 Requisito (model.bean.Requisito)3 ProjetoDAO (model.dao.ProjetoDAO)3