DynaPDF Manual - Page 550

Previous Page 549   Index   Next Page 551

Function Reference
Page 550 of 839
The header files pshpack2.h and poppack.h are available in Visual Studio and Embarcadeo's C++
Builder; they are used to declare a packed structure. Fill the structure TPORT_METAHEADER now
with values:
TPORT_METAHEADER wmf;
fread(&wmf, 1, sizeof(wmf), f);
if (wmf.Key != 0x9AC6CDD7) // Is this a portable WMF file?
{
fclose(f);
return -2;
}
Now we can calculate the size of the metafile picture:
METAFILEPICT pict;
if (!wmf.Inch) wmf.Inch = 96;
pict.hMF
= NULL;
pict.mm
= MM_ANISOTROPIC;
pict.xExt = (wmf.BBox.Right - wmf.BBox.Left) * 2540 / wmf.Inch;
pict.yExt = (wmf.BBox.Bottom - wmf.BBox.Top) * 2400 / wmf.Inch;
As you can see above, the y-axis is not calculated with 2540 pixels per inch. DynaPDF uses 2400
pixels instead. I don't know why it must be 2400 pixels in most cases, but the y-axis is often
stretched otherwise. This value can be adjusted in the range 2000 to 3000 with the property
WMFPixelPerInch. This property changes the value of the y-axis only; the value of the x-axis is
always 2540.
Notice: The adjustment above is maybe not required. The value 2400 pixels per inch was determined
via trial and error.
ROP Codes (Raster Operation Codes)
EMF files are mostly created for a raster device like a monitor or printer. Because of this, metafiles
use often ROP codes which combine fore- and background colors to achieve transparency or other
color effects. Such ROP codes are meaningful on a raster device but not on a vector device like PDF.
Because no raster image is created during conversion, it is not possible to use ROP codes which
combine fore- and background colors.
The function checks for unsupported ROP codes during conversion. If unsupported ROP codes will
be used then the EMF file will be rendered to an image by default. The problem with ROP codes is
that the result depends mainly on the background. Many unsupported ROP codes have no effect if
the background is empty. In most cases it is better to disable the rasterizer with the flag
mfDisableRasterEMF and to enable it only if the output is wrong. See SetMetaConvFlags() for
further information.
 

Previous topic: Portable WMF files

Next topic: How to convert spool EMF files?, Compatibility Note: