OpenPDF icon indicating copy to clipboard operation
OpenPDF copied to clipboard

Not Show the getNumberPage on the Page 1

Open Neanrakyr opened this issue 3 years ago • 3 comments

Hello,

Today i'm trying to not show the getNumberPage on the first page if you only have one page in the document.

I trySoemthing like it

if(writer.setPageNumber > 1 {
 //show the footer endpage on page 1/2/3
...
} else {
 //don't show the footer endpage on the page 1 if only 1 page
  ...
}

but it only show the second page and not show the firstpage if i have 2 page in the document

so i try something like it

if (nbPage == 0) {
  nbPage == 1
}

for(int i = 0; i > nbPage; i++) {
 //show the footer endpage on page 1/2/3
}

but that dont work too...

Anyone can help me to find the solution and if you have the solution to show the totalPage of the document too.

Thank you very much.

Neanrakyr avatar May 22 '22 11:05 Neanrakyr

Do you use PdfEvent for this? You are using writer.getPageNumber() I suppose, not setPageNumber

Try debugging the creation process and watch carefully, which value you get.

arnthom avatar May 25 '22 07:05 arnthom

@arnthom

yes sorry i use getPageNumber()

I don't find anysolution yet. I would like to show the getPageNumber() only if you have more than 1 page.

You have any idea?

Neanrakyr avatar Jun 02 '22 02:06 Neanrakyr

That's the problem, with the event onEndPage you can just "see" this peticular page. In iText there seems to be a PdfDocument method called getNumberOfPages() (instead of getPageNumber()) to retrieve this value. In OpenPDF I have not found such. As a first step you could hide the page number 1 and start counting at 2 ...

arnthom avatar Jun 02 '22 06:06 arnthom