You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Nicola Farina <fa...@multidialogo.it> on 2024/01/31 14:07:15 UTC
Filling a form advice
Hi
I need to produce a kind of form filled document like the attached one.
My application receives a print request payload with all the fields of
a kind of "payment postal order".
Then a PDF document, containing the layout, is loaded.
Then I fill it using PDFBox
primitives, basically a sequence of:
newLineAtOffset
followed by
showText
In the attached example, though, there is a new requirement.
There are some areas (I have encircled in red to better identify them)
which I need to place a string whose characters must be inside boxes.
I tried to use
showTextWithPositioning
preparing an array with each character followed by a number
representing the interleaving space, but the output was not the one I
need.
Do I need to manually position each character and then move the cursor
explicitly?
Is there no way to specify a string with some, I don't know, offset
between the chars?
thanks!
Bye
Nicola
Re: Filling a form advice
Posted by Nicola Farina <fa...@multidialogo.it>.
Hi Tilman
thanks for answering so fast!
Actually showTextWithPositioning does the job!
I had a bug in my code so it was not called!
I realised it just after sending the email sorry!
I am using an OCRB font which is fixed size I think
The PDF is not an acroform document, is just an image converted into a
PDF, and I manually write on it
(automating what a human user would do with paper and pen in a
"physical" postal office ... )
From your words I understand that using showTextWithPositioning is the
right choice for this task..
thanks a lot
Nicola
Il giorno mer 31 gen 2024 alle ore 16:01 Tilman Hausherr
<TH...@t-online.de> ha scritto:
>
> Hello Nicola,
>
> Please upload your PDF to a sharehoster, attachments are removed.
>
> showTextWithPositioning is for horizontal positioning of individual
> glyphs, it is the "way to specify a string with some, I don't know,
> offset between the chars". (or vertical, if it is a vertical font)
> it might be tricky if you are using a propotional font. Please explain
> "but the output was not the one I need" - what happened / what did you
> expect to happen?
>
> I'm also wondering whether the PDF is an acroform document, what might
> make things easier.
>
> Tilman
>
> On 31.01.2024 15:07, Nicola Farina wrote:
> > Hi
> >
> > I need to produce a kind of form filled document like the attached one.
> > My application receives a print request payload with all the fields of
> > a kind of "payment postal order".
> > Then a PDF document, containing the layout, is loaded.
> > Then I fill it using PDFBox
> > primitives, basically a sequence of:
> >
> > newLineAtOffset
> > followed by
> > showText
> >
> > In the attached example, though, there is a new requirement.
> > There are some areas (I have encircled in red to better identify them)
> > which I need to place a string whose characters must be inside boxes.
> > I tried to use
> >
> > showTextWithPositioning
> >
> > preparing an array with each character followed by a number
> > representing the interleaving space, but the output was not the one I
> > need.
> >
> > Do I need to manually position each character and then move the cursor
> > explicitly?
> > Is there no way to specify a string with some, I don't know, offset
> > between the chars?
> >
> > thanks!
> > Bye
> > Nicola
> >
> >
> > ---------------------------------------------------------------------
> > 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: Filling a form advice
Posted by Tilman Hausherr <TH...@t-online.de>.
Hello Nicola,
Please upload your PDF to a sharehoster, attachments are removed.
showTextWithPositioning is for horizontal positioning of individual
glyphs, it is the "way to specify a string with some, I don't know,
offset between the chars". (or vertical, if it is a vertical font)
it might be tricky if you are using a propotional font. Please explain
"but the output was not the one I need" - what happened / what did you
expect to happen?
I'm also wondering whether the PDF is an acroform document, what might
make things easier.
Tilman
On 31.01.2024 15:07, Nicola Farina wrote:
> Hi
>
> I need to produce a kind of form filled document like the attached one.
> My application receives a print request payload with all the fields of
> a kind of "payment postal order".
> Then a PDF document, containing the layout, is loaded.
> Then I fill it using PDFBox
> primitives, basically a sequence of:
>
> newLineAtOffset
> followed by
> showText
>
> In the attached example, though, there is a new requirement.
> There are some areas (I have encircled in red to better identify them)
> which I need to place a string whose characters must be inside boxes.
> I tried to use
>
> showTextWithPositioning
>
> preparing an array with each character followed by a number
> representing the interleaving space, but the output was not the one I
> need.
>
> Do I need to manually position each character and then move the cursor
> explicitly?
> Is there no way to specify a string with some, I don't know, offset
> between the chars?
>
> thanks!
> Bye
> Nicola
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail:users-help@pdfbox.apache.org