Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Export a diagram to PDF and stream to the browser (Read 10265 times)
LGK
YaBB Newbies
*
Offline



Posts: 30
Location: Boston, MA
Joined: Mar 29th, 2012
Export a diagram to PDF and stream to the browser
Apr 2nd, 2012 at 5:47pm
Print Post  
Hi -

I'm playing with the PdfExporter.Export() method and trying to get a feel for how I could stream the exported PDF to the client's browser. The current method signature is:

Code
Select All
void Export(Diagram diagram, string filePath) 


I do not find it very flexible as it only provides a mechanism to store the exported PDF to a location on the web server. Hence, if I wanted to get this PDF back to the user's browser, I would have to:

  1. Store the PDF on the web server
  2. Then put in a buffer and stream that to the user
  3. Delete the PDF from the web server (I would not want to clutter the directory with unnecessary/temp files)

Are there any plans to add an overload to the export API? Something along the lines of:

Code
Select All
byte[] Export(Diagram diagram) 




Also - do you guys support SVG Image Response when ClientSideMode="ImageMap"? From your documentation:

Quote:
To choose the format of the diagram image generated by NetDiagram, set the ImageFormat property to the respective image MIME type (the default is image/jpeg).

So, when I set ImageFormat="image/svg+xml", nothing gets rendered telling me that SVG MIME type/image response is not supported - is that correct?

Many thanks!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export a diagram to PDF and stream to the browser
Reply #1 - Apr 3rd, 2012 at 6:12am
Print Post  
Hi,

There weren't any plans for that, but I'll add it to our wish list for next release.

There is no support for SVG output in ImageMap mode, and I think image maps don't work with SVG images anyway. Since the control already includes an SvgExporter, we can quickly implement some support for non-interactive SVG mode if it will work for you.

Stoyan
  
Back to top
 
IP Logged
 
LGK
YaBB Newbies
*
Offline



Posts: 30
Location: Boston, MA
Joined: Mar 29th, 2012
Re: Export a diagram to PDF and stream to the browser
Reply #2 - Apr 3rd, 2012 at 3:08pm
Print Post  
Stoyan - that would be absolutely fantastic! A non-interactive SVG mode sounds perfect. We basically are looking to utilize this in the iPad/mobile version of our web site. So, when a user zooms in (using finger swipe), an ImageMap (in a JPG/BMP/GIF format) starts to look blurred and loses it's quality, whereas an SVG rendering looks amazing even after a resize! 

How difficult/easy do you think that would be?

Thank you!


  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export a diagram to PDF and stream to the browser
Reply #3 - Apr 4th, 2012 at 6:15am
Print Post  
If you need to zoom into the diagram instead of the whole page, perhaps it will be easier to handle the browser's touch events and set DiagramView.ZoomFactor to get a quality image. However this will require a postback to repaint the bitmap if using ImageMap mode. A read-only SVG mode shouldn't be hard to implement, our developer will try to add it in the next few days.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export a diagram to PDF and stream to the browser
Reply #4 - Apr 5th, 2012 at 5:32pm
Print Post  
This version adds a read-only "SvgImage" client mode:
https://mindfusion.eu/_beta/netdiag_svg.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
LGK
YaBB Newbies
*
Offline



Posts: 30
Location: Boston, MA
Joined: Mar 29th, 2012
Re: Export a diagram to PDF and stream to the browser
Reply #5 - Apr 10th, 2012 at 7:10pm
Print Post  
This is impressive! Thank you, Stoyan (and special thanks to your developers for adding this feature!)

In this new (SvgImage) mode, I've noticed that the ZoomFactor is no longer taken into account - would there be any workaround to get Zoom In/Out to work again?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export a diagram to PDF and stream to the browser
Reply #6 - Apr 12th, 2012 at 1:38am
Print Post  
This build implements ZoomFactor in Svg mode:
https://mindfusion.eu/_beta/netdiag_svg.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
LGK
YaBB Newbies
*
Offline



