Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Print (Read 5192 times)
educosta
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Nov 5th, 2009
Print
Nov 16th, 2009 at 10:54am
Print Post  
It is possible print the diagram?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print
Reply #1 - Nov 16th, 2009 at 11:22am
Print Post  
It's not - Silverlight does not support printing yet.

As a workaround you could call SaveToPng, send the file bytes to the server, and open the png in a new browser window for the user to print.

Another option is to use the PdfExporter library from our WinForms / ASP.NET controls; however since you are overriding the ShapeNode templates, you will have to implement some custom drawing server code to match the nodes appearance.

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


I love YaBB 1G - SP1!

Posts: 14
Joined: Nov 5th, 2009
Re: Print
Reply #2 - Nov 16th, 2009 at 11:28am
Print Post  
I tried use SaveToPng but i get the follwing error:


There is not enough free space to perform the operation.


What is?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print
Reply #3 - Nov 16th, 2009 at 12:00pm
Print Post  
It seems there is some quota on the Silverlight local storage size, so this won't work for large diagrams unless the users increase the allowed space. Try to call Diagram.CreateImage() and send the image bytes directly to the server instead of using an intermediary file.

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


I love YaBB 1G - SP1!

Posts: 6
Joined: Jul 20th, 2010
Re: Print
Reply #4 - Dec 6th, 2010 at 4:02pm
Print Post  
Stoyo wrote on Nov 16th, 2009 at 11:22am:
As a workaround you could call SaveToPng, send the file bytes to the server, and open the png in a new browser window for the user to print.
I hope that helps,
Stoyan


Hi Stoyan,
That was exactly my approach to enable user to save the png file with the browser. Nevertheless I am getting: "WriteableBitmap has protected content. Pixel access is not allowed." even if I want to write to a MemoryStream and then send it using HTTP Request.

Here is the code that gives error:
byte[] buffer = new byte[2000000];
MemoryStream stream = new MemoryStream(buffer, true);
diagram.SaveToPng(stream);
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print
Reply #5 - Dec 6th, 2010 at 8:34pm
Print Post  
The last few Diagramlite releases for Silverlight 4 now provide a Print method.

You might also check this sample:
https://mindfusion.eu/_samples/DiagliteJpeg.zip

It shows how to export a diagram file to the local file system and also how to use .NET ImageTools to encode to different image formats.

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


I love YaBB 1G - SP1!

Posts: 6
Joined: Jul 20th, 2010
Re: Print
Reply #6 - Dec 8th, 2010 at 4:19pm
Print Post  
First of all... thanks for quick response. It gave me a new energy to work;) Here is what I've found out.

Unfortunately The solution works when we have a standalone SL application. It do not work when it is embedded into a webapplication. It is related to cross-domain references (and the WriteableBitmap do not take fully trusted assemblies into consideration). I can use the Bitmap just for display (e.g. in SL Popup). The SaveToPng method also gives the same error.

The printing feature would be good enough, but unfortunately it stops with "Printing page 2 of 12 ..." message in the diagram box.

Any other ideas?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print
Reply #7 - Dec 8th, 2010 at 6:50pm
Print Post  
Unfortunately Silverlight 4 printing just sends to the printer a large bitmap for each page instead of text and graphic primitives. So it is very slow, but it should not be hanging, unless the printer or the printer driver does not work very well with bitmaps. The just announced Silverlight 5 will support vector-graphics printing from what I hear, so the situation should be better then.

I couldn't reproduce a cross-domain references problem. Is your application's .xap file hosted on the same domain as the page that loads it?
  
Back to top
 
IP Logged
 
wladek
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Jul 20th, 2010
Re: Print
Reply #8 - Dec 9th, 2010 at 8:59am
Print Post  
I have the SL app and a web service ins separate projects (one solution). The main aspx page hosts the application like:
Code
Select All
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
  <param name="source" value="ClientBin/TheWallSL.xap"/>
  <param name="onError" value="onSilverlightError" />
  <param name="background" value="white" />
  <param name="minRuntimeVersion" value="3.0.40624.0" />
  <param name="autoUpgrade" value="true" />
  <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
   <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
  </a>
    </object> 

So it shares the domain. I tried with the absolute url... still the same error. I will try to embed your demo into mine... I hope it is only a matter of configuration.
  
Back to top
 
IP Logged
 
wladek
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Jul 20th, 2010
Re: Print
Reply #9 - Dec 9th, 2010 at 10:48am
Print Post  
Stoyan....
I've found the "bug"! It is quite sneaky but so obvious that I almost feel ashamed it popped into my head so late... In some of my nodes I am using thumbnails that are stored in on the different server.

Sorry for wasting your time, but maybe this topic will help some desperate developers in the future;P
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint