且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从MFC MDI CView生成PDF页面

更新时间:2022-06-23 20:29:52

如果下载 CutePDF ,则可以直接打印为PDF.就像普通的基于打印机的打印一样.我很确定,如果您从Adobe公司获得acrobat pro,您也可以做同样的事情.

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.

使用设备上下文,您可以通过驱动程序可以使用"存储矢量图形的方式来绘制所有图形.

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

如果处理WM_PRINT命令(在消息映射中为ON_MESSAGE),则将为您提供HDC.您可以通过执行以下操作从HDC中检索MFC样式的CDC:

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 );

现在,您可以按以下方式向打印机发出标准的DC绘图命令:

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 );

这将从左上角到右下角绘制一个.如果按比例缩放所有矢量图形,则它们有望(尽管我不确定,但是我不确定)将以矢量命令而不是光栅命令的形式出现在PDF上.

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.