Posts: 30
Location: Boston, MA
Joined: Mar 29th, 2012
Re: Export a diagram to PDF and stream to the browser
Reply #7 - Apr 19th, 2012 at 8:44pm
Print Post  
Thank you! I tested it, and it works pretty good. There are a couple of issues that may need to be addressed at some point - please see the attached screenshot:

  • When I zoom in or out too much, the text crosses or gets out of the node's limits
  • I cannot use the scroll bars within the Diagram area to scroll and view the diagram when it is zoomed in

What are your recommendations?

We are impressed by your product, your support, commitment and quick feedback! We have already initiated an email to your sales department and are interested in purchasing NetDiagram.

One question that I have for you would be: How would we get the SVG enhancements/features you built for me? In other words, once we purchase the product would those be packaged separately for us or would we have to wait for an official release?

  

ClientSideMode_SvgImage.jpg (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export a diagram to PDF and stream to the browser
Reply #8 - Apr 20th, 2012 at 6:49am
Print Post  
Quote:
When I zoom in or out too much, the text crosses or gets out of the node's limits


I can't get this to happen in my IE9, what browser are you using? The same scale is applied to both graphics and text, so if the text starts to stick out of the node, that should be a problem of the browser's SVG renderer. It might be drawing texts using the nearest integer font size, so perhaps it would look better if you set zoom factors that keep the scaled font size an integer.

Quote:
I cannot use the scroll bars within the Diagram area to scroll and view the diagram when it is zoomed in


Scrollbars work fine for me. If you are testing this on an iPad, note that overflowed DIVs never display scrollabars in iOS Safari by design (to save screen space I think). Instead of scrollbars, you must use a two-finger swipe to scroll the DIV content. Also make sure your diagram.Bounds is large enough to fit the diagram content - the scroll range is set to the bounds size multiplied by zoom factor.

Quote:
In other words, once we purchase the product would those be packaged separately for us or would we have to wait for an official release?


You can request a pre-release build with the SVG feature at our support email address. There aren't any major changes being done at this time, so it should be pretty stable.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
LGK
YaBB Newbies
*
Offline



Posts: 30
Location: Boston, MA
Joined: Mar 29th, 2012
Re: Export a diagram to PDF and stream to the browser
Reply #9 - Apr 20th, 2012 at 3:11pm
Print Post  
Hi Stoyan, and thanks for the quick response!


Quote:
When I zoom in or out too much, the text crosses or gets out of the node's limits

I'm getting this behavior in both Chrome and IE9 with ZoomFactor = 170 (please see the first two screenshots respectively below).


Quote:
I cannot use the scroll bars within the Diagram area to scroll and view the diagram when it is zoomed in

This is actually working fine in IE9, but not in Chrome (as you can see in the first screenshot below).


Another problem that I'm getting is the JavaScript exception (in the third screenshot) on every page load.


Many thanks!!
  

Chrome_-_ClientSideMode_SvgImage.jpg (Attachment deleted)
IE9_-_ClientSideMode_SvgImage.jpg (Attachment deleted)
JavaScript_Error__all_browsers_.jpg (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export a diagram to PDF and stream to the browser
Reply #10 - Apr 24th, 2012 at 10:00am
Print Post  
Quote:
Another problem that I'm getting is the JavaScript exception (in the third screenshot) on every page load.


This will happen if the page contains some other NetDiagram control in Canvas mode (e.g. a ShapeListBox) and the MS Ajax script file is not loaded. Since you can't use any control other than DiagramView in SVG mode, it will be better to remove it anyway.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export a diagram to PDF and stream to the browser
Reply #11 - Apr 24th, 2012 at 7:09pm
Print Post  
This build should fix the scroll range problem in Chrome:
https://mindfusion.eu/_beta/netdiag_svg.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
LGK
YaBB Newbies
*
Offline



Posts: 30
Location: Boston, MA
Joined: Mar 29th, 2012
Re: Export a diagram to PDF and stream to the browser
Reply #12 - Apr 27th, 2012 at 3:24pm
Print Post  
Hi Stoyan -

In the latest build you made available, you have not only fixed the scrolling issue that I found in Chrome, but you have also corrected the zooming behavior - absolutely great work! The control is not working wonderful in "SvgImage" mode and the rendering looks fantastic!

Many thanks for your prompt responses and hard work!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint