You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Pa...@t-systems.com on 2024/05/17 08:25:47 UTC

Question about commit "PDFBOX-5660: add warning / exception, as suggested by mkl in SO 78307200"

Hi,

concerning commit: "PDFBOX-5660: add warning / exception, as suggested by mkl in SO 78307200" (https://github.com/apache/pdfbox/commit/5c0abf94367c12c9ac0b464046784d456ce4caf5)

After this commit this code:

for (int pageNumber = 0; pageNumber < pdDocument.getNumberOfPages(); pageNumber++) {
    PDPage pdPage = pdDocument.getPage(pageNumber);
    ...
    String textForRegion = extractText(pdPage, rect);}

private static String extractText(PDPage pdPage, Rectangle2D rect) throws IOException {
    String regionName = "rectangle";
    PDFTextStripperByArea textStripper = new PDFTextStripperByArea();
    textStripper.setSortByPosition(true);
    textStripper.addRegion(regionName, rect);
    textStripper.extractRegions(pdPage);
    return textStripper.getTextForRegion(regionName);
}

Which worked with PDF Box 3 and trunk before this change now fails with:

java.lang.IllegalArgumentException: Parameter must be 1-based, but is 0
	at org.apache.pdfbox.text.PDFTextStripper.setStartPage(PDFTextStripper.java:956)
	at org.apache.pdfbox.text.PDFTextStripperByArea.extractRegions(PDFTextStripperByArea.java:117)
...

I believe 0 should still be allowed, or am I missing something?

Thanks and kind regards,
Pascal

By the way: Thank you very much for providing PDFBox.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: AW: Question about commit "PDFBOX-5660: add warning / exception, as suggested by mkl in SO 78307200"

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

It's fixed now.
Thanks again

Tilman

On 17.05.2024 11:43, Pascal.Schumacher@t-systems.com wrote:
> Yes. The commit was made on Apr 19, that should be after the latest releases. I only discovered it after building from trunk.
>
> Thank you very much for the quick response!
>
> Kind regards,
> Pascal
>
> -----Ursprüngliche Nachricht-----
> Von: Tilman Hausherr <TH...@t-online.de>
> Gesendet: Freitag, 17. Mai 2024 11:37
> An: users@pdfbox.apache.org
> Betreff: Re: Question about commit "PDFBOX-5660: add warning / exception, as suggested by mkl in SO 78307200"
>
> I've created https://issues.apache.org/jira/browse/PDFBOX-5822 . This isn't in the released versions, correct? Then we have to thank you even more for discovering this.
>
> Tilman
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


AW: Question about commit "PDFBOX-5660: add warning / exception, as suggested by mkl in SO 78307200"

Posted by Pa...@t-systems.com.
Yes. The commit was made on Apr 19, that should be after the latest releases. I only discovered it after building from trunk.

Thank you very much for the quick response!

Kind regards,
Pascal

-----Ursprüngliche Nachricht-----
Von: Tilman Hausherr <TH...@t-online.de>
Gesendet: Freitag, 17. Mai 2024 11:37
An: users@pdfbox.apache.org
Betreff: Re: Question about commit "PDFBOX-5660: add warning / exception, as suggested by mkl in SO 78307200"

I've created https://issues.apache.org/jira/browse/PDFBOX-5822 . This isn't in the released versions, correct? Then we have to thank you even more for discovering this.

Tilman


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Question about commit "PDFBOX-5660: add warning / exception, as suggested by mkl in SO 78307200"

Posted by Tilman Hausherr <TH...@t-online.de>.
I've created https://issues.apache.org/jira/browse/PDFBOX-5822 . This 
isn't in the released versions, correct? Then we have to thank you even 
more for discovering this.

Tilman


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Question about commit "PDFBOX-5660: add warning / exception, as suggested by mkl in SO 78307200"

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

Thanks for finding this. Sadly there were no tests. I'll investigate.


Tilman

On 17.05.2024 10:25, Pascal.Schumacher@t-systems.com wrote:
> Hi,
>
> concerning commit: "PDFBOX-5660: add warning / exception, as suggested by mkl in SO 78307200" (https://github.com/apache/pdfbox/commit/5c0abf94367c12c9ac0b464046784d456ce4caf5)
>
> After this commit this code:
>
> for (int pageNumber = 0; pageNumber < pdDocument.getNumberOfPages(); pageNumber++) {
>      PDPage pdPage = pdDocument.getPage(pageNumber);
>      ...
>      String textForRegion = extractText(pdPage, rect);}
>
> private static String extractText(PDPage pdPage, Rectangle2D rect) throws IOException {
>      String regionName = "rectangle";
>      PDFTextStripperByArea textStripper = new PDFTextStripperByArea();
>      textStripper.setSortByPosition(true);
>      textStripper.addRegion(regionName, rect);
>      textStripper.extractRegions(pdPage);
>      return textStripper.getTextForRegion(regionName);
> }
>
> Which worked with PDF Box 3 and trunk before this change now fails with:
>
> java.lang.IllegalArgumentException: Parameter must be 1-based, but is 0
> 	at org.apache.pdfbox.text.PDFTextStripper.setStartPage(PDFTextStripper.java:956)
> 	at org.apache.pdfbox.text.PDFTextStripperByArea.extractRegions(PDFTextStripperByArea.java:117)
> ...
>
> I believe 0 should still be allowed, or am I missing something?
>
> Thanks and kind regards,
> Pascal
>
> By the way: Thank you very much for providing PDFBox.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org