/** * Constructs a <CODE>HtmlWriter</CODE>. * * @param doc The <CODE>Document</CODE> that has to be written as HTML * @param os The <CODE>OutputStream</CODE> the writer has to write to. */ protected HtmlWriter(Document doc, OutputStream os) { super(doc, os); document.addDocListener(this); this.pageN = document.getPageNumber(); try { os.write(LT); os.write(getISOBytes(HtmlTags.HTML)); os.write(GT); os.write(NEWLINE); os.write(TAB); os.write(LT); os.write(getISOBytes(HtmlTags.HEAD)); os.write(GT); } catch(IOException ioe) { throw new ExceptionConverter(ioe); } }
/** * Constructs a <CODE>HtmlWriter</CODE>. * * @param doc The <CODE>Document</CODE> that has to be written as HTML * @param os The <CODE>OutputStream</CODE> the writer has to write to. */ protected HtmlWriter(Document doc, OutputStream os) { super(doc, os); document.addDocListener(this); this.pageN = document.getPageNumber(); try { os.write(LT); os.write(getISOBytes(HtmlTags.HTML)); os.write(GT); os.write(NEWLINE); os.write(TAB); os.write(LT); os.write(getISOBytes(HtmlTags.HEAD)); os.write(GT); } catch(IOException ioe) { throw new ExceptionConverter(ioe); } }
private void setPagenumberToTOC(Document document){ if(templateList.size() > 0){ PdfTemplate currentPageTemplate_ = (PdfTemplate)templateList.remove(0); currentPageTemplate_.beginText(); currentPageTemplate_.setFontAndSize(PdfUtils.BASEFONT_MINCHO,10); currentPageTemplate_.showText(document.getPageNumber() + ""); currentPageTemplate_.endText(); } }
/** * Constructs a <CODE>HtmlWriter</CODE>. * * @param doc The <CODE>Document</CODE> that has to be written as HTML * @param os The <CODE>OutputStream</CODE> the writer has to write to. */ protected HtmlWriter(Document doc, OutputStream os) { super(doc, os); document.addDocListener(this); this.pageN = document.getPageNumber(); try { os.write(LT); os.write(getISOBytes(HtmlTags.HTML)); os.write(GT); os.write(NEWLINE); os.write(TAB); os.write(LT); os.write(getISOBytes(HtmlTags.HEAD)); os.write(GT); } catch(IOException ioe) { throw new ExceptionConverter(ioe); } }
private void addHeaderAndFooter(PdfWriter writer, Document document) { if (document.getPageNumber() == 1) { return; } String header = docInstallArgs.getDocName() + " version" + docInstallArgs.getVersion(); PdfContentByte directContent = writer.getDirectContent(); Phrase headerPhare = ItextUtil.getFontSelector(9, Font.NORMAL, Color.LIGHT_GRAY).process(header); headerPhare.add(new LineSeparator(0.5f, 2.5f, Color.LIGHT_GRAY, Element.ALIGN_LEFT, -5f)); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, headerPhare, document.left(), document.top() + 20, 0); String footer = Integer.valueOf(document.getPageNumber()).toString(); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, textbFont.process(footer), document.getPageSize().getWidth() / 2.0f - 20, document.bottom() - 20, 0); }
private void renderFooter(PdfWriter writer, Document document){ // footer lines // int num = writer.getPageNumber(); int num = document.getPageNumber(); String text = FOOTERPREFIX + num + FOOTERMIDDLE; float len = PdfUtils.BASEFONT_MINCHO.getWidthPoint(text, size_); cb_.moveTo(document.left(),PAGEMARGIN_BOTTOM - 5); cb_.lineTo(document.right(),PAGEMARGIN_BOTTOM - 5); cb_.stroke(); // don't forget !! // footer contents cb_.beginText(); cb_.setFontAndSize(PdfUtils.BASEFONT_MINCHO,size_); cb_.setTextMatrix(footerX_, PAGEMARGIN_BOTTOM/2); cb_.showText(text); cb_.endText(); // adding template point into direct content. cb_.addTemplate(template_,footerX_+len, PAGEMARGIN_BOTTOM/2); }
@Override public void onChapter(final PdfWriter writer, final Document document, final float position, final Paragraph title) { content.getDefaultCell().setBorderColorBottom(Color.LIGHT_GRAY); content.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); content.getDefaultCell().setUseBorderPadding(true); content .addCell(new Phrase(title.getContent(), new Font(Font.HELVETICA, 11))); content.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); content.addCell(new Phrase("Page " + document.getPageNumber(), new Font( Font.HELVETICA, 11))); content.getDefaultCell().setBorderColorBottom(Color.WHITE); content.getDefaultCell().setUseBorderPadding(false); }
addPageNumber(foot, font, pb.isPageNumberAtFooter(), document.getPageNumber());