Custom Printing

I have a WinForms application that includes a sophisticated printing system. By implementing a simple interface, I can extend it so that I can print custom businesss objects seamlessly. My application uses GoDiagram and includes many complex drawings. Everything is working fine, thank you.

Now I need to integrate the drawings with various reports. Some of the report pages include content that comes from other parts of the application, with portions of the GoDiagram drawings included in various places of the report. In order to render those graphical elements, I have a customized GoDocument that selectively renders the diagram in different ways based on parameters I pass to it.

My questions are:

  1. If I create a custom GoView that is never shown, but is used only for rendering the diagram, is it possible to “print” the view without displaying any UI? This would be useful in the one scenario where the entire diagram must be printed as a series of pages, but integrated into the application’s printing system.

  2. For the other scenarios, where I need to render portions of the digram embedded into the report, is there anything better than MakeBitmap for getting a high-quality result? I’ve seen a few posts about SVG and metafiles, but they are very old and I’m not sure at this point what the best approach would be.

If you create a GoView, add objects to the GoDocument, and call view.Print… it will print without ever being displayed.

SVG would give you scalable graphics, but you’d have to be inserting the SVG you get out into something that understood how to display SVG. I don’t think I would recommend metafiles, I think their day has come and gone.

We print to printers with high quality… so if your “<span =“Apple-style-span” style=”: rgb248, 248, 252; “>sophisticated printing system” looks like a printer to the GoView, it seems like it should work.

The printing system works the other way. It calls my object repeatedly in order to build up each page. I intend to derive a custom class from GoView and implement their interface, essentially passing back selected portions of the diagram when requested. I therefore need to render the view into my own graphics object. Alternatively, I need to either capture the graphics output of the view while it is printing, or render the diagram to a bitmap and then copy it onto the print surface supplied by the other system.

I guess using GetBitmap is your best path then. Note that using the entry with 4 parameters gives you the most control…

GetBitmapFromCollection(IGoCollection coll, RectangleF bounds, float scale, bool paper)

I’m noticing that when printing from a view, all of the iconic nodes appear as black circles. Any idea what might be causing this? All of the other nodes (shapes, etc.) appear fine.

It should work. Check to see if you are getting any Trace errors.