Printing Questions


I have a printing issue that I need help to resolve and a printing question. First, the question:

  1. What implications/limitations do I impose on myself (as programmer) and what must my program’s users endure by my setting GoView.ShowsNegativeCoordinates to false? I understand that users cannot specify negative coordinates, but what does that mean?

Now, for my printing issue…

  1. Currently, my program has a palette containing objects that users may drag out onto the canvas. One of those objects is a text box sub-classed from GoText. The text box displays a rectangle around the text with a margin (i.e., whitespace) between the text and the rectangle. I override GoText’s Paint and ExpandPaintBounds methods to draw an 4 pixel margin around the text before drawing the rectangle.

When a text box is printed using the goview.print method, the text’s margins are not equal on all sides (i.e., not 4 pixels). Specifically, it appears that the right and bottom margins increase substantially. For example, an 8 point font string “Text Box” will print with a 16-20 pixel margin both at the end of the text string and below the text string
(even though I’ve specified an 4 pixel margin all the way around the text). At larger point sizes, the right and bottom margins become quite large, causing the print to span pages, due to so much white space at the end of and below the text. Any idea what might be causing this issue? Below, I’m including the code for my overridden Paint and ExpandPaintBounds methods:

Public Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal view As Northwoods.Go.GoView)

    If Not (Me.HasBorder) Then
        MyBase.Paint(g, view)
    End If

    If (PaintGreek(g, view)) Then
    End If

    Dim r As RectangleF = Me.Bounds
    Dim borderpen As Pen = New Pen(Me.TextColor)
    Dim backgroundBrush As New SolidBrush(Me.BackgroundColor)
    GoShape.DrawRectangle(g, view, borderpen, backgroundBrush, r.X - 4, r.Y - 4, r.Width + 8, r.Height + 8)
    MyBase.Paint(g, view)

End Sub

Public Overrides Function ExpandPaintBounds(ByVal rect As System.Drawing.RectangleF, ByVal view As Northwoods.Go.GoView) As System.Drawing.RectangleF

    If Not (Me.HasBorder) Then
        Return MyBase.ExpandPaintBounds(rect, view)
    End If

    Dim r As RectangleF = MyBase.ExpandPaintBounds(rect, view)

    r.X -= 4
    r.Width += 8
    r.Y -= 4
    r.Height += 8

    Return r

End Function

Thanks a lot for your help.

R. Houston

  1. Basically it means that they can’t scroll the view to show negative coordinates. It means that the values of GoView.DocumentTopLeft and PrintDocumentTopLeft are (0, 0), assuming GoView.SheetStyle is None.

  2. I am unable to reproduce the problem. I used instances (with different FontSize values) of the following class:

[Serializable] public class PText : GoText { public PText() { this.Text = "Text Box"; } public override void Paint(Graphics g, GoView view) { if (PaintGreek(g, view)) return; RectangleF r = this.Bounds; Pen borderpen = new Pen(this.TextColor); GoShape.DrawRectangle(g, view, borderpen, null, r.X-4, r.Y-4, r.Width+8, r.Height+8); borderpen.Dispose(); base.Paint(g, view); } public override RectangleF ExpandPaintBounds(RectangleF rect, GoView view) { rect.Inflate(4, 4); return base.ExpandPaintBounds(rect, view); } }

Hi Walter,

I modified my paint and expandpaintbounds methods to look like yours but it made no difference to the print or print preview - The text boxes look OK on-screen, but when I go to print or use print preview (using Go’s convenience methods) I get the larger margin along the right and bottom of the text. What else could cause a problem like this?

I just ran the Northwood example, Demo1, and saw similar behavior to what I’m experiencing with my app. Here are the steps to recreate in Demo1:
a. Launch Demo1
b. Close GraphDoc 1 window (I clicked the X button)
c. Click File->New ( a new graphdoc window appears)
d. Expand Special folder (upper left tree view window)
e. Drag a ‘Comment’ onto the graphdoc window
f. Click File->PrintPreview
g. Magnify to 100% (or greater) and scroll to view comment image -
In my environment the margin (whitespace) between the text and the box surrounding the text is much greater at the end of the
text and below the text than to the left or above the text. Very

My default printer is an HP 2100. I changed my default printer to be a Xerox Phaser 6300 Postscript printer and reran Demo1. I got the same results. My app produced the same results too. Does GoView.printpreview use the default printer to render or does it use it’s own (generic) printer driver?

So far, the only things I see in common between Demo1 and my app are the version of GoDiagrams (V2.6.2), both apps’ use of GoView.PrintPreview and GoView.Print, and my environment. Are there any other similarities between the apps that you can think of?

You said you couldn’t recreate the problem at your end. You are using 2.6.2 and printpreview and print to test, right? Could the problem lie elsewhere in my environment (besides default printers)? Other thoughts or suggestions? I’d really like to get this issue resolved.

Thanks a lot.

R. Houston

On a different machine with different printers, I’m still not able to
reproduce the problem. I did exactly the steps that you list with
Demo1 (2.6.2 for .NET 2.0). Here’s what I get in print preview:

Hi Walter,

Here is what I get…

  1. Notice the size of the right and bottom margins. They are bigger
    than the top and left margins. As the font size increases, the margins become larger still.

  2. If you can’t reproduce the effect then the error is probably in my
    environment, but I don’t know where. Hmmm.

Any ideas?

R. Houston

Hi Walter,

Good news. I found the problem…

I told my system (a dell laptop) to use a 120dpi setting (vice the
normal 96 dpi). By doing this, I redefined how big one inch is in

My laptop’s screen resolution is 1900 by 1200 but 96 dpi make
text too small. So, I upped the dpi setting to 120. You can do the same
by going to Start->Control Panel, launch Display, and click the
button. In the top panel (on the General tab), there is a
choice of 96 or 120 dpi.

Unfortunately, changing the dpi setting from 96 to 120 causes go’s
printpreview and print to render incorrectly. I would presume both are
trying to use 96dpi in all cases? Would there be a way to compensate for
the dpi setting in print and printpreview?

I also looked at increasing the font size on the Display Properties window (Appearance Tab, bottom combo box). GO didn’t seem to have a problem with using larger fonts (prints seem to render correctly) but I didn’t like the effect. For some reason choosing larger fonts just didn’t look as nice to me.

For what its worth…

Thanks again for your time.

R. Houston