You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Blake McBride <bl...@gmail.com> on 2016/03/09 04:31:45 UTC

How to reset text on a new page?

Hi,

I get that one starts text with contentStream.beginText() and ends text
with contentStream.endText().  And I get that one gets a new page with doc
.addPage(page).  But when I use all this to print two pages, I end up with
two pages each with the same text (the merge of the contents of the two
pages).  How can I clear the page contents for a new page?  (I didn't see
an example that printed two pages in the examples.)

Thanks!

Blake McBride

Re: How to reset text on a new page?

Posted by Blake McBride <bl...@gmail.com>.
I should have stated that I am using 2.x.

Thanks.

On Tue, Mar 8, 2016 at 9:31 PM, Blake McBride <bl...@gmail.com> wrote:

> Hi,
>
> I get that one starts text with contentStream.beginText() and ends text
> with contentStream.endText().  And I get that one gets a new page with doc
> .addPage(page).  But when I use all this to print two pages, I end up
> with two pages each with the same text (the merge of the contents of the
> two pages).  How can I clear the page contents for a new page?  (I didn't
> see an example that printed two pages in the examples.)
>
> Thanks!
>
> Blake McBride
>
>

Re: How to reset text on a new page?

Posted by Blake McBride <bl...@gmail.com>.
Thanks.  I actually got it working.  I have even switched between text mode
and line drawing mode.  I'm now working on being able to switch back to
text mode.

Thanks for the help!

Blake


On Thu, Mar 10, 2016 at 11:10 AM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Am 10.03.2016 um 15:50 schrieb Blake McBride:
>
>> Thanks, but getting a little confused here.  Let me ask this:
>>
>> Each page in a document has its own PDPageContentStream _and_ PDPage.
>> This
>> means that there is a one-to-one relationship between
>> PDPageContentStream's
>> and PDPage objects.  Is that (always) true?
>>
>
> No. It is possible to have the same content stream for several pages. It
> is even possible to have the same page object several times. This is
> possible, but would not be very useful, obviously. And that may be what
> happened to you.
>
> And it is also possible to have an array of content streams for one page,
> but that is a different story.
>
> If still you don't know what went wrong, please post your code (rather,
> the shortest possible code that reproduces the problem).
>
> Tilman
>
>
>
>
>> Thanks.
>>
>> Blake
>>
>>
>>
>> On Wed, Mar 9, 2016 at 12:28 AM, Tilman Hausherr <TH...@t-online.de>
>> wrote:
>>
>> You must create a new content stream object for each page. And of course
>>> also a new PDPage object too.
>>>
>>> Tilman
>>>
>>>
>>> Am 09.03.2016 um 04:31 schrieb Blake McBride:
>>>
>>> Hi,
>>>>
>>>> I get that one starts text with contentStream.beginText() and ends text
>>>> with contentStream.endText().  And I get that one gets a new page with
>>>> doc
>>>> .addPage(page).  But when I use all this to print two pages, I end up
>>>> with
>>>> two pages each with the same text (the merge of the contents of the two
>>>> pages).  How can I clear the page contents for a new page?  (I didn't
>>>> see
>>>> an example that printed two pages in the examples.)
>>>>
>>>> Thanks!
>>>>
>>>> Blake McBride
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>> 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: How to reset text on a new page?

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 10.03.2016 um 15:50 schrieb Blake McBride:
> Thanks, but getting a little confused here.  Let me ask this:
>
> Each page in a document has its own PDPageContentStream _and_ PDPage.  This
> means that there is a one-to-one relationship between PDPageContentStream's
> and PDPage objects.  Is that (always) true?

No. It is possible to have the same content stream for several pages. It 
is even possible to have the same page object several times. This is 
possible, but would not be very useful, obviously. And that may be what 
happened to you.

And it is also possible to have an array of content streams for one 
page, but that is a different story.

If still you don't know what went wrong, please post your code (rather, 
the shortest possible code that reproduces the problem).

Tilman


>
> Thanks.
>
> Blake
>
>
>
> On Wed, Mar 9, 2016 at 12:28 AM, Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> You must create a new content stream object for each page. And of course
>> also a new PDPage object too.
>>
>> Tilman
>>
>>
>> Am 09.03.2016 um 04:31 schrieb Blake McBride:
>>
>>> Hi,
>>>
>>> I get that one starts text with contentStream.beginText() and ends text
>>> with contentStream.endText().  And I get that one gets a new page with doc
>>> .addPage(page).  But when I use all this to print two pages, I end up with
>>> two pages each with the same text (the merge of the contents of the two
>>> pages).  How can I clear the page contents for a new page?  (I didn't see
>>> an example that printed two pages in the examples.)
>>>
>>> Thanks!
>>>
>>> Blake McBride
>>>
>>>
>> ---------------------------------------------------------------------
>> 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: How to reset text on a new page?

Posted by Blake McBride <bl...@gmail.com>.
Thanks, but getting a little confused here.  Let me ask this:

Each page in a document has its own PDPageContentStream _and_ PDPage.  This
means that there is a one-to-one relationship between PDPageContentStream's
and PDPage objects.  Is that (always) true?

Thanks.

Blake



On Wed, Mar 9, 2016 at 12:28 AM, Tilman Hausherr <TH...@t-online.de>
wrote:

> You must create a new content stream object for each page. And of course
> also a new PDPage object too.
>
> Tilman
>
>
> Am 09.03.2016 um 04:31 schrieb Blake McBride:
>
>> Hi,
>>
>> I get that one starts text with contentStream.beginText() and ends text
>> with contentStream.endText().  And I get that one gets a new page with doc
>> .addPage(page).  But when I use all this to print two pages, I end up with
>> two pages each with the same text (the merge of the contents of the two
>> pages).  How can I clear the page contents for a new page?  (I didn't see
>> an example that printed two pages in the examples.)
>>
>> Thanks!
>>
>> Blake McBride
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: How to reset text on a new page?

Posted by Tilman Hausherr <TH...@t-online.de>.
You must create a new content stream object for each page. And of course 
also a new PDPage object too.

Tilman

Am 09.03.2016 um 04:31 schrieb Blake McBride:
> Hi,
>
> I get that one starts text with contentStream.beginText() and ends text
> with contentStream.endText().  And I get that one gets a new page with doc
> .addPage(page).  But when I use all this to print two pages, I end up with
> two pages each with the same text (the merge of the contents of the two
> pages).  How can I clear the page contents for a new page?  (I didn't see
> an example that printed two pages in the examples.)
>
> Thanks!
>
> Blake McBride
>


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