Discussion:
Drawing a Metafile to a PrintDocument using PrintPreview
(too old to reply)
Roy Soltoff
2009-10-26 19:36:10 UTC
Permalink
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?
Rong-Chun Zhang [MSFT]
2009-10-27 11:04:47 UTC
Permalink
Hello Roy,

The managed support service of the newsgroup
microsoft.public.dotnet.framework.windowsforms.controls is now available
instead on Windows Forms General forum:
http://social.msdn.microsoft.com/Forums/en/winforms/threads. Would you
please repost the question in the forum with the Windows Live ID used to
access your Subscription benefits? Our engineers will assist you in the new
platform. The article
http://msdn.microsoft.com/en-us/subscriptions/aa974230.aspx introduces more
information about the migration. In the future, please post your
Winform-related questions directly to the forums. If you have any questions
or concerns, please feel free to contact us: ***@microsoft.com.

Regards,
Rongchun Zhang
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
***@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

MSDN Managed Newsgroup and Forum support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Loading...