Print w/o splitting nodes

is it posible to print an org chart and not have the nodes possibly get split in half when multiple pages are involved?

You’ll need to move them manually, either the user interactively or your application programmatically.
How can the user tell where the page boundaries will be? Look at the “I want to show my users where the page boundaries will be, in the GoView and not just in the PrintPreview dialog.” entry in the FAQ.
If you want to do this programmatically, you can start with the same page boundary calculations. You’ll need to iterate over all of the nodes in your document, find the ones that intersect these lines, and shift them over.
You might find it handy to artficially increase the width of the margins so that there is more room to print nodes along the margins, i.e. so that you don’t have to move the nodes.

OK, everyone, here you go. This assumes we can use the default page size and margins. It doesn't change any margins, but instead just shifts everything out farther so that all objects that would be split fall onto the next page. public void ShiftObjectsToAvoidPageSplits(GoView view) { PrintDocument pd = new PrintDocument(); PageSettings ps = pd.DefaultPageSettings; int paperw = ps.PaperSize.Width; int paperh = ps.PaperSize.Height; int pagew = paperw-ps.Margins.Left-ps.Margins.Right; int pageh = paperh-ps.Margins.Top-ps.Margins.Bottom; pd.Dispose(); float viewscale = view.PrintScale; SizeF pagesize = new SizeF(pagew/viewscale, pageh/viewscale); PointF origin = view.PrintDocumentTopLeft; SizeF extent = view.PrintDocumentSize; view.StartTransaction(); GoSelection sel = new GoSelection(null); for (float x = origin.X+pagesize.Width; x < origin.X+extent.Width; x += pagesize.Width) { float maxShift = 0; foreach (GoObject obj in view.Document) { if (obj is IGoLink) continue; // skip links, but include nodes and other objects if (obj.Width >= pagesize.Width) continue; // skip really wide objects if (obj.Left-1 <= x && x <= obj.Right+1) { // find split objects maxShift = Math.Max(maxShift, x-obj.Left+1); // distance to move out } } if (maxShift > 0) { sel.Clear(); foreach (GoObject obj in view.Document) { if (obj is IGoLink) continue; if (obj.Width >= pagesize.Width) continue; if (obj.Right > x) sel.Add(obj); // collect objects that need moving } view.MoveSelection(sel, new SizeF(maxShift+1, 0), false); extent = view.PrintDocumentSize; // recalculate print size } } for (float y = origin.Y+pagesize.Height; y < origin.Y+extent.Height; y += pagesize.Height) { float maxShift = 0; foreach (GoObject obj in view.Document) { if (obj is IGoLink) continue; // skip links, but include nodes and other objects if (obj.Height >= pagesize.Height) continue; // skip really tall objects if (obj.Top-1 <= y && y <= obj.Bottom+1) { // find split objects maxShift = Math.Max(maxShift, y-obj.Top+1); // distance to move out } } if (maxShift > 0) { sel.Clear(); foreach (GoObject obj in view.Document) { if (obj is IGoLink) continue; if (obj.Height >= pagesize.Height) continue; if (obj.Bottom > y) sel.Add(obj); // collect objects that need moving } view.MoveSelection(sel, new SizeF(0, maxShift+1), false); extent = view.PrintDocumentSize; // recalculate print size } } view.FinishTransaction("shifted objects to avoid page splits"); }

I apply this function, however it cause one more issue: The link will cross the node after shift the objects. Is there anyway, there is no crossing over node?

The links will re-route after the node moves. Do you have AvoidsNodes = true on your links?


Yes, it has.

Sorry, I’m not understanding your issue. Can you upload a screenshot?

(you have to use the "post reply" button at the botton right to do that)
Sorry, I still have problem.
I want user to be able to choose Paper size before print. So I have to overide PrintPreviewShowDialog or PrintShowDialog
Protected Overloads Overrides Sub PrintPreviewShowDialog(ByVal pd As PrintDocument) 'auto select the Paper Orientation Dim docsize As SizeF = Me.PrintDocumentSize If (docsize.Height > docsize.Width) Then pd.DefaultPageSettings.Landscape = False Else pd.DefaultPageSettings.Landscape = True End If If ShowPageSetupDialog(pd) = DialogResult.OK Then ' ShiftObjectsToAvoidPageSplits(Me) ???? MyBase.PrintPreviewShowDialog(pd) End If MyBase.PrintPreviewShowDialog(pd) End Sub
and I do not want node split over different pages. So I need ShiftObjectsToAvoidPageSplits
However, Where should I put shiftObjectsToAvoidPageSplits function?
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click myView.PrintScale = myView.DocScale 'ShiftObjectsToAvoidPageSplits(myView) --- here? myView.PrintPreview() End Sub
It seems to me if I add the override PrintPreviewShowDialog, The ShiftObjectToAvoidPageSplits does not work.
If I get rid of the override functions, ShiftObjectToAvoidPageSplits does work.
Please give me some advice on this issue.
Thanks!