[GIS] How to get the map data frame fill the page layout (ArcObjects java)

arcgis-10.2arcobjectsjava

I need to export a map for several extents (typically states or regions of a country) to PDF. I have a MXD document that I open in an ArcObject console program.

I manage to set the PageLayout to A2 form and change the orientation of the page depending on my extent.

Nevertheless, I would like to set the data frame to fill my PageLayout with a given margin (1cm for example) between the PageLayout and the data frame, and then change the map extent to my region extent. How can I do that please ?

My actual code is

                    IPageLayout pageLayout = (IPageLayout)activeView;
                IPage page = pageLayout.getPage();

                if(regionExtent.getHeight() > regionExtent.getWidth()) {
                    log.info("Orientation : Portrait");
                    page.setOrientation((short) 1);
                } else {
                    log.info("Orientation : Paysage");
                    page.setOrientation((short) 2);
                }
                log.info("Format : A2");
                page.setFormID(esriPageFormID.esriPageFormA2);
                page.setUnits(esriUnits.esriCentimeters);
                page.setStretchGraphicsWithPage(true);
                pageLayout.zoomToWhole();
                pageLayout.setAlignToMargins(true);

                IMap map = activeView.getFocusMap();
                // here I have to get the map fill the pageLayout

Best Answer

Filling the map layout with you data extent you could just zoom to the layer. If there is a certain feature within the layer that defines the extent than you could use a query filter to select that feature than zoom to the selected feature. A general web search should give you some leads on zooming to layers, setting query filters, or zooming to selected features.

Related Question