Printpreview issue

I have added many GoObjects on GoView of my application.
On Goview, all objects are placed at different positions.
But when i use printpreview method to see the print preview window, then view's object which is first from top of the view but not at the top of view itself, print preview window shows that object on its top.
View's image:
Print preview's window:
So the requirement is that there should be same distance from top of view as welll as on printpreview window.
Please reply me as soon as possible.

You can override GoView.PrintDocumentTopLeft and GoView.PrintDocumentSize if you want to change this. By default, GoView uses GoView.ComputeDocumentBounds to get the bounding box for visible objects and then prints those.

I tried to override like:
public override PointF PrintDocumentTopLeft
get { return base.PrintDocumentTopLeft; } set { base.PrintDocumentTopLeft = value; } }
But there is following compilation error:
Error 1 'VLDGraph.GUI.GUI_View.PrintDocumentTopLeft.set': cannot override because 'Northwoods.Go.GoView.PrintDocumentTopLeft' does not have an overridable set accessor.
How can i override GoView.PrintDocumentTopLeft and GoView.PrintDocumentSize because both properties are read only.
Please help me as soon as possible.

so, remove the “set”. all you need is the “get”.


Thanks a lot for your valuable support.
The problem has been resolved.
But there is a symbol appears at each corner on every printed page, that i don't require. I marked it in paint & then attached the image.Please have a look:
Please let me know how this symbol be removed from printed page?

Override GoView.PrintDecoration and make it a no-op.

I already overrided GoView.PrintDecoration in my code.
But what do you mean by to make it a no-op?
Please let me know that how can i do that?

Don’t call base.PrintDecoration then.

Sorry, I come from a time when no-op was a machine instruction that did nothing on the VAX. (short for "no operation")


Still there is a problem. Very first time when data is displayed on y axis view & x axis view, If i don't trigger any drag event on y axis view & call directly print preview, then preview shows correct data for y axis view, but doesn't shows x axis view's data as per original data on x axis view & it appears as:
But if i trigger any drag event on y axis view, then call print preview, then preview perfectly appear as per original data on both views & it appears same as on both views as:
Please have a look of the following code. I implemented this code in x axis view class, whose data changes on each sheet on print preview window & places y axis data on each sheet.
protected override void PrintDecoration(Graphics g, PrintPageEventArgs e, int hpnum, int hpmax, int vpnum, int vpmax)
this.PrintScale = 1.0F; GlobalResourceManager gRM = GlobalResourceManager.instance(); String msg = gRM.GetStringFromResource("MF_DAYTYPE") + this.FPLCreateGraph.FrmFpl.SelectedDayType + "\n" + gRM.GetStringFromResource("MF_ROUTES") + this.FPLCreateGraph.FrmFpl.SelectedRouteList + "\n" + gRM.GetStringFromResource("MF_BLOCKS") + this.FPLCreateGraph.FrmFpl.SelectedBlockList; Font font = new Font("Verdana", 10); SizeF size = g.MeasureString(msg, font); PointF pt = new PointF(e.MarginBounds.X,e.MarginBounds.Y + e.MarginBounds.Height); g.DrawString(msg, font, Brushes.Blue, pt); msg = (hpnum + 1).ToString() + "/" + hpmax.ToString(); size = g.MeasureString(msg, font); pt = new PointF(e.MarginBounds.X + e.MarginBounds.Width / 2 - size.Width / 2, e.MarginBounds.Y + e.MarginBounds.Height); g.DrawString(msg, font, Brushes.Blue, pt); msg = System.Windows.Forms.SystemInformation.UserName + "\n" + System.DateTime.Today.ToShortDateString(); size = g.MeasureString(msg, font); pt = new PointF(e.MarginBounds.X + e.MarginBounds.Width - size.Width, e.MarginBounds.Y + e.MarginBounds.Height); g.DrawString(msg, font, Brushes.Blue, pt); GraphicsContainer before = g.BeginContainer(); // save Graphics state GoView yAxisView = this.FPLCreateGraph.YAxisView; // get the GoView to be same while printed on each page RectangleF pYAxisBounds = new RectangleF(yAxisView.DocumentTopLeft, yAxisView.DocExtentSize); // draw into left margin, but not into top-left corner of page // NB: the palette's Width needs to fit into the margin, otherwise it will overlap with the main view g.TranslateTransform(Math.Max(0, e.MarginBounds.X - pYAxisBounds.Width), e.MarginBounds.Y); g.ScaleTransform(this.PrintScale, this.PrintScale); // draw at same scale as the rest of the view g.TranslateTransform(pYAxisBounds.X, pYAxisBounds.Y); // normalize palette's PrintDocumentTopLeft foreach (GoLayer oLayer in yAxisView.Layers) // draw each palette's document's layer { if (oLayer.Identifier.ToString() == "YAxisLabelLayer") { oLayer.Paint(g, yAxisView, pYAxisBounds); Pen objPen = new Pen(Color.Black, 1.0F); g.DrawLine(objPen, new PointF(pYAxisBounds.Width, pYAxisBounds.Top), new PointF(pYAxisBounds.Width, pYAxisBounds.Top + pYAxisBounds.Height)); break; } } g.EndContainer(before); // restore Graphics state, so that this view will print normally //base.PrintDecoration(g, e, hpnum, hpmax, vpnum, vpmax); }

I don’t know. If you remove all the code from your override of PrintDecoration, does the issue with the shifting go away?


Yes, When i removed all the code from overriden of PrintDecoration, the issue with the shifting went away.
Please provide me some hint to resolve the issue as soon as possible.

I’m suspicious of the transforms you do on the Graphics object, but the Begin/EndContainer look ok. I really don’t know.

I am also notified a scenario.
When first time x axis view & y axis view is loaded & then i go for print preview option, then print preview window doesn't show x axis view objects on its original position.
But if i do scroll x axis view a little horizontally by x axis view's horizontal scrollbar & then again go for print preview option, then problem is resolved in print preview window.
I also analysed taht when data is first time loaded on x axis view, then x axis view's horizontal scroll bar's width is little bit more than that of when i scrolled x axis view's horizontal scroll bar manually.
Is there any GoView's function, which do the same automatically?
So i can try by calling that function when first time data is loaded on X axis view.
Please let me know as soon as possible.

I’m not sure I’m reading this right. You want to scroll the view a bit to avoid the problem in your PrintDecoration code?


Please provide me a piece of code which automatically scroll the view a little bit.
Please provide me some piece of code or hint why first time print preview window doesn't work properly.
When i close print preview window first time, then x axis view's horizontal scroll bar's width increases a very little bit than that of it was before opening print preview window & as soon as i scroll it a little bit, than it sets to the same as it was before & then if i again open print peview window, then everythings looks perfect.

You can set GoView.DocPosition to scroll the view.