Printing to a single page

Hi
Our application creates diagrams which span several pages.
The users want be able to print the diagram scaled to fit onto 1 page which may be A4, A3 or bigger, ie they have a large plotter.
Is this possible? If so a guide as to how to do it…

The follow code is in the FAQ:

// print to fit

SizeF docsize = myView.PrintDocumentSize;

if (docsize.Width > 1 || docsize.Height > 1) {

PrintDocument pd = new PrintDocument();

Rectangle b = pd.DefaultPageSettings.Bounds;

Margins m = pd.DefaultPageSettings.Margins;

float w = b.Width - (m.Left + m.Right);

float h = b.Height - (m.Top + m.Bottom);

float ratio = Math.Min(w/docsize.Width, h/docsize.Height);

if (ratio > 1)

ratio = 1;

myView.PrintScale = ratio;

}

myView.Print();

Hi,
I have a similar requirement to print the document on a single page.
I used the above code from the FAQ and included it in the override for PrintPreviewShowDialog, so that the print preview is also displayed on a single page. But when I print from the Print button on this dialog the grid lines are not printed properly ie there are few grid lines, then there is some empty space, then again a few grid lines, then some space and this goes on.
You can reproduce this in Demo1, by
1)Set the view grid style to Line and Set the grid cell size to around (30,30)
2)Override PrintPreviewShowDialog : GraphView, to include the code from the FAQ before passing the call to base (use the print document object passed as parameter to the method to determine page settings and margins)
3)Insert -> lotsa stuff
4)Select all and drag the selections such that scroll bars appear
5)Insert -> Lotsa stuff
6)Print Preview
7)Print
You will observe that the grids in the background are not printed continuously
Can you please let me know if you are able to reproduce this and what could be possible solution to this problem.
Thanks,
Rafique

What version are you using?
With version 2.3, everything printed fine for me. Of course the grid lines disappeared behind objects, but I assume that’s not what you are complaining about. I just ran the installed Demo1.exe, so I had to set the GoView.PrintScale using the Properties grid to a small enough value so that everything printed on one page.
With version 2.4, the grid lines were not printed at all. You need to set GoView.PrintsViewObjects to true and GoView.BackgroundGrid.Printable to true. I think the latter setting (defaulting to false) is unnecessarily incompatible and therefore incorrect. That default value is well intentioned given the introduction of GoGrid objects, but I think we’ll change the default value for the GoView.Background.Printable to be true in the future.
Anyway, after setting those two properties to true, everything printed just fine.
Maybe if you are running v2.3 or earlier and if the computed PrintScale is too small you are seeing some rendering effects that cause lines to be so thin they seem to disappear. If this is the case, you could override GoView.PaintBackgroundDecoration to first set:
g.SmoothingMode = SmoothingMode.AntiAlias;
base.PaintBackgroundDecoration(g, clipRect);
This shouldn’t be necessary in v2.4 or later, since grids are implemented by GoGrid, which just inherits from GoRectangle/GoShape/GoObject, so all the standard GoObject painting conventions apply.

I m using version 2.3.1.
Actually, the grid lines are printed, but not continuously. A couple of grid lines are printed, then there is some space, again a couple of grid lines are printed and so on.
The print scale in Demo1, when I get this problem, is around 0.35. Did you try the Grid Cell Size as (30,30). I think in Demo1, the default grid size is a little larger.
Also make sure that printing the document normally would take around 3 to 4 pages.
Let me know if you need any other detail.
Thanks,
Rafique

Did you try the override of PaintBackgroundDecoration?

Yes

OK, we’ll investigate this.

I suspect it’s a problem with the printer.
Out of three different printers that I have tried, I only had a problem with one of them (a relatively cheap inkjet printer).
You never saw any problems in the Print Preview window, right?
Another possibility is to change the GoView.GridColor to be darker, or the GridPenWidth wider, to see if that makes the undrawn lines more visible.

Setting the GridPenWidth to 2.0f seems to have solved the problem. But I havent tested this enough yet. So I will get back to you if I run into any issues.
Thanks,
Rafique