private string ExportToPDF(string p_destDir, string p_destName, bool p_append, IGTPlotWindow p_outputWindow, out string p_msg) { string retVal = string.Empty; p_msg = ""; try { string destPathName = Path.Combine(p_destDir, p_destName); IGTPDFPrinterProperties pdfProps = GTClassFactory.Create <IGTPDFPrinterProperties>(); pdfProps.EmbedFont = true; if (p_outputWindow.NamedPlot != null) { pdfProps.PageHeight = p_outputWindow.NamedPlot.PaperHeight; pdfProps.PageWidth = p_outputWindow.NamedPlot.PaperWidth; } pdfProps.Orientation = PageOrientationType.Portrait; pdfProps.PageSize = PageSizeValue.Auto; pdfProps.Resolution = ResolutionValue.DPI600; // Perform export IGTExportService svcExport = GTClassFactory.Create <IGTExportService>(); svcExport.PDFLayersEnabled = false; svcExport.SaveAsPDF(destPathName, pdfProps, p_outputWindow, p_append); svcExport = null; // Close output window p_outputWindow.Close(); retVal = destPathName; } catch (Exception ex) { p_msg = ex.Message; } return(retVal); }
internal void BuildWorkPrint(List <PlotBoundaryAttributes> p_PlotBoundaryCollection, IGTApplication p_oApp, string p_destDir, string p_outputFileName, string p_legendName) { try { List <string> PDFNames = new List <string>(); for (int i = 0; i < p_PlotBoundaryCollection.Count; i++) { string sErrMsg = string.Empty; IGTNamedPlot oNamedPlot = null; IGTKeyObject oClipGeom = p_oApp.DataContext.OpenFeature(p_PlotBoundaryCollection[i].FNO, p_PlotBoundaryCollection[i].FID); IGTComponent oComp = oClipGeom.Components.GetComponent(18802); oComp.Recordset.MoveFirst(); IGTPolygonGeometry oGeom = (IGTPolygonGeometry)oComp.Geometry; foreach (IGTNamedPlot item in p_oApp.NamedPlots) { if (item.Name.Equals(p_PlotBoundaryCollection[i].PlotTemplateName)) { oNamedPlot = item; break; } } DeleteNamedPlot("OUTPUT - " + p_oApp.DataContext.ActiveJob + "-" + i, p_oApp); IGTNamedPlot oCopiedPlot = oNamedPlot.CopyPlot("OUTPUT - " + p_oApp.DataContext.ActiveJob + "-" + i); IGTPlotWindow oPlotWindow = p_oApp.NewPlotWindow(oCopiedPlot); IGTPlotFrame oFrame = null; foreach (IGTPlotFrame tmpFrame in oPlotWindow.NamedPlot.Frames) { // IGTPlotFrame oFrame = oPlotWindow.NamedPlot.Frames[0]; if (tmpFrame.Type == GTPlotFrameTypeConstants.gtpftMap) { oFrame = tmpFrame; break; } } oFrame.Activate(); oFrame.PlotMap.DisplayService.ReplaceLegend(p_legendName); AssignClipGeometryToFrame(p_oApp, oFrame, oGeom); oPlotWindow.Activate(); SetAutomaticFields(oPlotWindow.NamedPlot, p_PlotBoundaryCollection.Count, i + 1, p_oApp); p_oApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, string.Format("Generating Construction Print {0} of {1}", i + 1, p_PlotBoundaryCollection)); ExportToPDF(p_destDir, p_outputFileName + "-" + i + ".pdf", false, oPlotWindow, out sErrMsg); PDFNames.Add(p_outputFileName + "-" + i + ".pdf"); oPlotWindow.Close(); DeleteNamedPlot("OUTPUT - " + p_oApp.DataContext.ActiveJob + "-" + i + 1, p_oApp); } if (PDFNames.Count > 0) { MergePDFs(p_destDir, PDFNames, p_outputFileName); } } catch (Exception) { throw; } }