You are not logged in.
Hello
I use SynPDF to export the user chats of my application into a PDF file. For that I use the VCL canvas provided by the PDF document, and I draw on it with several GDI and GDI+ functions. The resulting PDF is well generated.
Now I use the exactly same GDI and GDI+ drawing code, but instead of drawing directly on the VCL canvas provided by the PDF document, I generate an intermediate metafile, that I use to draw my page, and later I use this metafile to draw the final page on the PDF document. However the resulting PDF is broken (can be opened at all by Firefox, several parts are missing when opened by Chrome, ...)
Here is the code I use to generate the intermediate metafile canvas:
// create metafile
HDC hMetaFileDC = ::CreateEnhMetaFile(NULL, NULL, NULL, NULL);
if (!hMetaFileDC)
{
M_LogErrorT("Export messages to PDF - FAILED - create metafile");
return false;
}
pCanvas->Handle = hMetaFileDC;
And here is the code I use to draw the intermediate metafile on the final document
// terminate and close the metafile
::HENHMETAFILE hMetaFile = ::CloseEnhMetaFile(hMetaFileDC);
std::auto_ptr<TMetafile> pMeta(new TMetafile());
// use TMetafile object
pMeta->Handle = (unsigned)hMetaFile;
// render meta file
pPdfDoc->Canvas->RenderMetaFile(pMeta.get());
NOTE I also draw a footer after the above code by calling some GDI/GDI+ functions on the pPdfDoc->VCLCanvas
I also joined a copy of a PDF generated from the same content, once without the problem, and once with the problem, here:
https://drive.google.com/open?id=0B7C-R … nZ6Q21hNUk for the well formatted document
https://drive.google.com/open?id=0B7C-R … UhBaG9vekU for the broken document
I cannot figure out why the issue happen. Somebody can explain to me what I'm doing wrong?
Regards
Offline