You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Nick Westerly <de...@gmail.com> on 2017/06/19 23:40:44 UTC

Text Bounding Boxes and Reflowing

Hi -

My ultimate goal is to be able to properly replace text and 'reflow' it - I
know this isn't handled out of the box, but there are a few subproblems I
am trying to first solve that would help me towards this goal. Also, my
text reflowing does not need to be perfect! Just 'kind of work. I am doing
my best to replicate what Acrobat does when you click 'Edit' text as my
attempt, specifically:

A. Like in acrobat when a user clicks 'edit' pdf, it seems that contiguous
areas of text are put together into a single editable textbox, and text
reflows within this text box. Does PDFBOX (or other suggested libraries)
have heuristics or other ideas on how to create these 'paragraph' like
bounding boxes?

B. Acrobat, for instance, will reflow and refit text naturally put inside
of a Form Text Field. Does PDFBOX support form text fields (that presumably
would fit/reflow the text inside of them?) and be able to 'flatten' it?

Anyway - any suggestions are welcome - thanks a lot!

Nick

Re: Text Bounding Boxes and Reflowing

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 21.06.2017 um 00:47 schrieb Nathan Artz:
> Okay great - with regard to adding text, would you recommend any libraries,
> i.e. that have helpful methods 'autofit to size' at all, or reflowing
> within them? For instance, using a form field to do this?

No recommandation... a google search finds this:
https://hardmockcafe.blogspot.com/2016/04/pdf-text-layout-made-easy-with-pdfbox_17.html
But as I said, somewhere in AppearanceGeneratorHelper.java there is code 
to format text, see the call to PlainTextFormatter.

Re: "using a form field" - no, that makes no sense, unless it is a form 
field.


Tilman


>
> Thanks.
>
> On Tue, Jun 20, 2017 at 1:21 PM, Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> PDFTextStripper has heuristics for paragraphs. This issue
>> https://issues.apache.org/jira/browse/PDFBOX-3804
>> has test files and a parameter to change.
>>
>> Yes it does support form fields and flattening. But that is something
>> different than the first problem. Start with AppearanceGeneratorHelper.java
>> and search from there...
>>
>> Tilman
>>
>>
>>
>> Am 20.06.2017 um 01:40 schrieb Nick Westerly:
>>
>>> Hi -
>>>
>>> My ultimate goal is to be able to properly replace text and 'reflow' it -
>>> I
>>> know this isn't handled out of the box, but there are a few subproblems I
>>> am trying to first solve that would help me towards this goal. Also, my
>>> text reflowing does not need to be perfect! Just 'kind of work. I am doing
>>> my best to replicate what Acrobat does when you click 'Edit' text as my
>>> attempt, specifically:
>>>
>>> A. Like in acrobat when a user clicks 'edit' pdf, it seems that contiguous
>>> areas of text are put together into a single editable textbox, and text
>>> reflows within this text box. Does PDFBOX (or other suggested libraries)
>>> have heuristics or other ideas on how to create these 'paragraph' like
>>> bounding boxes?
>>>
>>> B. Acrobat, for instance, will reflow and refit text naturally put inside
>>> of a Form Text Field. Does PDFBOX support form text fields (that
>>> presumably
>>> would fit/reflow the text inside of them?) and be able to 'flatten' it?
>>>
>>> Anyway - any suggestions are welcome - thanks a lot!
>>>
>>> Nick
>>>
>>>
>> ---------------------------------------------------------------------
>> 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: Text Bounding Boxes and Reflowing

Posted by Nathan Artz <na...@gmail.com>.
Okay great - with regard to adding text, would you recommend any libraries,
i.e. that have helpful methods 'autofit to size' at all, or reflowing
within them? For instance, using a form field to do this?

Thanks.

On Tue, Jun 20, 2017 at 1:21 PM, Tilman Hausherr <TH...@t-online.de>
wrote:

> PDFTextStripper has heuristics for paragraphs. This issue
> https://issues.apache.org/jira/browse/PDFBOX-3804
> has test files and a parameter to change.
>
> Yes it does support form fields and flattening. But that is something
> different than the first problem. Start with AppearanceGeneratorHelper.java
> and search from there...
>
> Tilman
>
>
>
> Am 20.06.2017 um 01:40 schrieb Nick Westerly:
>
>> Hi -
>>
>> My ultimate goal is to be able to properly replace text and 'reflow' it -
>> I
>> know this isn't handled out of the box, but there are a few subproblems I
>> am trying to first solve that would help me towards this goal. Also, my
>> text reflowing does not need to be perfect! Just 'kind of work. I am doing
>> my best to replicate what Acrobat does when you click 'Edit' text as my
>> attempt, specifically:
>>
>> A. Like in acrobat when a user clicks 'edit' pdf, it seems that contiguous
>> areas of text are put together into a single editable textbox, and text
>> reflows within this text box. Does PDFBOX (or other suggested libraries)
>> have heuristics or other ideas on how to create these 'paragraph' like
>> bounding boxes?
>>
>> B. Acrobat, for instance, will reflow and refit text naturally put inside
>> of a Form Text Field. Does PDFBOX support form text fields (that
>> presumably
>> would fit/reflow the text inside of them?) and be able to 'flatten' it?
>>
>> Anyway - any suggestions are welcome - thanks a lot!
>>
>> Nick
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Text Bounding Boxes and Reflowing

Posted by Tilman Hausherr <TH...@t-online.de>.
PDFTextStripper has heuristics for paragraphs. This issue
https://issues.apache.org/jira/browse/PDFBOX-3804
has test files and a parameter to change.

Yes it does support form fields and flattening. But that is something 
different than the first problem. Start with 
AppearanceGeneratorHelper.java and search from there...

Tilman


Am 20.06.2017 um 01:40 schrieb Nick Westerly:
> Hi -
>
> My ultimate goal is to be able to properly replace text and 'reflow' it - I
> know this isn't handled out of the box, but there are a few subproblems I
> am trying to first solve that would help me towards this goal. Also, my
> text reflowing does not need to be perfect! Just 'kind of work. I am doing
> my best to replicate what Acrobat does when you click 'Edit' text as my
> attempt, specifically:
>
> A. Like in acrobat when a user clicks 'edit' pdf, it seems that contiguous
> areas of text are put together into a single editable textbox, and text
> reflows within this text box. Does PDFBOX (or other suggested libraries)
> have heuristics or other ideas on how to create these 'paragraph' like
> bounding boxes?
>
> B. Acrobat, for instance, will reflow and refit text naturally put inside
> of a Form Text Field. Does PDFBOX support form text fields (that presumably
> would fit/reflow the text inside of them?) and be able to 'flatten' it?
>
> Anyway - any suggestions are welcome - thanks a lot!
>
> Nick
>


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