tags:

views:

177

answers:

1

My c++ MFC MDI application displays engineering drawings in its views. What is a good way to dump a CView derived object into a PDF file? What libraries could you suggest (not nesesery free)? I've looked into a few libraries like Cairo and libHaru. It is possible to draw all the graphic components but I was thinking that the CView has allready all the drawingins done. Can it be dumped into a PDF through a PS or something like it? Thanks

+1  A: 

If you download CutePDF you can print directly to a PDF. Its just like normal printer based printing. I'm pretty sure if you get acrobat pro from adobe you can do the same thing.

Edit:

Using a device context you can do all your drawing in a way that "could" be used by a driver to store vector graphics.

If you handle the WM_PRINT command (ON_MESSAGE in your message map) then you are supplied an HDC. You can retrieve an MFC style CDC from the HDC by doing the following:

CDC* pDC = CDC::FromHandle( hDC );

Now you can issue standard DC drawing commands to the printer as follows:

int width = pDC->GetDeviceCaps( HORZRES );
int height = pDC->GetDeviceCaps( VERTRES );
pDC->MoveTo( 0, 0 );
pDC->LineTo( width, height );

This will draw a from the top left corner to the bottom right corner. If you scale all your vector graphics accordingly they will, hopefully (I'm, unfortunately, not sure of this, though), appear on the PDF as vector commands rather than raster commands.

Goz
Hi Goz.CutePDF is a good start for me and I will try it asap. My real challenge is to generate vector graphic PDF page as opposed to bitmap. You know if a bitmap is printed in PDF the zoom pixelates it way too ugly. I will try CutePDF to see if it is possible to overcome zoom pixelation anyway.Have you tried the CutePDF SDK?Cheers.
val
Goz
Hi Goz, I just tried CutePDF as you suggested to replace a printer.It give's me some ammo but the pixalation is a problem as I susspected.Your hit to use HDC could a gold one - I feel it. Can you elaborate a bit on your HDC idea? Thanks
val