How can I draw a PDF file to a DC?

This is a read only forum. It contains the most frequently asked questions about Amyuni products and licensing.
Post Reply
Dany
Amyuni Team
Posts: 113
Joined: Wed Sep 11 2002
Location: Montreal.
Contact:

How can I draw a PDF file to a DC?

Post by Dany »

You can call: PDF.DrawCurrentPage( hDC, PrepareDC )
the current page will be displayed on the specified DC.

The PrepareDC is a Boolean value that indicates whether it is up to the PDF Creator control to prepare the device context for viewing the page or if the calling application is preparing DC. The calling application can do things like modifying the drawing origin, zoom factor, clipping area, ... in this case PrepareDC should be set to False.

To have the Creator prepare the DC and do the drawing, simply call:
PDF.DrawCurrentPage( hDC, TRUE )

To prepare the DC before calling drawing the page, you need to call something similar to:

int saveDC;
int oldMap;
SIZE oldWindow, oldView;

saveDC = SaveDC( hDC );

// set scale and origin
oldMap = SetMapMode( hDC, MM_ISOTROPIC );

// set scaling factor and drawing origin
SetWindowExtEx( hDC, 2000, 2000, &oldWindow );
SetViewportExtEx( hDC, m_zoomFactor, m_zoomFactor, &oldView );

// now draw the page
pdf.DrawCurrentPage( (long)hDC, FALSE );

// reset previous scaling and origin
SetViewportExtEx( dc, oldView.cx, oldView.cy, NULL );
SetWindowExtEx( dc, oldWindow.cx, oldWindow.cy, NULL );

SetMapMode( dc, oldMap );
RestoreDC( dc, saveDC );
Post Reply