locked
Problem with PrintPreviewControl when used with transform scaling RRS feed

  • Question

  • In my .NET 2.0 application I use the same code to print and to print preview as I use for rendering to the screen. This works fine for both screen rendering and printing but when a scaling transform is applied in the low-level rendering code the print preview renders incorrectly. Screen rendering and printing to an actual printer works correctly even when the scaling transform is being used.

    Is this a known problem with the print preview control? Would moving to .NET 3.5 fix this?

    Tuesday, March 17, 2009 8:17 PM

Answers

  • Sounds like another case of using VisibleClipBounds.  Don't.  For precise printing, set OriginAtMargins to True and layout the print from the  left, top margin.  Use display units (0.01") and make your own calculations for conversions.  The print will be exact.  The PrintPreview will be off by the hard margins, but the entire document will be seen and the slight shift is normally not objectionable.
    • Marked as answer by Kira Qian Tuesday, March 24, 2009 6:03 AM
    Wednesday, March 18, 2009 7:09 AM

All replies

  • Post code to reproduce the problem.
    Tuesday, March 17, 2009 9:03 PM
  • Hmya, what the heck does "incorrectly" mean?  Too pink?
    Hans Passant.
    Wednesday, March 18, 2009 12:42 AM
  • This app is rather large so I can't just post the code. I'll try and put together a test case and post that. By "incorrectly" I mean that the areas that are rendered with the scaled transform just don't appear. Other portions of the preview rendering that do not involve a scale transform do render correctly. My guess is that the scale transform is not being applied or applied incorrectly, so it gets rendered outside the clip region. I've stepped through the code with a debugger and the transform is identical in both the screen rendering and print preview rendering cases. Also, this happens both with my own print preview code and when using the WinForms PrintPreviewDialog.


    Wednesday, March 18, 2009 2:23 AM
  • Sounds like another case of using VisibleClipBounds.  Don't.  For precise printing, set OriginAtMargins to True and layout the print from the  left, top margin.  Use display units (0.01") and make your own calculations for conversions.  The print will be exact.  The PrintPreview will be off by the hard margins, but the entire document will be seen and the slight shift is normally not objectionable.
    • Marked as answer by Kira Qian Tuesday, March 24, 2009 6:03 AM
    Wednesday, March 18, 2009 7:09 AM