I hope I can clear this a bit up:

PdfImage::SetImageData does write all data directly into a PdfStream object 
(PdfStream::Set). If you are using PdfStreamedDocument all data written to a 
PdfStream is written directly to disc (see PdfFileStream).

To explain how this can work without a page being created:
PdfImages are embedded directly into the PDF file when you are creating them. 
This has the advantage that an image can be used on multiple pages but has to 
be embedded only once. If you use PdfPainter::DrawImage it writes only a 
reference to the image to the page. As a reason the data is only embedded 
once and can be written directly to disc when creating the PdfImage.

This is why image handling in PDF is very efficient and superior to image 
handling in PostScript. Images can be reused.

best regards,
        Dom

Am Wednesday 01 August 2007 schrieb Jonathan Sibony:
> Thanks for the new check-ins, that's really great!
>
> As to the PdfStreamedDocument, I must say I am a bit lost here, you say
> below:
>
> // Now write the image out to disc
> pImage.SetImageData (imgChunk.width, imgChunk.height, 8, &pStream);
>
> How exactly are you writing to disc here? a page wasn't yet created, and
> obviously it is not written to the document directly, so you do have the
> pdf images in memory all that time (unless you somehow write to
> temporary file and read it when painter DrawImage() the content of the
> page, which I doubt).
>
> Where's the flushing mechanism?
>
> Thanks in advance
> yoni
>
>
> -----Original Message-----
> From: Dominik Seichter [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 31, 2007 3:33 PM
> To: [email protected]
> Cc: Jonathan Sibony
> Subject: Re: [Podofo-users] Write current object to file
>
> Hi,
>
> Well this is what PdfStreamedDocument will do for you. After my latest
> commit
> you should be able to use PdfStreamedDocument as you can now set the
> PdfVersion to 1.6.
>
> One thing you have to be careful about is, that PdfStreamedDocument is
> only
> able to stream one object out to disc directly at a time. So you should
> not
> work on a page and an image at the same time. Some code like this should
> give
> you best performance.
>
> PdfStreamedDocument doc( "file.pdf", ePdfVersion_1_6 );
> PdfPainter painter;
>
> Image imgChunk = GetNextChunk();
> PdfMemoryInputStream pStream
> (imgChunk.GetBuffer(),imgChunk.GetSizeInBytes());
> PdfImage pImage(&document);
> // Now write the image out to disc
> pImage.SetImageData (imgChunk.width, imgChunk.height, 8, &pStream);
>
> PdfPage* pPage = document.CreatePage( size );
> painter.SetPage( pPage );
> // page contents can now also be written to disc and the image is
> already
> written out
> painter.DrawImage( pImage );
>
> Maybe you have to create an array of PdfImage objects before creating
> your
> page, but this won't matter as a PdfImage is small in memory as all data
> is
> streamed out to disc when used with PdfStreamedDocument.
>
> best regards,
>       Dom
>
> Am Tuesday 31 July 2007 schrieb Jonathan Sibony:
> >     Hello All,
> >
> >     Small question regarding the way things are being written to
> > file in PdfDocument.
> >     For now the way I put images into my document is pretty much as
> > follows:
> >
> >     PdfDocument document;
> >     document.SetPdfVersion(ePdfVersion_1_6);
> >     ...
> >     PdfPage* pPage = document.CreatePage(rSize);
> >
> >     PdfPainter painter;
> >     painter.SetPage( pPage );
> >
> >     while(i < ...)
> >     {
> >             Image imgChunk = GetNextChunk();
> >             PdfMemoryInputStream pStream
> > (imgChunk.GetBuffer(),imgChunk.GetSizeInBytes());
> >
> >             PdfImage pImage(&document);
> >             pImage.SetImageData (imgChunk.width, imgChunk.height, 8,
> > &pStream);
> >
> >             painter.DrawImage (0, i, &pImage, 1.0, 1.0);
> >             i += imgChunk.height;
> >     }
> >
> >     painter.FinishPage();
> >     document.Write (fname);
> >
> >
> >     This work fine, however it means I hold the document in memory
> > till I call the Write() function to flush it down to file.
> >     This can pose a problem when images chunks are numerous and
> > quite big.
> >     What I would really like is a way to flush each chunk to file
> > within the loop, right after DrawImage by the painter i.e. a way to
> > write the current object without any need to wait till the page is
> > finished.
> >
> >     Is it possible?
> >
> >     Many Thanks!
> >     Jonathan



-- 
**********************************************************************
Dominik Seichter - [EMAIL PROTECTED]
KRename  - http://www.krename.net  - Powerful batch renamer for KDE
KBarcode - http://www.kbarcode.net - Barcode and label printing
PoDoFo - http://podofo.sf.net - PDF generation and parsing library
SchafKopf - http://schafkopf.berlios.de - Schafkopf, a card game,  for KDE
Alan - http://alan.sf.net - A Turing Machine in Java
**********************************************************************

Attachment: pgpIFRrDPPOJL.pgp
Description: PGP signature

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to