pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Hewson <j...@jahewson.com>
Subject Re: Insert Cover Page (2.0.0)
Date Tue, 13 Oct 2015 20:00:47 GMT
> Iterator<PDPage> iterator = doc.getPages.iterator()
> while(iterator.hasNext()) {
>  PDPage page = iterator.next();
>  addFooter(doc, page, regularFont, footerDetail)
> }

This can be simplified to:

> for(PDPage page : doc.getPages()) {
>  addFooter(doc, page, regularFont, footerDetail)
> }

— John

> On 13 Oct 2015, at 07:24, Adam Retter <adam.retter@googlemail.com> wrote:
> 
> On 13 October 2015 at 14:34, Maruan Sahyoun <sahyoun@fileaffairs.de> wrote:
>> Hi,
>> 
>> glad it worked. I would be interested in how you add the footer to the page i.e.
how do you do the iteration, how do you add the additional content. It's always good for us
to get a better understanding of how PDFBox is actually used.
>> 
> 
> Once I have opened my document, set some metadata and inserted my
> cover page, then I basically have something similar to this:
> 
> Iterator<PDPage> iterator = doc.getPages.iterator()
> while(iterator.hasNext()) {
>  PDPage page = iterator.next();
>  addFooter(doc, page, regularFont, footerDetail)
> }
> 
> private void addFooter(PDDocument doc, PDPage page, PDFont
> regularFont, FooterDetail footerDetail) {
>  try(final PDPageContentStream contentStream = new
> PDPageContentStream(doc, page, true, true, true)) {
>    //various positioning, and calls to beginText, setFont, showText, endText
>  }
> }
> 
> 
> -- 
> Adam Retter
> 
> skype: adam.retter
> tweet: adamretter
> http://www.adamretter.org.uk
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message