You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Bob Swanson <rd...@swansongrp.com> on 2010/06/28 20:59:49 UTC

PDJpeg creation order problem

I have discovered a state problem that I did
not understand, until I tried to put images
in my document with the text.

It appears that you have to create all of
the PDJpeg objects after the PDDocument
is created and BEFORE you try to
create any text using the PDPageContentStream
object.

When I tried to create the PDJpeg object
in the same part of my code where I was
creating text, the text PDF stream was
getting mixed in with the "stream"
where the XOjbect is defined. This
situation makes some of the text disappear,
and the PDF reader throws errors
trying to process the image.

This issue begs the question of how
you create mixed image/text documents
"on the fly", where you don't know
whether you will embed an image, or
where you don't know the name of
the image file until the instant
you have to create the text stream.

I can provide code, if desired, but
I used the ImageToPDF example as a base
for trying to also write some text
along with the image created in
this code.