Select to view content in your preferred language

Printing [fit to one page]

3521
6
Jump to solution
02-06-2014 09:42 AM
IbrahimHussein
Deactivated User
Hey,  I followed this http://resources.arcgis.com/en/help/runtime-java/concepts/index.html#/Printing/01qv00000084000000/ to set up a print button on my application. The only problem I am having is making the map fit on one page. any idea how do achieve this?
0 Kudos
1 Solution

Accepted Solutions
IbrahimHussein
Deactivated User
Whats the screen resolution you are working on?

Just for a quick test try DPI 150, then 200 and 300 and see what happens !!!


Hey sorry for the late reply, resolution is 1080P. Not sure if this is the right method of what Im trying to achieve.  See here, that's basically what happens to the map when I change the dpi. whereas im looking for the map to be filled to a single page. If you have the SDK for WPF, im basically looking to do something similar there on how it prints.


edit: ok got it, this is what I did. I saved the map as an image, and from there was able to print nicely. I used u/helengeb method to export an image,  seen here,for saving the image

Thanks for the help sachin.

View solution in original post

0 Kudos
6 Replies
SachinKanaujia
Deactivated User
Hey,  I followed this http://resources.arcgis.com/en/help/runtime-java/concepts/index.html#/Printing/01qv00000084000000/ to set up a print button on my application. The only problem I am having is making the map fit on one page. any idea how do achieve this?


I am not very clear on what the exact problem is. Have you set up the Paper size and Orientation? How are you setting that?
0 Kudos
IbrahimHussein
Deactivated User
I am not very clear on what the exact problem is. Have you set up the Paper size and Orientation? How are you setting that?


Hello, Yeah PaperSize (8.5 by 11) and Orientation is set up using the print dialog. To rephrase my problem, if you look at the image http://i.imgur.com/A3Bggv2.jpg; the map prints using 3 pages, is there anyway to have make it fit on one page? [ATTACH=CONFIG]0[/ATTACH]

             Paper paper = new Paper();

             // ...set up the paper options...
             PrinterJob printJob1 = PrinterJob.getPrinterJob();
             PageFormat pageFormat = new PageFormat();
               if (printJob1.printDialog()) {
                     try {printJob1.print();}
                     catch (PrinterException exc) {
                         System.out.println(exc);
                      }
                  } 
              
             //set up page format [DEFAULT] options and pass the paper settings through
             pageFormat.setPaper(paper);
             pageFormat.setOrientation(Integer.valueOf(PageFormat.LANDSCAPE));

             // set page format for the map to print
             map.setPageFormat(pageFormat);
           
             printJob1.setPageable(map);

            
             try {
                // send job to printer!
                printJob1.print();
             } catch (PrinterException e) {
                // handle the exception
             }
0 Kudos
SachinKanaujia
Deactivated User
You can use the DPI option while printing to adjust printing according to the paper size

     int DPI = 96; // change DPI accordingly
     Paper paper = new Paper();
     MediaSize size = sizeMap.get(sizeList.getSelectedItem());
     double width = (size.getX(Size2DSyntax.INCH))*DPI;
     double height = (size.getY(Size2DSyntax.INCH))*DPI;
     paper.setSize(width, height);
     paper.setImageableArea(MARGIN, MARGIN, width - (2*MARGIN), height - (2*MARGIN));


I hope this helps
0 Kudos
IbrahimHussein
Deactivated User
You can use the DPI option while printing to adjust printing according to the paper size

     int DPI = 96; // change DPI accordingly
     Paper paper = new Paper();
     MediaSize size = sizeMap.get(sizeList.getSelectedItem());
     double width = (size.getX(Size2DSyntax.INCH))*DPI;
     double height = (size.getY(Size2DSyntax.INCH))*DPI;
     paper.setSize(width, height);
     paper.setImageableArea(MARGIN, MARGIN, width - (2*MARGIN), height - (2*MARGIN));


I hope this helps


Thanks, still haven't got it, but definitely stirs me in the right direction.
0 Kudos
SachinKanaujia
Deactivated User
Whats the screen resolution you are working on?

Just for a quick test try DPI 150, then 200 and 300 and see what happens !!!
0 Kudos
IbrahimHussein
Deactivated User
Whats the screen resolution you are working on?

Just for a quick test try DPI 150, then 200 and 300 and see what happens !!!


Hey sorry for the late reply, resolution is 1080P. Not sure if this is the right method of what Im trying to achieve.  See here, that's basically what happens to the map when I change the dpi. whereas im looking for the map to be filled to a single page. If you have the SDK for WPF, im basically looking to do something similar there on how it prints.


edit: ok got it, this is what I did. I saved the map as an image, and from there was able to print nicely. I used u/helengeb method to export an image,  seen here,for saving the image

Thanks for the help sachin.
0 Kudos