With my MFC application, I am able to print my CDocument on screen using the CView class. Basically, I use the CDC class to write text and draw polygons on screen to provide a view representation of my document.
Now let's say I would like to use that output view in Microsoft Word.
From a user point a view and without anymore developer work, I can :
These two effortless solutions are great because I can keep the exact layout of my view, but have cons (raster or format)
Another way to solve my problem would be to write SVG or VML but I would not get the same layout and this would require a lot of work.
Is there a library to do the same kind of PDF export / print mechanism into a standard format ?
What would you suggest ? Thanks a lot.
To draw your view into a Enhanced Meta File, first read the documentation @ MSDN: http://msdn.microsoft.com/en-us/library/427wezx1%28v=VS.80%29.aspx
Here is an example, how this works:
CMetaFileDC MFDC;
CRect rect(0,0,width,height);
MFDC.CreateEnhanced(NULL,NULL,rect,NULL);
MFDC.SetBkMode(TRANSPARENT);
MFDC.SetMapMode(MM_HIMETRIC);
CDC tempDC;
tempDC.CreateCompatibleDC(&MFDC);
MFDC.SetAttribDC(tempDC.m_hDC);
// now you draw into the DC like it was your original view
HENHMETAFILE hEnhMetaFile = MFDC.CloseEnhanced();
HENHMETAFILE hEMF = NULL;
hEMF = CopyEnhMetaFile(hEnhMetaFile,"C:\\Temp\\Test.emf");
DeleteEnhMetaFile(hEMF);
DeleteEnhMetaFile(hEnhMetaFile);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With