Jonathan Sibony wrote:

> I know it should be fairly easy, but I am not at all sure of the way to
> do it ( PdfXRef::AddObject() ? accessed within a PdfWriter ? Or I am
> missing it all)

Understandable - it takes a bit of work with the library to understand
how things like PdfImage relate to the underlying document tree.

I've written a bit that might help below. However, I haven't spent
enough time checking it carefully against the sources and this is a part
of PoDoFo I'm much less familiar with, so please keep the possibility of
inaccuracies in mind.

I'm hoping to find time to write some explanatory documentation about
this later, but in short PdfImage's inheritance tree is:

PdfImage <- PdfXObject <- PdfElement
                       <- PdfCanvas

In other words, PdfImage, being based on PdfElement, is a class for
manipulating an element in the the document tree. The actual object(s) -
dictionaries, arrays, etc - being manipulated aren't a part of the
PdfImage class but are only referenced.

PdfImage's referenced base object is a PdfObject (always indirect)
containing a dictionary with an attached stream. This isn't visible in
the type system; all you can see is that its' PdfElement base has a
`PdfObject* m_pObject' member variable plus GetObject() accessor method.

If you want to directly manipulate the PdfImage's dictionary, you want
to mess with m_pObject's dictionary. From within PdfObject that's
visible as:

GetObject()->GetDictionary()

which has return type PdfDictionary& .

If you need to create a new indirect object and insert a reference into
the dictionary, use PdfVecObject::CreateObject(...) to create the
indirect object. If you need to give it a stream, use
PdfObject::GetStream() once you've created the object.

Each PDF document has a single PdfVecObjects instance. You'll need to
take this as an argument to your `SetICCProfile(...)' or whatever
method, since the PdfImage doesn't keep track of its owning document. To
the caller, the interface would thus be something like:

SetICCProfile(PdfVecObjects* parent,
              const PdfName& alternate,
              const char * psProfileBytes,
              long int psProfileLength);

Much of this is probably less than ideal in terms of interface and API.
Just explaining it has helped me get some ideas about how it could
perhaps be made easier to understand through documentation and a few
changes.

--
Craig Ringer

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to