Exporting map to a pdf or Iimage

7133
8
09-27-2013 07:46 AM
HelenAraya1
New Contributor
I want some means of exporting map to a pdf.  Is there some built in functions in com.esri.map  which can help me to create an image from a Jmap which I can then export it to pdf ? Other option could be to export the layers directly to pdf instead of to Jmap ?

I have tried itext(java pdf creation software) to take a picture of the component (Jmap and put it in pdf) but that is not of good quality. Ant it required me to open the Jmap in JFrame before paiting it to pdf which I don't want to do. I am really stuck here.


Let me know if any one have done this before.

Thanks
Helen Araya
0 Kudos
8 Replies
JeremieJoalland1
Occasional Contributor II
In the "ArcGIS Runtime SDK for Java Samples" (v10.1.1), you can have a look at the following sample :
- Mapping > Printing > Printing (Online)

Maybe it will bring you clear answers...
0 Kudos
HelenAraya1
New Contributor
Hi Jeremie. Thanks for taking time to respond to my question.

But the example in the samples simply prints the map and it requires the window to be visible to be printed
(appWindow.setVisible(true).

But , what I want is to implicitly export the map to pdf with out opening it.
If any body else have done this let me know

Thanks
Helen Araya
0 Kudos
JerrySmith
New Contributor
Once you�??ve finished a map design, you can export your map for use in other applications. You can export the entire world or choose a smaller region by setting the bounding box. You are able to export the map to various image and document formats, such as PDF, PNG, SVG, etc. In addition to exporting your maps to PDF, you can also manipulate existing PDF documents or create new PDF documents.
0 Kudos
CarlosColón-Maldonado
Occasional Contributor III
I want some means of exporting map to a pdf. I have tried itext(java pdf creation software) to take a picture of the component (Jmap and put it in pdf) but that is not of good quality. And, it required me to open the Jmap in JFrame before paiting it to pdf which I don't want to do.


This gives the impression that your intent is to export what is being reflected on the JMap unto a PDF file. Otherwise, why expect a Java-based com.esri.map component to do this work? If you don't intend to export what is being displayed, then you must mean to want to export a JMap-consumable base map layer. I don't know how else you could get non-base map layers, i.e., graphics layers, to provide a visual output without them being displayed first.

Jerry made a good point and recommendation to pre-create the PDFs from Arc Map while in design, but you still will have to consume/display them in Arc Map, and this will still be a manual process. It sounds like you want to do this programmatically.  Perhaps, you might want to clarify exactly what you want to accomplish.
0 Kudos
HelenAraya1
New Contributor
Once you�??ve finished a map design, you can export your map for use in other applications. You can export the entire world or choose a smaller region by setting the bounding box. You are able to export the map to various image and document formats, such as PDF, PNG, SVG, etc. In addition to exporting your maps to PDF, you can also manipulate existing PDF documents or create new PDF documents.



Hi Jerry,
Thanks for your response. I am looking to programatically export the map using ARC GIS SDK for  java or any third  party libraries for pdf creation like itext. What you posted does not seem to do what I am intending to do. I am expecting some java code which takes JMap and exports it to pdf or which allows me to create a map with its custom layers and graphics in pdf using java
0 Kudos
HelenAraya1
New Contributor
This gives the impression that your intent is to export what is being reflected on the JMap unto a PDF file. Otherwise, why expect a Java-based com.esri.map component to do this work? If you don't intend to export what is being displayed, then you must mean to want to export a JMap-consumable base map layer. I don't know how else you could get non-base map layers, i.e., graphics layers, to provide a visual output without them being displayed first.

Jerry made a good point and recommendation to pre-create the PDFs from Arc Map while in design, but you still will have to consume/display them in Arc Map, and this will still be a manual process. It sounds like you want to do this programmatically.  Perhaps, you might want to clarify exactly what you want to accomplish.



Hi Carlos.

1. I am expecting some java code which takes JMap(Created using arcgis SDK for java) and exports it to pdf OR
2. A code which allows me to create a map with its custom layers and graphics in pdf using ArcGIS Runtime SDK for Java.
0 Kudos
HelenAraya1
New Contributor
Hi guys here is how I was able to create image from

createMap()
{
   theFrame = new JFrame();
....more code here

map = new JMap(reference,initialExtent);
       theFrame.getContentPane().add(map);     
       ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer(worldStreetMap);           
       map.getLayers().add(tiledLayer);
       map.setExtent(initialExtent);       


  theFrame.setVisible(true) ;

    Thread.sleep(30000); //Sleep untill all the layers are added

createImage(map);

//Close the frame after image taken place( to avoid manual closing)
WindowEvent windowClosing = new WindowEvent(theFrame, WindowEvent.WINDOW_CLOSING);
         theFrame.dispatchEvent(windowClosing);

}

public static BufferedImage createImage(Component panel)
    {
        int w = panel.getWidth();
        int h = panel.getHeight();
        BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = bi.createGraphics();
        panel.paintAll(g);
   
           File file = new File(filePath);
           ImageIO.write(bi, "png", file);  // ignore returned boolean
    }
0 Kudos
RavindraSingh
Occasional Contributor

Same functionality i also want.

But I want it in Georefrenced, GeoTIFF image format.

What is being displayed in JMap, I want that.

0 Kudos