Surely this is partly a maths question and partly a business logic question.
You can first grab the total number of pages and then loop over the
pagenumber of each page you wish to extract and if it gets over the max,
then make it the max pagenumber and stop looping to guarantee it is the last
page you ask for.
BUT

What if someone makes this PDF without pages two and three?? Then asking for
page 5 will give you the fifth page but not necessarily the result you are
after. And don't use the it would never happen argument here..... :)

john renfrew 
Right Way Up 


-----Original Message-----
From: beppecosta [mailto:beppeco...@yahoo.it] 
Sent: 20 November 2013 13:08
To: itext-questions@lists.sourceforge.net
Subject: Re: [iText-questions] selectpages for non existing page

/> That looks like a case of garbage in, garbage out./

I agree but we receive some pdf from our dealer that SHOULD have 26 pages
(the last page contains the signature) and we must extract the first, fifth
and 28th. page. But possibly there was an error and it was built without
some pages.

The selectpages() method - if the pdf does not contains the 26th page
requested - does not care and returns the last page. If we say that this is
by design, I will run a check of total pages before the extract, but an
exception that says that the input is invalid could be appropriate as well.

Regards. Giuseppe.






--
View this message in context:
http://itext-general.2136553.n4.nabble.com/selectpages-for-non-existing-page
-tp4659480p4659484.html
Sent from the iText - General mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now.

http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a
reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to