use of com.itextpdf.text.Chapter in project trainning by fernandotomasio.
the class DOC001PDF method buildChapter2.
private Chapter buildChapter2(CurriculoMinimoDTO curriculo) {
Chapter ch = new Chapter(new Paragraph("CONCEPÇÃO ESTRUTURAL DO CURSO", fontManager.getBoldFont()), 2);
IReportUtil.fillChapter(ch, curriculo.getConcepcaoEstrutural());
return ch;
}
use of com.itextpdf.text.Chapter in project trainning by fernandotomasio.
the class DOC001PDF method buildChapter1.
private Chapter buildChapter1(CurriculoMinimoDTO curriculo) {
Chapter ch = new Chapter(new Paragraph("DISPOSIÇÕES PRELIMINARES", fontManager.getBoldFont()), 1);
Section section1 = ch.addSection(new Paragraph("FINALIDADE", fontManager.getUnderlineFont()));
IReportUtil.fillSection(section1, curriculo.getFinalidadeInstrucao());
Section section2 = ch.addSection(new Paragraph("ÂMBITO", fontManager.getUnderlineFont()));
IReportUtil.fillSection(section2, curriculo.getAmbito());
Section section3 = ch.addSection(new Paragraph("DEFINIÇÕES", fontManager.getUnderlineFont()));
IReportUtil.fillSection(section3, curriculo.getConceituacoes());
return ch;
}
use of com.itextpdf.text.Chapter in project trainning by fernandotomasio.
the class DOC003PDF method buildCapitulo.
private Chapter buildCapitulo(CapituloApostilaDTO capitulo, XMLParser p, Document document) throws IOException, DocumentException {
UnidadeDidaticaDTO unidade = teachingDocumentsService.findUnidadeDidatica(capitulo.getUnidadeDidatica().getId());
String capituloLabel = "UNIDADE " + unidade.getNumeroGeral() + ": " + capitulo.getUnidadeDidatica().getDescricao().toUpperCase();
Paragraph capituloParagraph = new Paragraph(capituloLabel, fontManager.getH1Font());
Chapter ch = new Chapter(capituloParagraph, capitulo.getUnidadeDidatica().getNumero());
ch.setNumberDepth(0);
buildFolhaRostoCapitulo(ch, capitulo);
SecaoApostilaDTO[] secoes = teachingDocumentsService.findAllSecoesApostila(capitulo.getId());
for (SecaoApostilaDTO secao : secoes) {
if (secao.getContent() != null) {
buildSection(ch, secao, p, document);
}
}
return ch;
// fim do capitulo
}
use of com.itextpdf.text.Chapter in project trainning by fernandotomasio.
the class DOC003PDF 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 apostilaIdParam = (String) params.get("apostilaId");
Long apostilaId = Long.parseLong(apostilaIdParam);
ApostilaDTO apostila = teachingDocumentsService.findApostila(apostilaId);
CurriculoMinimoDTO curriculo = teachingDocumentsService.findCurriculoMinimo(apostila.getDisciplina().getCurriculoMinimo().getId());
buildCover(document, curriculo, apostila);
CapituloApostilaDTO[] capitulos = teachingDocumentsService.findAllCapitulosApostila(apostilaId);
for (CapituloApostilaDTO capitulo : capitulos) {
Chapter ch = buildCapitulo(capitulo, p, document);
document.add(ch);
}
document.add(buildReferencias(apostilaId));
document.add(buildSumario(eventHandler.titles));
} catch (DocumentException e) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
throw new CoreException(e.getMessage());
} catch (IOException ex) {
Logger.getLogger(DOC003PDF.class.getName()).log(Level.SEVERE, null, ex);
} finally {
document.close();
}
try {
PdfReader reader = new PdfReader(os.toByteArray());
int n = reader.getNumberOfPages();
String pagesInterval = String.format("1-2,%d, 3-%d", n, n - 1);
reader.selectPages(pagesInterval);
os = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader, os);
stamper.close();
reader.close();
} catch (IOException | DocumentException ex) {
Logger.getLogger(DOC003PDF.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of com.itextpdf.text.Chapter in project trainning by fernandotomasio.
the class DOC003PDF method buildReferencias.
private Chapter buildReferencias(Long apostilaId) {
ApostilaDTO apostila = teachingDocumentsService.findApostila(apostilaId);
ReferenciaDTO[] referencias = teachingDocumentsService.findAllReferenciasByDisciplina(apostila.getDisciplina().getId());
String referenciasLabel = "REFERÊNCIAS";
Paragraph referenciasChapter = new Paragraph(referenciasLabel, fontManager.getBoldFont());
referenciasChapter.setAlignment(Element.ALIGN_CENTER);
Chapter ch = new Chapter(referenciasChapter, 0);
ch.setNumberDepth(0);
ch.add(Chunk.NEWLINE);
for (ReferenciaDTO referencia : referencias) {
ch.add(new Paragraph(referencia.getTexto(), fontManager.getDefaultFont()));
}
return ch;
}
Aggregations