Roy Soltoff
2009-10-26 19:36:10 UTC
Using VB.Net and Framework 3.5:
With a PrintDocument the PrintPreview dialog, drawing a metafile to the
document prints as it should using the MarginBounds obtained from the
PrintPageEventArgs, but the preview is never correct. One would think that:
ev.Graphics.EnumerateMetafile(metafile1, ev.MarginBounds,
metafileDelegate)
should produce the same results as:
Dim points() As Point = {New Point(ev.MarginBounds.Location), New
Point(ev.MarginBounds.Right, ev.MarginBounds.Top), New
Point(ev.MarginBounds.Left, ev.MarginBounds.Bottom)}
ev.Graphics.EnumerateMetafile(metafile1, points, metafileDelegate)
but it does not. And although both correctly print to the printer, the
preview is terribly different in both cases. Using the overload of the dest
rectangle, the drawing is always to Point(0,0) and is not scaled correctly,
and using the overload of the parallelogram defined by points (which define
the same rectangle), the file is drawn supersized. Its as if the scaling of
the metafile to the preview device is not correctly handled by the preview
component but the scaling to the printer is correct. And the
graphics.EnumerateMetafile API does not correctly interpret its overloads. I
have not been able to determine what scaling factor I can apply to the
metafile when I create it so that I can use the 100% scale for printing, but
some other scale for previewing (I can determine if the document is being
previewed or printied by the document.PrintController.IsPreview property).
Is this a bug in the framework's PrintPreview or PrintDocument components?
Or is the EnumerateMetafile the culprit?
With a PrintDocument the PrintPreview dialog, drawing a metafile to the
document prints as it should using the MarginBounds obtained from the
PrintPageEventArgs, but the preview is never correct. One would think that:
ev.Graphics.EnumerateMetafile(metafile1, ev.MarginBounds,
metafileDelegate)
should produce the same results as:
Dim points() As Point = {New Point(ev.MarginBounds.Location), New
Point(ev.MarginBounds.Right, ev.MarginBounds.Top), New
Point(ev.MarginBounds.Left, ev.MarginBounds.Bottom)}
ev.Graphics.EnumerateMetafile(metafile1, points, metafileDelegate)
but it does not. And although both correctly print to the printer, the
preview is terribly different in both cases. Using the overload of the dest
rectangle, the drawing is always to Point(0,0) and is not scaled correctly,
and using the overload of the parallelogram defined by points (which define
the same rectangle), the file is drawn supersized. Its as if the scaling of
the metafile to the preview device is not correctly handled by the preview
component but the scaling to the printer is correct. And the
graphics.EnumerateMetafile API does not correctly interpret its overloads. I
have not been able to determine what scaling factor I can apply to the
metafile when I create it so that I can use the 100% scale for printing, but
some other scale for previewing (I can determine if the document is being
previewed or printied by the document.PrintController.IsPreview property).
Is this a bug in the framework's PrintPreview or PrintDocument components?
Or is the EnumerateMetafile the culprit?