public static void Run()
        {
            // ExStart:ExtractImagesStream
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            // Open input PDF
            PdfExtractor pdfExtractor = new PdfExtractor();

            pdfExtractor.BindPdf(dataDir + "ExtractImages-Stream.pdf");

            // Extract images
            pdfExtractor.ExtractImage();
            // Get all the extracted images
            while (pdfExtractor.HasNextImage())
            {
                // Read image into memory stream
                MemoryStream memoryStream = new MemoryStream();
                pdfExtractor.GetNextImage(memoryStream);

                // Write to disk, if you like, or use it otherwise.
                FileStream fileStream = new
                                        FileStream(dataDir + DateTime.Now.Ticks.ToString() + "_out.jpg", FileMode.Create);
                memoryStream.WriteTo(fileStream);
                fileStream.Close();
            }
            // ExEnd:ExtractImagesStream
        }
Exemplo n.º 2
0
        public static void Run()
        {
            // ExStart:ConvertPDFPages
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();

            // Create PdfConverter object
            PdfConverter objConverter = new PdfConverter();

            // Bind input pdf file
            objConverter.BindPdf(dataDir + "ConvertPDFPages.pdf");

            // Initialize the converting process
            objConverter.DoConvert();

            objConverter.CoordinateType = PageCoordinateType.CropBox;

            // Check if pages exist and then convert to image one by one
            while (objConverter.HasNextImage())
            {
                objConverter.GetNextImage(dataDir + DateTime.Now.Ticks.ToString() + "_out_.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            }

            // Close the PdfConverter object
            objConverter.Close();
            // ExEnd:ConvertPDFPages
        }
        public static void Run()
        {
            // ExStart:ConvertToTIFFSettings
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            // Create PdfConverter object and bind input PDF file
            PdfConverter pdfConverter = new PdfConverter();

            // Create Resolution object with 300 as an argument
            Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);
            // Specify the resolution value for PdfConverter object
            pdfConverter.Resolution = resolution;
            // Bind the source PDF file
            pdfConverter.BindPdf(dataDir + "ConvertToTIFF-Settings.pdf");
            // Start the conversion process
            pdfConverter.DoConvert();
            // Create TiffSettings object and set ColorDepth
            TiffSettings tiffSettings = new TiffSettings();

            tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp;
            // Convert to TIFF image
            pdfConverter.SaveAsTIFF(dataDir + "output_out_.tif", 300, 300, tiffSettings);
            // Close Converter object
            pdfConverter.Close();
            // ExEnd:ConvertToTIFFSettings
        }
Exemplo n.º 4
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();

            //open input PDF
            PdfExtractor pdfExtractor = new PdfExtractor();

            pdfExtractor.BindPdf(dataDir + "ExtractImages-Page.pdf");

            //set StartPage and EndPage properties to the page number to
            //you want to extract images from
            pdfExtractor.StartPage = 2;
            pdfExtractor.EndPage   = 2;

            //extract images
            pdfExtractor.ExtractImage();
            //get extracted images
            while (pdfExtractor.HasNextImage())
            {
                //read image into memory stream
                MemoryStream memoryStream = new MemoryStream();
                pdfExtractor.GetNextImage(memoryStream);

                //write to disk, if you like, or use it otherwise.
                FileStream fileStream = new
                                        FileStream(dataDir + DateTime.Now.Ticks.ToString() + ".jpg", FileMode.Create);
                memoryStream.WriteTo(fileStream);
                fileStream.Close();
            }
        }
Exemplo n.º 5
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            //open input PDF
            PdfContentEditor pdfContentEditor = new PdfContentEditor();

            pdfContentEditor.BindPdf(dataDir + "ReplaceImage.pdf");
            //replace image on a particular page
            pdfContentEditor.ReplaceImage(1, 1, dataDir + "aspose-logo.jpg");
            //save output PDF
            pdfContentEditor.Save(dataDir + "ReplaceImage_out.pdf");
        }
Exemplo n.º 6
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();

            //create PdfFileMend object to add text
            PdfFileMend mender = new PdfFileMend(dataDir + "AddImage.pdf", dataDir + "AddImage_out.pdf");

            //add image in the PDF file
            mender.AddImage(dataDir + "aspose-logo.jpg", 1, 100, 600, 200, 700);

            //close PdfFileMend object
            mender.Close();
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            //open PDF file
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "DeleteAllImages.pdf");

            //delete the images from the particular page
            contentEditor.DeleteImage();

            //save output PDF
            contentEditor.Save(dataDir + "DeleteAllImages_out.pdf");
        }
