Generate Diagram as PDF document


I want to know if it is possible to output the diagram as PDF document.

If not, what is the best alternative in order to generate the diagram to a PDF document?

Thank you,

Just want to clarify that we are trying to achieve this for a Silverlight project.

Thank you,

GoXam for Silverlight doesn’t support generating PDF files directly.

However, you could render an image of a diagram and then use other tools for producing the PDF file.

To produce an image, call Diagram.Panel.MakeBitmap, using the overload that takes an Action. In that action you might be able to use code such as or to actually generate the PDF file.

Caveat: I haven’t tried this, so I cannot vouch for its effectiveness.

Hi walter,

Thank you for the prompt reply.

The printing to PDF works but I have another question. When a user select parts from the diagram, how do I get the Diagram bounds in order to generate the bitmap image with only the part of diagram that contains all the parts? (Just like how it is with PrintManager when we set the Parts)

Thank you,

Figure out the bounding rectangle for those selected parts:

Rect b = myDiagram.Panel.ComputeBounds(myDiagram.SelectedParts);

Then you should choose a scale such that the resulting bitmap is a reasonable size,
given the values of b.Width and b.Height.

Hi Walter,

When I use PrintManager to print parts, only the parts & links selected were printed. If I use ComputeBounds, even the link / parts not selected will be generated on the image if they are in the computed rectangle. Is there anyway that we can generate the image without the parts that are not selected?

Thank you for the prompt reply.

You’ll need to temporarily make all those Parts that you don’t care about not Visible.

Is it possible to make the Bitmap image of the DiagramPanel with GridLines?

Thank you.

Perhaps not. Are you just displaying the background grid pattern?

If that doesn’t work for you, you can implement a work-around to hide the background grid pattern and create a similar GridPattern object in the Background layer that is big enough to cover the area to be rendered.

Hi walter,

I am wondering, if I use Diagram.Panel.MakeBitmapSize,Double,Point,Double,Action)<span style=‘font:ormal “Times New Roman”; color: rgb0, 0, 0; text-trans: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; border-collapse: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;’ =“Apple-style-span”><span style=“font-family: arial; font-size: 18px; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;” =“Apple-style-span”><span =“Apple-converted-space”> to split a diagram into multiple parts, is there anyway I can know the order of the image rendered in the action?

Thank you,


You could have the Action be a closure that captures the viewport position (which is a Point that is passed as the viewpos argument of MakeBitmap).