Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Page format and margins (Read 9744 times)
princji
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 8th, 2009
Page format and margins
Sep 11th, 2009 at 3:45pm
Print Post  
Hi,

Is it possible to set the page size and orientation via Javascript for NetDiagram?

Currently, it prints on Letter paper and the margins are also too wide, leaving a lot of wasted empty room. Can that be changed too?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Page format and margins
Reply #1 - Sep 13th, 2009 at 11:07am
Print Post  
Hi,

The applet's DiagramView class has a print(PageFormat, String) method that can be used to specify the orientation and printable area size. If you know Java, you might extend the DiagramApplet class and add a method that calls print() with the setting you need. Otherwise, since Internet Explorer does not support instantiating Java classes from JavaScript, we'll have to add a ScripHelper.createPageFormat method to let you create a PageFormat object from script.

Stoyan
  
Back to top
 
IP Logged
 
princji
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 8th, 2009
Re: Page format and margins
Reply #2 - Sep 14th, 2009 at 5:09pm
Print Post  
A CreateScriptHelper would be a useful feature to change the paper format, orientation and margins. Too much white space is wasted otherwise.

And it's impossible to print to anything but the printer's default page format (i.e. letter) ?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Page format and margins
Reply #3 - Sep 15th, 2009 at 8:58am
Print Post  
This version of the applet adds createPaper and createPageFormat methods to ScriptHelper:

https://mindfusion.eu/_beta/netdiag_pageformat.zip

The PageFormat.setPaper(Paper) method lets you change the paper size. You can see the PageFormat and Paper Java docs here:

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/print/PageFormat.html
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/print/Paper.html

However I remember there were some security restrictions when you try to print to the non-default printer from an applet. Those might apply to changing some of the default printer setting too.

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


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 8th, 2009
Re: Page format and margins
Reply #4 - Sep 15th, 2009 at 2:00pm
Print Post  
Thank you for being so accommodating.

Would these options also apply to print preview?

Would you also be able to provide me with a Javascript sample on how to set the options to Print and Print Preview?

Thank you!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Page format and margins
Reply #5 - Sep 16th, 2009 at 6:59am
Print Post  
There is an internal PageFormat field in the print preview class too, we'll add a public setter for it.
  
Back to top
 
IP Logged
 
princji
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 8th, 2009
Re: Page format and margins
Reply #6 - Sep 16th, 2009 at 12:53pm
Print Post  
Thanks, how do I apply this PageFormat object to the Print and PrintPreview?

E.g.
    var scriptHelper = sbApplet.getScriptHelper();
    var paper = scriptHelper.createPaper()
    var pageformat = scriptHelper.createPageFormat()
   
    paper.setSize(612, 1008);   //8.5*14 in 1/72nds of inches
    paper.setImageableArea(0,0,612,1008);
    pageformat.setPaper(paper);
    pageformat.setOrientation(pageformat.LANDSCAPE);

-- I'm stuck here  Smiley

Thanks.
  
Back to top
 
IP Logged
 
princji
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 8th, 2009
Re: Page format and margins
Reply #7 - Sep 18th, 2009 at 1:02pm
Print Post  
Hi again,
I would need your help on how to apply this PageFormat object to the Print and PrintPreview?

Thank you.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Page format and margins
Reply #8 - Sep 18th, 2009 at 4:23pm
Print Post  
var diagramView = sbApplet.getDiagramView();
diagramView.print(pageformat, null);

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


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 8th, 2009
Re: Page format and margins
Reply #9 - Sep 18th, 2009 at 7:01pm
Print Post  
Yes, thank you!  Cheesy

When you make changes on the fly, are they actually going to make it to the release versions?

It would also be nice if printPreview could be called with a PageFormat as well.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Page format and margins
Reply #10 - Sep 19th, 2009 at 10:48am
Print Post  
Yes, this will be available in the release version too, along with a printPreview(PageFormat) method.

Stoyan
  
Back to top
 
IP Logged
 
princji
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 8th, 2009
Re: Page format and margins
Reply #11 - Oct 6th, 2009 at 7:12pm
Print Post  
Hello,

I have been playing with the above code/objects and I'm hitting a wall: It seems I can change the size of the paper, but the contents is always sized for Letter paper.

I want to print on Legal paper, Landscape view.

Here's the code that I'm using (which doesn't work)... Please help!  Smiley

    var diagram = fcApplet.getDiagramView().getDiagram();
    var scriptHelper = sbApplet.getScriptHelper();
    var paper = scriptHelper.createPaper();
    var pageformat = scriptHelper.createPageFormat();

    paper.setSize(612.0, 1008.0);   //8.5*14 in 1/72nds of inches
    paper.setImageableArea(0.0, 0.0, 612.0, 1008.0);
    pageformat.setPaper(paper);
    pageformat.setOrientation(pageformat.LANDSCAPE);

    var po = fcApplet.getDiagramView().getPrintOptions();
    po.setEnableFitToPage(true);
    po.setDocumentName('');
    po.setHeaderFormat(''); 

    fcApplet.getDiagramView().print(pageformat, null);
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Page format and margins
Reply #12 - Oct 8th, 2009 at 8:12am
Print Post  
Hi,

That code should work better with this version:
https://mindfusion.eu/_beta/applet_print.zip

Let us know if there are still any problems.

Stoyan
  
Back to top
 
IP Logged
 
princji
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 8th, 2009
Re: Page format and margins
Reply #13 - Oct 8th, 2009 at 1:41pm
Print Post  
Thank you, this is working much better!

Your responsiveness is great.
  
Back to top
 
IP Logged
 
jgreen
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Aug 12th, 2010
Re: Page format and margins
Reply #14 - Aug 12th, 2010 at 8:19pm
Print Post  
Stoyo wrote on Sep 19th, 2009 at 10:48am:
Yes, this will be available in the release version too, along with a printPreview(PageFormat) method.

Stoyan


Just wondering when the pageformat for printpreview will be available?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint