This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I'm using the code below to print, but I would very much like it to fit a paper source for instance A4, instead of multiple pages. I know I can change the zoom to decrease the size but the resolution is horrible when doing that.
Regards, Michael |
|
|
Hello Michael Setting the Zoom to shrink the diagram should produce the best result due to WPF using vector geometries. The only thing I can suggest is if your nodes have a lot of detail, you could create a more printer friendly node style to apply while printing. And maybe thicken the connections if they come out too thin. -Jason Fauchelle |
|
|
Hi' Jason What is the best way to get the zoom factor that fits the paper size? I have tried another approach to printing by using an FlowDocument and a rendered PNG, to get the best result I was forced to setting the zoom factor to 2 before printing and setting it back afterwards. The print output is very good, but the zooming is not :-( is there a way to do a DiagramBitmapRenderer with a zoom option/quality, whiteout the visual zooming? Regards, Michael |
|
|
Hello Michael You can get the bounds of the diagram via the DiagramSurface.DiagramBounds property. With this you can make the calculations to get the zoom factor that fits the paper. In the next nightly build, DiagramBitmapRenderer will have a Zoom property which you can set to specify the zoom level you want for the exported image. -Jason Fauchelle |
|
|
Thanks :-) |
|
|
Don't mean to hijack a thread, but this relates directly to my current situation. I'm on the Feb 23, 2015 nightly and do not see the Zoom property on the DiagramBitmapRenderer that was mentioned as being added back in this 2014 thread. Regardless of that, here is what I'm facing: How do I control the DiagramSurface.DiagramBounds in terms of producing a screenshot. When I load a large diagram (in a collapsed state) the DiagramBounds is reasonable for the size of a screenshot. If I expand the entire thing then collapse it back down before I do a screenshot, the DiagramBounds is still huge, from the expanded state it was previously in, and thus taking a screenshot gives the expected out of memory error because the Bounds are enormous. Do I just need to set my zoom as you explain above? (once I can get the property back, might be in the latest nightly, just haven't looked yet) EDIT: Latest nightly does not have a public Zoom property on the DiagramBitmapRenderer |
|
|
EDIT: Found the Zoom property. I was looking on the DiagramBitRenderer object, instead of the PNG object, where it is. I still don't know what to do about DiagramSurface.DiagramBounds size after I've expanded my diagram then collapsed is back down. the screenshot resolution is too large, making the visible image small but the resolution too large. |
|
|
Hi Chris, I will be looking into this issue this week or early next week. There is most likely an issue with the DiagramBounds calculation not shrinking again when the nodes are collapsed. The Zoom property won't help unfortunately. I'll get back to you when I've resolved this. -Jason Fauchelle |
|
|
Great thank you Jason. |
|
|
Hi Chris, I've been able to look into this now. We do shrink the DiagramBounds when the bounds of the nodes change, so what's most likely happening is the position of your expanded nodes remain when they are collapsed again. Since the diagram model doesn't currently know about expand/collapsed state, it will still use the node positions to calculate the overall diagram bounds. I would suggest either running a layout algorithm on the diagram when the nodes are collapsed, or at least manually repositioning the collapsed nodes before creating the screen shot. You'll want to position the collapsed nodes somewhere within the bounds of the visible nodes, so that they don't interfere with the diagram bounds. I hope that helps, please let me know if you have questions about this. -Jason Fauchelle |
|
|
Running a layout algorithm doesn't seem to change anything for me. I am using the Tree Layout Algorithm. I have tried different zoom setting on the PNG object, but it doesn't seem to zoom the screenshot at all. When I set Zoom = 2.0 I get a black background. Strange. Take a look at the attached screen shots. Here is the code I use to generate the PNG (just two lines):
|
|
|
Hi Chris, Before rendering the image, try iterating all the nodes, and for each node that is invisible, set it's position to 0,0 and see if that improves the output image. A further improvement to this could be to create a custom layout algorithm that puts invisible nodes within the bounds of the visible nodes area. -Jason Fauchelle |
|