Print out resizing

Hi Jake,<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I am facing some issue regarding printing functionality.

My requirement is :

1. My view’s canvas should entirely fit my paper size. i.e. the right left top and bottom cut marks on paper should exactly match my document’s left top right and bottom. Currently my top left and top right are not matching and due to this the bottom margins are also getting extended beyond paper sizes.

2. Depending on default paper size of the printer(A4,A3,A2), my view should stretch or compress itself so that my 1st requirement is fulfilled.

To do this I have overridden GoView in this fashion:

class MyView:GoView

{

protected override System.Windows.Forms.DialogResult PrintShowDialog(System.Drawing.Printing.PrintDocument pd)

{

PrintDialog pPrnDlg = new PrintDialog();

pPrnDlg.AllowCurrentPage = false;

pPrnDlg.AllowPrintToFile = false;

pPrnDlg.AllowSelection = false;

pPrnDlg.AllowSomePages = true;

pPrnDlg.Document = pd;

pd.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.SomePages;

pd.PrinterSettings.FromPage = 1;

pd.PrinterSettings.ToPage = 1;

if (this.Document.Size.Width > this.Document.Size.Height)

{

pPrnDlg.Document.DefaultPageSettings.Landscape = true;

}

else

{

pPrnDlg.Document.DefaultPageSettings.Landscape = false;

}

SizeF docsize = this.PrintDocumentSize;

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

{

RectangleF pRect = this.Document.ComputeBounds();

float ratio = Math.Max(b.Width / pRect.Width, b.Height / pRect.Height);

this.PrintScale = ratio;

}

return pPrnDlg.ShowDialog();

}

public override System.Drawing.PointF PrintDocumentTopLeft

{

get

{

return new System.Drawing.PointF(this.Document.TopLeft.X, this.Document.TopLeft.Y);

}

}

public override System.Drawing.SizeF PrintDocumentSize

{

get

{

return this.Document.ComputeBounds().Size;

}

}

}

But I am unable to achieve the desired functionality, The current behaviour is :

1. Cut marks do not match the extreme edges of my view.

2. Diagram does not fits completely into the default paper size of the printer and the bottom margins extend the paper size and upper margins tend to slip from their desired position.

I am attaching snapshots, which should help.

Thanks

Vin

First, I don’t think your PrintDocumentTopLeft or PrintDocumentSize are helping… just comment those out.



and in PrintShowDialog:



float ratio = Math.Max(b.Width / pRect.Width, b.Height / pRect.Height);



what is b? not defined here.



GoDiagram is going to try to put the top/left most object on the top/left cutmark. Just try StateCharter or other samples that support printing.