Two Pilots™    Home  |  Navigation  |  Site Map  |  Products  |  Download  |  Prices  |  For Partners  |  Support

All forums · Statistics · Search ·

Two Pilots forum / For software developers / Metafile scaling
Author Message
# Posted: 10 Dec 2004 19:46

When I convert an emf with our image2pdf tool, the result is perfect. ie, the image fills the 8 1/2x 11 page... But when playing the metafile with PDFPAGE_PlayMetafileFromFilename function, the resulting image is way too big and doesn't fit in the PDF page. I can I calculate the scaling ratio needed?


# Posted: 16 Dec 2004 14:49

Can anyone help me out? If I can play my metafles properly, then this is the tool I'm going to buy. Please let me know.


# Posted: 16 Dec 2004 15:16

Joe, sorry fot the delay with the answer. We would suggest the following:

//This variable will be used later to render EMF file
double xyScale = 0;
//Before start new document you need to set up document resolution
//using resolution of the first of your EMF files
piPDFdocument->Resolution = YOUR_FILE_RESOLUTION;
//Begin PDF document (don't forget to setup document name)
//Now set document page dimensions using EMF file size (in pixels)
piPDFdocument->PDFPAGE_Height = SomeValueY;//(height of your EMF
//file - suppose, 800 pixels)

//And also width - also in pixels
piPDFdocument->PDFPAGE_Width = SomeValueX;

// Now you need to get document used DC resolution
HDC hDocumentDC;
piPDFdocument->get_HDC((unsigned long *)&hDocumentDC);
// API call - GDI
int iResolution = GetDeviceCaps(hDocumentDC,LOGPIXELSX);
long lDocumentPageResolution = (long)iResolution;

// Now you need to calculate scale ratio to render EMF properly
xyScale = (double)((double)lDocumentPageResolution/(double)YOUR_FILE_RESOLUTION) ;

// Now play your EMF ! API call also
HENHMETAFILE hEmf = GetEnhMetaFile(m_CurentJob.szSourceFileName);
RECT rc = {0,0,(LONG)(SomeValueX*iResolution/YOUR_FILE_RESOLUTION),
// API call
// API call

//That's all !

In case you are using other language than C++, you can use usual
WinAPI wrappers that are used in your language.



Powered by miniBB 2.0 RC7 © 2001-2004 Page creation time (sec.): 0.012


Page top