Exemplo n.º 8
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            //open PDF file
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "DeleteImages-Page.pdf");

            //array of images to be deleted
            int[] imageIndex = new int[] { 1 };

            //delete the images from the particular page
            contentEditor.DeleteImage(2, imageIndex);

            //save output PDF
            contentEditor.Save(dataDir + "DeleteImages-Page_out.pdf");
        }
Exemplo n.º 9
0
        public static void Run()
        {
            // ExStart:ConvertToTIFF
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            // Create PdfConverter object and bind input PDF file
            PdfConverter pdfConverter = new PdfConverter();

            // Bind the source PDF file
            pdfConverter.BindPdf(dataDir + "ConvertToTIFF-Settings.pdf");
            // Start the conversion process
            pdfConverter.DoConvert();
            // Convert to TIFF image
            pdfConverter.SaveAsTIFF(dataDir + "output_out.tif");
            // Close Converter object
            pdfConverter.Close();
            // ExEnd:ConvertToTIFF
        }
Exemplo n.º 10
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();

            //open input PDF
            PdfExtractor pdfExtractor = new PdfExtractor();

            pdfExtractor.BindPdf(dataDir + "ExtractImages.pdf");

            //extract all the images
            pdfExtractor.ExtractImage();

            //get all the extracted images
            while (pdfExtractor.HasNextImage())
            {
                pdfExtractor.GetNextImage(dataDir + DateTime.Now.Ticks.ToString() + ".jpg");
            }
        }
Exemplo n.º 11
0
        public static void Run()
        {
            // ExStart:ConvertPageRegion
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();

            // Instantiate PdfPageEditor class to get particular page region
            Aspose.Pdf.Facades.PdfPageEditor editor = new Aspose.Pdf.Facades.PdfPageEditor();
            // Bind the source PDF file
            editor.BindPdf(dataDir + "Convert-PageRegion.pdf");
            // Move the origin of PDF file to particular point
            editor.MovePosition(0, 700);
            // Create a memory stream object
            MemoryStream ms = new MemoryStream();

            // Save the updated document to stream object
            editor.Save(ms);
            // Create PdfConverter object
            PdfConverter objConverter = new PdfConverter();

            // Bind input pdf file
            objConverter.BindPdf(ms);
            // Set StartPage and EndPage properties to the page number to
            // You want to convert images from
            objConverter.StartPage = 1;
            objConverter.EndPage   = 1;
            // Counter
            int page = 1;

            // Initialize the converting process
            objConverter.DoConvert();
            // Check if pages exist and then convert to image one by one
            while (objConverter.HasNextImage())
            {
                objConverter.GetNextImage(dataDir + "Specific_Region-Image" + page++ + "_out_.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
            }
            // Close the PdfConverter object
            objConverter.Close();
            // Close MemoryStream object holding the updated document
            ms.Close();
            // ExEnd:ConvertPageRegion
        }
Exemplo n.º 12
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            //open input PDF
            PdfExtractor extractor = new PdfExtractor();

            extractor.BindPdf(dataDir + "ExtractImageExtractionMode.pdf");

            //Specify Image Extraction Mode
            extractor.ExtractImageMode = ExtractImageMode.DefinedInResources;

            //Extract Images based on Image Extraction Mode
            extractor.ExtractImage();

            //Get all the extracted images
            while (extractor.HasNextImage())
            {
                extractor.GetNextImage(dataDir + DateTime.Now.Ticks.ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png);
            }
        }
Exemplo n.º 13
0
        public static void Run()
        {
            // ExStart:AddImage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();

            // Open document
            PdfFileMend mender = new PdfFileMend();

            // Create PdfFileMend object to add text
            mender.BindPdf(dataDir + "AddImage.pdf");

            // Add image in the PDF file
            mender.AddImage(dataDir + "aspose-logo.jpg", 1, 100, 600, 200, 700);

            // Save changes
            mender.Save(dataDir + "AddImage_out.pdf");

            // Close PdfFileMend object
            mender.Close();
            // ExEnd:AddImage
        }
Exemplo n.º 14
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            //create PdfConverter object
            PdfConverter objConverter = new PdfConverter();

            //bind input pdf file
            objConverter.BindPdf(dataDir + "ConvertPDFPages.pdf");

            //initialize the converting process
            objConverter.DoConvert();
            objConverter.ShowHiddenAreas = true;

            //check if pages exist and then convert to image one by one
            while (objConverter.HasNextImage())
            {
                objConverter.GetNextImage(dataDir + DateTime.Now.Ticks.ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            }

            //close the PdfConverter object
            objConverter.Close();
        }