Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void SetAOI(IMxDocument mxd, double latitude, double longitude)
- {
- UTM = SetUTMProjection(longitude);
- IPoint centerpoint = new PointClass();
- centerpoint.SpatialReference = NAD83;
- centerpoint.PutCoords(longitude, latitude);
- IEnvelope targetActiveViewEnv;
- targetActiveViewEnv = (mxd.FocusMap as IActiveView).Extent;
- targetActiveViewEnv.Project(NAD83);
- targetActiveViewEnv.CenterAt(centerpoint);
- (mxd.FocusMap as IActiveView).Extent = targetActiveViewEnv;
- mxd.FocusMap.SpatialReference = UTM;
- }
- public static void ExportMapPage(IMxDocument mxd, MapPage mapPage, string outputPath)
- {
- IActiveView activeView = mxd.PageLayout as IActiveView;
- activeView.FocusMap.MapScale = mapPage.Scale; //6000
- mxd.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, activeView.Extent);
- string output = String.Format("{0}\{1}{2}", outputPath, "test", GetFileExtension(mapPage.FileFormat)); //PDF
- IExport exporter;
- switch (mapPage.FileFormat) {
- case FileFormatEnum.JPG:
- exporter = new ExportJPEGClass();
- break;
- default:
- exporter = new ExportPDFClass();
- break;
- }
- exporter.ExportFileName = output;
- exporter.Resolution = mapPage.DPI; //300
- IEnvelope pixelBox = new EnvelopeClass();
- double ratio = mapPage.Ratio;
- pixelBox.XMin = activeView.ExportFrame.left * ratio;
- pixelBox.XMax = activeView.ExportFrame.right * ratio;
- pixelBox.YMin = activeView.ExportFrame.top * ratio;
- pixelBox.YMax = activeView.ExportFrame.bottom * ratio;
- tagRECT exporterRectangle;
- exporterRectangle.left = activeView.ExportFrame.left * (int)ratio;
- exporterRectangle.right = activeView.ExportFrame.right * (int)ratio;
- exporterRectangle.top = activeView.ExportFrame.top * (int)ratio;
- exporterRectangle.bottom = activeView.ExportFrame.bottom * (int)ratio;
- exporter.PixelBounds = pixelBox;
- int hdc = exporter.StartExporting();
- activeView.Output(hdc, (int)exporter.Resolution, ref exporterRectangle, null, null);
- exporter.FinishExporting();
- exporter.Cleanup();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement