Пример #1
0
        public async void btnExportLayout(object sender, EventArgs e)
        {
            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MY NEW LAYOUT"));

            if (layoutItem != null)
            {
                await QueuedTask.Run(() =>
                {
                    Layout layout = layoutItem.GetLayout();
                    if (layout == null)
                    {
                        return;
                    }

                    PDFFormat PDF = new PDFFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\Users\fimpe\OneDrive\MGIS\GEOG 8990 Spring 2018\Layout.pdf"
                    };
                    if (PDF.ValidateOutputFilePath())
                    {
                        layout.Export(PDF);
                        MessageBox.Show("The layout was exported to a pdf.", "Well done!", MessageBoxButton.OK);
                    }
                });
            }
        }
Пример #2
0
        public static Task ExportMapFrameToPDFAsync(string LayoutName, string MFName, string Path)
        {
            //Reference a layoutitem in a project by name
            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName));

            if (layoutItem == null)
            {
                return(Task.FromResult <Layout>(null));
            }

            //Create PDF format with appropriate settings
            PDFFormat PDF = new PDFFormat();

            PDF.Resolution     = 300;
            PDF.OutputFileName = Path;

            return(QueuedTask.Run(() =>
            {
                //Export MapFrame
                Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem
                MapFrame mf = lyt.FindElement(MFName) as MapFrame;
                PDF.OutputFileName = Path;
                if (PDF.ValidateOutputFilePath())
                {
                    mf.Export(PDF);
                }
            }));
        }
        /// <summary>
        /// Exports report
        /// </summary>
        /// <returns></returns>
        private async Task ExportReport()
        {
            ReportProjectItem reportProjItem = Project.Current.GetItems <ReportProjectItem>().FirstOrDefault(item => item.Name.Equals(ReportName));
            Report            report         = null;
            await QueuedTask.Run(() => report = reportProjItem?.GetReport());

            if (report == null)
            {
                MessageBox.Show($"{ReportName} report not found.");
                return;
            }

            //Define Export Options
            var exportOptions = new ReportExportOptions
            {
                ExportPageOption              = ExportPageOptions.ExportAllPages,
                TotalPageNumberOverride       = 12,
                StartingPageNumberLabelOffset = 0
            };
            //Create PDF format with appropriate settings
            PDFFormat pdfFormat = new PDFFormat();

            pdfFormat.Resolution     = 300;
            pdfFormat.OutputFileName = Path.Combine(Project.Current.HomeFolderPath, report.Name);
            await ExportAReportToPdf(report, pdfFormat, exportOptions, IsUseSelection);

            MessageBox.Show($"{ReportName} report exported to {pdfFormat.OutputFileName}");
        }
Пример #4
0
        async public static void ExportLayoutToPDF()
        {
            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout Name"));
            Layout            layout     = await QueuedTask.Run(() => layoutItem.GetLayout());

            String filePath = null;

            #region Layout_ExportPDF
            //Export a layout to PDF

            //Create a PDF export format
            PDFFormat pdf = new PDFFormat()
            {
                OutputFileName           = filePath,
                Resolution               = 300,
                DoCompressVectorGraphics = true,
                DoEmbedFonts             = true,
                HasGeoRefInfo            = true,
                ImageCompression         = ImageCompression.Adaptive,
                ImageQuality             = ImageQuality.Best,
                LayersAndAttributes      = LayersAndAttributes.LayersAndAttributes
            };

            //Check to see if the path is valid and export
            if (pdf.ValidateOutputFilePath())
            {
                layout.Export(pdf); //Export the PDF
            }
            #endregion Layout_ExportPDF
        }
 private async Task ExportAReportToPdf(Report report, PDFFormat pdfFormat, ReportExportOptions reportExportOptions, bool isUseSelectionSet = true)
 {
     await QueuedTask.Run(() =>
     {
         report?.ExportToPDF(ReportName, pdfFormat, reportExportOptions, isUseSelectionSet);
     });
 }
Пример #6
0
        async public static void ExportSnippets()
        {
            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout Name"));

            Layout lyt = await QueuedTask.Run(() => layoutItem.GetLayout());

            MapFrame mf = lyt.FindElement("Map1 Map Frame") as MapFrame;

            #region BMP_Constructor
            BMPFormat BMP = new BMPFormat();
            #endregion BMP_Constructor

            #region EMF_Constructor
            EMFFormat EMF = new EMFFormat();
            #endregion EMF_Constructor

            #region EPS_Constructor
            EPSFormat EPS = new EPSFormat();
            #endregion EPS_Constructor

            #region GIF_Constructor
            GIFFormat GIF = new GIFFormat();
            #endregion GIF_Constructor

            #region JPEG_Constructor
            JPEGFormat JPEG = new JPEGFormat();
            #endregion JPEG_Constructor

            #region PNG_Constructor
            PNGFormat PNG = new PNGFormat();
            #endregion PNG_Constructor

            #region PDF_Constructor
            PDFFormat PDF = new PDFFormat();
            #endregion PDF_Constructor

            #region SVG_Constructor
            SVGFormat SVG = new SVGFormat();
            #endregion SVG_Constructor

            #region TGA_Constructor
            TGAFormat TGA = new TGAFormat();
            #endregion TGA_Constructor

            #region TIFF_Constructor
            TIFFFormat TIFF = new TIFFFormat();
            #endregion TIFF_Constructor


            PDF.OutputFileName = @"C:\Temp\output.pdf";

            #region PDF_lyt_Export
            lyt.Export(PDF);
            #endregion PDF_lyt_Export
        }
Пример #7
0
        protected async override void OnClick()
        {
            try
            {
                //Export a single page layout to PDF.

                //Create a PDF format with appropriate settings
                //BMP, EMF, EPS, GIF, JPEG, PNG, SVG, TGA, and TFF formats are also available for export
                PDFFormat PDF = new PDFFormat()
                {
                    OutputFileName = Module1.Current.Aoi.FilePath + "\\" + Constants.FOLDER_MAP_PACKAGE + "\\"
                                     + Module1.Current.DisplayedMap,
                    Resolution = 300,
                    DoCompressVectorGraphics = true,
                    DoEmbedFonts             = true,
                    HasGeoRefInfo            = true,
                    ImageCompression         = ImageCompression.Adaptive,
                    ImageQuality             = ImageQuality.Best,
                    LayersAndAttributes      = LayersAndAttributes.LayersAndAttributes
                };

                // Get a handle to the layout
                Layout layout = null;
                await QueuedTask.Run(() =>
                {
                    LayoutProjectItem lytItem =
                        Project.Current.GetItems <LayoutProjectItem>()
                        .FirstOrDefault(m => m.Name.Equals(Constants.MAPS_DEFAULT_LAYOUT_NAME, StringComparison.CurrentCultureIgnoreCase));
                    if (lytItem != null)
                    {
                        layout = lytItem.GetLayout();
                    }
                });

                //Check to see if the path is valid and export
                if (layout != null)
                {
                    if (PDF.ValidateOutputFilePath())
                    {
                        await QueuedTask.Run(() => layout.Export(PDF));  //Export the layout to PDF on the worker thread
                    }
                    MessageBox.Show("PDF file created!!", "BAGIS PRO");
                }
                else
                {
                    MessageBox.Show("Could not find default layout. Map cannot be exported!!", "BAGIS PRO");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("An error occurred while trying to export the map!! " + e.Message, "BAGIS PRO");
            }
        }
Пример #8
0
        public void snippets_MapFrame()
        {
            #region Access map frame and map bookmarks from Layout

            // Reference a layoutitem in a project by name
            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MyLayout"));
            if (layoutItem != null)
            {
                QueuedTask.Run(() =>
                {
                    // Reference and load the layout associated with the layout item
                    Layout layout = layoutItem.GetLayout();
                    if (layout == null)
                    {
                        return;
                    }

                    // Reference a mapframe by name
                    MapFrame mf = layout.Elements.FirstOrDefault(item => item.Name.Equals("MapFrame")) as MapFrame;
                    if (mf == null)
                    {
                        return;
                    }

                    // get the map and the bookmarks
                    Bookmark bookmark = mf.Map.GetBookmarks().FirstOrDefault(b => b.Name == "Great Lakes");
                    if (bookmark == null)
                    {
                        return;
                    }

                    // Set up a PDF format and set its properties
                    PDFFormat PDF      = new PDFFormat();
                    String path        = String.Format(@"C:\Temp\{0}.pdf", bookmark.Name);
                    PDF.OutputFileName = path;

                    // Zoom to the bookmark
                    mf.SetCamera(bookmark);

                    // Export to PDF
                    if (PDF.ValidateOutputFilePath())
                    {
                        mf.Export(PDF);
                    }
                });
            }
            #endregion
        }
Пример #9
0
        public override FileFormat Match(FileFormatScanJob job)
        {
            if (!ValidateStartBytes(job.StartBytes))
            {
                return(null);
            }

            if (!ValidateEndBytes(job.EndBytes))
            {
                return(null);
            }

            var fingerprint = new PDFFormat();

            return(fingerprint);
        }
 public static void ExportAReport(Report report, string path, bool useSelection = true)
 {
     if (report == null)
     {
         return;
     }
     #region Export report to pdf
     //Note: Call within QueuedTask.Run()
     //Define Export Options
     var exportOptions = new ReportExportOptions
     {
         ExportPageOption        = ExportPageOptions.ExportAllPages,
         TotalPageNumberOverride = 0
     };
     //Create PDF format with appropriate settings
     PDFFormat pdfFormat = new PDFFormat();
     pdfFormat.Resolution     = 300;
     pdfFormat.OutputFileName = path;
     report.ExportToPDF($"{report.Name}", pdfFormat, exportOptions, useSelection);
     #endregion
 }
Пример #11
0
        public static Task ExportActiveMapToPDFAsync(string Path)
        {
            return(QueuedTask.Run(() =>
            {
                //Reference the active map view
                MapView map = MapView.Active;

                //Create PDF format with appropriate settings
                PDFFormat PDF = new PDFFormat();
                PDF.Resolution = 300;
                PDF.Height = 500;
                PDF.Width = 800;
                PDF.OutputFileName = Path;

                //Export active map view
                if (PDF.ValidateOutputFilePath())
                {
                    map.Export(PDF);
                }
            }));
        }
Пример #12
0
        public async void btnExportLayout(object sender, EventArgs e)
        {
            var currName = MapView.Active.Map.Name;
            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(currName));

            if (layoutItem != null)
            {
                await QueuedTask.Run(() =>
                {
                    Layout layout = layoutItem.GetLayout();
                    if (layout == null)
                    {
                        return;
                    }

                    var outputFolder = Project.Current.HomeFolderPath;


                    PDFFormat PDF = new PDFFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = outputFolder + "\\" + currName + ".pdf"
                    };

                    if (PDF.ValidateOutputFilePath())
                    {
                        if (File.Exists(PDF.OutputFileName))
                        {
                            Debug.WriteLine(PDF.OutputFileName + " already exists.");
                            MessageBox.Show(PDF.OutputFileName + " already exists.", PDF.OutputFileName + " already exists.", MessageBoxButton.OK);
                        }
                        else
                        {
                            layout.Export(PDF);
                            MessageBox.Show("The layout was exported to a .pdf.", "The layout was exported to a pdf.", MessageBoxButton.OK);
                        }
                    }
                });
            }
        }
Пример #13
0
        public void snippets_exportLayout()
        {
            #region Export a layout

            // Reference a layoutitem in a project by name
            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MyLayout"));
            if (layoutItem != null)
            {
                QueuedTask.Run(() =>
                {
                    Layout layout = layoutItem.GetLayout();
                    if (layout == null)
                    {
                        return;
                    }

                    // Create BMP format with appropriate settings
                    BMPFormat BMP = new BMPFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\temp\Layout.bmp"
                    };
                    if (BMP.ValidateOutputFilePath())
                    {
                        layout.Export(BMP);
                    }

                    // Create EMF format with appropriate settings
                    EMFFormat EMF = new EMFFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\temp\Layout.emf"
                    };
                    if (EMF.ValidateOutputFilePath())
                    {
                        layout.Export(EMF);
                    }

                    // create eps format with appropriate settings
                    EPSFormat EPS = new EPSFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\temp\Layout.eps"
                    };
                    if (EPS.ValidateOutputFilePath())
                    {
                        layout.Export(EPS);
                    }

                    // Create GIF format with appropriate settings
                    GIFFormat GIF = new GIFFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\temp\Layout.gif"
                    };
                    if (GIF.ValidateOutputFilePath())
                    {
                        layout.Export(GIF);
                    }

                    // Create JPEG format with appropriate settings
                    JPEGFormat JPEG = new JPEGFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\temp\Layout.jpg"
                    };
                    if (JPEG.ValidateOutputFilePath())
                    {
                        layout.Export(JPEG);
                    }

                    // Create PDF format with appropriate settings
                    PDFFormat PDF = new PDFFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\temp\Layout.pdf"
                    };
                    if (PDF.ValidateOutputFilePath())
                    {
                        layout.Export(PDF);
                    }

                    // Create PNG format with appropriate settings
                    PNGFormat PNG = new PNGFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\temp\Layout.png"
                    };
                    if (PNG.ValidateOutputFilePath())
                    {
                        layout.Export(PNG);
                    }

                    // Create SVG format with appropriate settings
                    SVGFormat SVG = new SVGFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\temp\Layout.svg"
                    };
                    if (SVG.ValidateOutputFilePath())
                    {
                        layout.Export(SVG);
                    }

                    // Create TGA format with appropriate settings
                    TGAFormat TGA = new TGAFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\temp\Layout.tga"
                    };
                    if (TGA.ValidateOutputFilePath())
                    {
                        layout.Export(TGA);
                    }

                    // Create TIFF format with appropriate settings
                    TIFFFormat TIFF = new TIFFFormat()
                    {
                        Resolution     = 300,
                        OutputFileName = @"C:\temp\Layout.tif"
                    };
                    if (TIFF.ValidateOutputFilePath())
                    {
                        layout.Export(TIFF);
                    }
                });
            }
            #endregion
        }
Пример #14
0
        async public static void MethodSnippets()
        {
            #region LayoutProjectItem_GetLayout
            //Reference the layout associated with a layout project item.

            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout Name"));
            Layout            layout     = await QueuedTask.Run(() => layoutItem.GetLayout()); //Perform on the worker thread

            #endregion LayoutProjectItem_GetLayout


            TextElement elm = layout.FindElement("Text") as TextElement;
            #region Layout_DeleteElement
            //Delete a single layout element.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.DeleteElement(elm);
            });

            #endregion Layout_DeleteElement


            #region Layout_DeleteElements
            //Delete multiple layout elements.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.DeleteElements(item => item.Name.Contains("Clone"));
            });

            #endregion Layout_DeleteElements


            #region Layout_FindElement
            //Find a layout element.  The example below is referencing an existing text element.

            TextElement txtElm = layout.FindElement("Text") as TextElement;
            #endregion Layout_FindElement


            #region Layout_GetSetDefinition
            //Modify a layout's CIM definition

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                CIMLayout cimLayout = layout.GetDefinition();

                //Do something

                layout.SetDefinition(cimLayout);
            });

            #endregion Layout_GetSetDefinition


            #region Layout_GetSetPage
            //Modify a layouts page settings.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                CIMPage page = layout.GetPage();

                //Do something

                layout.SetPage(page);
            });

            #endregion Layout_GetSetPage


            String filePath = null;
            #region Layout_ExportPDF
            //See ProSnippets "Export layout to PDF"
            #endregion Layout_ExportPDF


            #region Layout_ExportMS_PDF
            //Export multiple map series pages to PDF

            //Create a PDF export format
            PDFFormat msPDF = new PDFFormat()
            {
                Resolution               = 300,
                OutputFileName           = filePath,
                DoCompressVectorGraphics = true
            };

            //Set up the export options for the map series
            MapSeriesExportOptions MSExport_custom = new MapSeriesExportOptions()
            {
                ExportPages           = ExportPages.Custom,
                CustomPages           = "1-3, 5",
                ExportFileOptions     = ExportFileOptions.ExportAsSinglePDF,
                ShowSelectedSymbology = false
            };

            //Check to see if the path is valid and export
            if (msPDF.ValidateOutputFilePath())
            {
                layout.Export(msPDF, MSExport_custom); //Export the PDF to a single, multiple page PDF.
            }
            #endregion Layout_ExportMS_PDF


            #region Layout_ExportMS_TIFF
            //Export multiple map series pages to TIFF

            //Create a TIFF export format
            TIFFFormat msTIFF = new TIFFFormat()
            {
                Resolution     = 300,
                OutputFileName = filePath,
                ColorMode      = ColorMode.TwentyFourBitTrueColor,
                HasGeoTiffTags = true,
                HasWorldFile   = true
            };

            //Set up the export options for the map series
            MapSeriesExportOptions MSExport_All = new MapSeriesExportOptions()
            {
                ExportPages           = ExportPages.All,
                ExportFileOptions     = ExportFileOptions.ExportMultipleNames,
                ShowSelectedSymbology = false
            };

            //Check to see if the path is valid and export
            if (msPDF.ValidateOutputFilePath())
            {
                layout.Export(msPDF, MSExport_All); //Export each page to a TIFF and apppend the page name suffix to each output file
            }
            #endregion Layout_ExportMS_TIFF


            #region Layout_RefreshMapSeries
            //Refresh the map series associated with the layout.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.RefreshMapSeries();
            });

            #endregion Layout_RefreshMapSeries


            #region Layout_SaveAsFile
            //Save a layout to a pagx file.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.SaveAsFile(filePath);
            });

            #endregion Layout_SaveAsFile


            #region Layout_SetName
            //Change the name of a layout.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.SetName("New Name");
            });

            #endregion Layout_SetName


            SpatialMapSeries SMS = null;
            #region Layout_SetMapSeries
            //Change the properities of a spacial map series.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.SetMapSeries(SMS);
            });

            #endregion Layout_SetMapSeries


            #region Layout_ShowProperties
            //Open the layout properties dialog.

            //Get the layout associated with a layout project item
            LayoutProjectItem lytItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout Name"));
            Layout            lyt     = await QueuedTask.Run(() => lytItem.GetLayout()); //Worker thread

            //Open the properties dialog
            lyt.ShowProperties(); //GUI thread
            #endregion Layout_ShowProperties
        }