static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            RenderingOptions renderingOptions = new RenderingOptions();

            // Enable text objects rendering
            renderingOptions.RenderTextObjects = true;
            // DISABLE vector objects rendering
            renderingOptions.RenderVectorObjects = false;
            // DISABLE image objects rendering
            renderingOptions.RenderImageObjects = false;

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Render document page to PNG image file.
                renderer.Save("image" + i + ".png", RasterImageFormat.PNG, i, 300, renderingOptions);
            }

            // Cleanup
            renderer.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("image0.png");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Set high quality resolution 600 dpi (600 dots per inch)
            float renderingResolution = 600;

            // Load PDF document.
            renderer.LoadDocumentFromFile("sample_table.pdf");

            // Set extraction area
            renderer.SetExtractionArea(205.5f, 108.75f, 331.5f, 121.5f);

            // Render part of document to PNG image file.
            renderer.Save($"result_{renderingResolution}.png", RasterImageFormat.PNG, 0, renderingResolution);

            // Cleanup
            renderer.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo($"result_{renderingResolution}.png");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document
            renderer.LoadDocumentFromFile("multipage.pdf");

            // Specify Rendering Options
            RenderingOptions renderingOptions = new RenderingOptions();

            renderingOptions.ResolutionOverride = 300;

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Render document page to 800x600 PNG image file.
                renderer.Save("image" + i + ".png", RasterImageFormat.PNG, i, 600, 800, renderingOptions);
            }

            // Cleanup
            renderer.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("image0.png");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Input file Url
            var inputUrl = @"https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-to-text/sample.pdf";

            // Get Input Stream
            var inpStream = GetStreamFromUrl(inputUrl);

            // Load PDF document from stream
            renderer.LoadDocumentFromStream(inpStream);

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Render document page to PNG image file.
                renderer.Save("image" + i + ".jpg", RasterImageFormat.JPEG, i, 96);
            }

            // Cleanup
            renderer.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("image0.jpg");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
        /*
         * IF YOU SEE TEMPORARY FOLDER ACCESS ERRORS:
         *
         * Temporary folder access is required for web application when you use ByteScout SDK in it.
         * If you are getting errors related to the access to temporary folder like "Access to the path 'C:\Windows\TEMP\... is denied" then you need to add permission for this temporary folder to make ByteScout SDK working on that machine and IIS configuration because ByteScout SDK requires access to temp folder to cache some of its data for more efficient work.
         *
         * SOLUTION:
         *
         * If your IIS Application Pool has "Load User Profile" option enabled the IIS provides access to user's temp folder. Check user's temporary folder
         *
         * If you are running Web Application under an impersonated account or IIS_IUSRS group, IIS may redirect all requests into separate temp folder like "c:\temp\".
         *
         * In this case
         * - check the User or User Group your web application is running under
         * - then add permissions for this User or User Group to read and write into that temp folder (c:\temp or c:\windows\temp\ folder)
         * - restart your web application and try again
         *
         */

        protected void Page_Load(object sender, EventArgs e)
        {
            // Prepare a test document.
            // Multipage.pdf file will be copied to the project directory on the pre-build event (see the project properties).
            String inputDocument = Server.MapPath("multipage.pdf");

            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document.
            renderer.LoadDocumentFromFile(inputDocument);

            // Prepare response.
            Response.Clear();
            Response.ContentType = "image/png";
            Response.AddHeader("Content-Disposition", "inline;filename=result.png");

            // Render first page of the document to the output stream.
            renderer.Save(Response.OutputStream, RasterImageFormat.PNG, 0, 300);

            Response.End();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Prepare a test document.
            // Multipage.pdf file will be copied to the project directory on the pre-build event (see the project properties).
            String inputDocument = Server.MapPath("multipage.pdf");

            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document.
            renderer.LoadDocumentFromFile(inputDocument);

            // Write the response.
            Response.Clear();
            Response.ContentType = "text/html";

            Response.Write("Converting into multipaged TIFF image...<br>");
            Response.Flush();

            // Render document to multi-page TIFF file at 300 DPI resoultion
            renderer.SaveMultipageTiff(Server.MapPath("output.tiff"), 0, -1, 300);

            Response.Write("Done! Check <a href=\"output.tiff\">output.tiff</a> file saved");

            Response.End();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            RenderingOptions renderingOptions = new RenderingOptions();

            // Set pixel format to 1-bit
            renderingOptions.ImageBitsPerPixel = ImageBitsPerPixel.BPP1;

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Save 1-bit image to file
                renderer.Save("image" + i + ".bmp", RasterImageFormat.BMP, i, 200, renderingOptions);
            }

            // Cleanup
            renderer.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("image0.bmp");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            // Iterate through pages
            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    // Render document page and save to memory stream
                    renderer.Save(memoryStream, RasterImageFormat.PNG, i, 300);

                    // Create image from memory stream
                    Image pngImg = Image.FromStream(memoryStream);
                    // Save image to file
                    pngImg.Save(i + ".png");
                }
            }

            // Cleanup
            renderer.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("0.png");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
        static void Main(string[] args)
        {
            // LicenseInfo can be retrieved by createing instance of any renderer class,
            // Because all of them are derived from BaseRenderer
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Get License Info
            var licenseInfo = renderer.LicenseInfo;

            // Show Info
            Console.WriteLine("===============================");
            Console.WriteLine("======== License Info =========");
            Console.WriteLine("===============================\n");

            Console.WriteLine($"License type: {licenseInfo.LicenseType}");
            Console.WriteLine($"License limit type: {licenseInfo.LimitType}");
            Console.WriteLine($"Limit of license units: {licenseInfo.Limit}");
            Console.WriteLine($"License limit term: {licenseInfo.LimitTerm}");
            Console.WriteLine($"No of remaining license units: {licenseInfo.Remainder}");
            Console.WriteLine($"Update expires On: {licenseInfo.UpdatesExpireOn}");

            Console.ReadLine();
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            RenderingOptions renderingOptions = new RenderingOptions();

            // Enable text objects rendering
            renderingOptions.RenderTextObjects = true;
            // DISABLE vector objects rendering
            renderingOptions.RenderVectorObjects = false;
            // DISABLE image objects rendering
            renderingOptions.RenderImageObjects = false;

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Render document page to PNG image file.
                renderer.Save("image" + i + ".png", RasterImageFormat.PNG, i, 300, renderingOptions);
            }

            // Open the first output file in default image viewer.
            System.Diagnostics.Process.Start("image0.png");
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            // Iterate through pages
            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    // Render document page and save to memory stream
                    renderer.Save(memoryStream, RasterImageFormat.PNG, i, 300);

                    // Create image from memory stream
                    Image pngImg = Image.FromStream(memoryStream);
                    // Save image to file
                    pngImg.Save(i + ".png");
                }
            }

            // Open the first output file in default image viewer.
            // open the very first page
            System.Diagnostics.Process.Start("0.png");
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            RenderingOptions renderingOptions = new RenderingOptions();

            // Set pixel format to 1-bit
            renderingOptions.ImageBitsPerPixel = ImageBitsPerPixel.BPP1;

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Save 1-bit image to file
                renderer.Save("image" + i + ".bmp", RasterImageFormat.BMP, i, 200, renderingOptions);
            }

            // Open the first output image in default image viewer.
            System.Diagnostics.Process.Start("image0.bmp");
        }
Exemplo n.º 13
0
        static void Main()
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document
            renderer.LoadDocumentFromFile("multipage.pdf");

            // Get size of the page in Points (standard PDF document units; 1 Point = 1/72")
            RectangleF rectangle = renderer.GetPageRectangle(0);

            int width, height;

            if (rectangle.Width < rectangle.Height) // portrait page orientation
            {
                width  = -1;                        // width will be calculated from height keeping the aspect ratio
                height = 100;
            }
            else             // landscape page orientation
            {
                width  = 100;
                height = -1;                 // height will be calculated from width keeping the aspect ratio
            }

            // Render first page of the document to JPEG image file
            renderer.Save("thumbnail.jpg", RasterImageFormat.JPEG, 0, width, height);

            // Open the output image file in default image viewer
            System.Diagnostics.Process.Start("thumbnail.jpg");
        }
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document
            renderer.LoadDocumentFromFile("multipage.pdf");

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Render document page to TIFF images
                renderer.Save("image" + i + ".tif", RasterImageFormat.TIFF, i, 96, new RenderingOptions()
                {
                    // select TIFF compression
                    TIFFCompression = TIFFCompression.LZW
                });
            }

            // Cleanup
            renderer.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("image0.tif");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Render first page of the document to BMP image file.
                renderer.Save("image" + i + ".bmp", RasterImageFormat.BMP, i, 300);
            }

            // Cleanup
            renderer.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("image0.bmp");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
Exemplo n.º 16
0
        static void Main()
        {
            // Create Bytescout.PDFRenderer.RasterRenderer object instance and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            int startPage = 0;
            int endPage   = renderer.GetPageCount() - 1;

            // Save PDF document to black-and-white multi-page TIFF at 120 DPI
            RenderingOptions renderingOptions = new RenderingOptions();

            renderingOptions.TIFFCompression = TIFFCompression.CCITT4;
            renderer.SaveMultipageTiff("multipage.tiff", startPage, endPage, 120, renderingOptions);

            // Cleanup
            renderer.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("multipage.tiff");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
Exemplo n.º 17
0
        public void Draw_PassARasterRenderer_DrawsWithTheSpecifiedRenderer()
        {
            var renderer = new RasterRenderer();
            var circle   = new Circle(renderer, 5);
            var drawn    = circle.Draw();

            Assert.That(drawn, Is.EqualTo("raster"));
        }
Exemplo n.º 18
0
        public Form1()
        {
            InitializeComponent();

            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            _rasterRenderer = new RasterRenderer();
            _rasterRenderer.RegistrationName = "demo";
            _rasterRenderer.RegistrationKey  = "demo";
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            var rasterRenderer = new RasterRenderer();
            var vectorRenderer = new VectorRenderer();

            var triangleOne = new Triangle(rasterRenderer, nameof(Triangle));
            var triangleTwo = new Triangle(vectorRenderer, nameof(Triangle));

            triangleOne.Draw();
            triangleTwo.Draw();
        }
Exemplo n.º 20
0
        static void Slice(int pageIndex, FoundLinesCollection lines, RasterRenderer rasterRenderer)
        {
            const float pdfRenderingResolution = 300;
            float       lastLineY = float.NaN;
            int         sliceNum  = 0;

            RectangleF pageRect = rasterRenderer.GetPageRectangle(pageIndex);

            foreach (FoundLine line in lines)
            {
                if (float.IsNaN(lastLineY))
                {
                    lastLineY = line.From.Y;
                }
                else
                {
                    // Compute slice rectangle
                    RectangleF sliceRect = new RectangleF(0, lastLineY, pageRect.Width, line.From.Y - lastLineY);
                    // Set extraction rectangle for RasterRenderer
                    rasterRenderer.SetExtractionArea(sliceRect);
                    // Render the page region to Image object
                    Image slice = rasterRenderer.GetImage(pageIndex, pdfRenderingResolution);

                    // Create PDF document
                    Document document = new Document
                    {
                        RegistrationName = "demo",
                        RegistrationKey  = "demo"
                    };

                    // Create page of A4 size
                    Page page = new Page(PaperFormat.A4);
                    document.Pages.Add(page);

                    // Create PDF Image object from System.Drawing.Image
                    Bytescout.PDF.Image pdfImage = new Bytescout.PDF.Image(slice);
                    // Draw image on the page keeping the aspect ratio
                    RectangleF r = new RectangleF(0, 20, page.Width, page.Width / slice.Width * slice.Height);
                    page.Canvas.DrawImage(pdfImage, r.Left, r.Top, r.Width, r.Height);

                    // Save PDF document
                    string fileName = string.Format(@"{0}\{1}-page{2}-slice{3}.pdf", OutputFolder, Path.GetFileName(InputFile), pageIndex, ++sliceNum);
                    document.Save(fileName);

                    Console.WriteLine("Saved slice '{0}'", fileName);

                    // Cleanup
                    document.Dispose();
                    slice.Dispose();

                    lastLineY = line.From.Y;
                }
            }
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            const string inputFile           = @"sample.pdf";
            const int    pageIndex           = 0;
            const float  renderingResolution = 300f;
            const string searchPattern       = "\\d+\\.\\d+";

            // Prepare TextExtractor
            using (TextExtractor textExtractor = new TextExtractor("demo", "demo"))
            {
                textExtractor.RegexSearch = true;
                textExtractor.LoadDocumentFromFile(inputFile);

                // Preapre RasterRenderer
                using (RasterRenderer rasterRenderer = new RasterRenderer("demo", "demo"))
                {
                    rasterRenderer.LoadDocumentFromFile(inputFile);

                    // Render document page to image
                    Image image = rasterRenderer.GetImage(pageIndex, renderingResolution);

                    // Prepare highlight brush
                    Brush highlightBrush = new SolidBrush(Color.FromArgb(128, Color.Yellow));

                    using (Graphics graphics = Graphics.FromImage(image))
                    {
                        // Search for pattern and paint found piecese
                        if (textExtractor.Find(pageIndex, searchPattern, caseSensitive: false))
                        {
                            do
                            {
                                foreach (var foundPiece in textExtractor.FoundText.Elements)
                                {
                                    // Convert from document Points to pixels
                                    Rectangle pixelRect = new Rectangle(
                                        (int)(foundPiece.Bounds.Left / 72f * renderingResolution),
                                        (int)(foundPiece.Bounds.Top / 72f * renderingResolution),
                                        (int)(foundPiece.Bounds.Width / 72f * renderingResolution),
                                        (int)(foundPiece.Bounds.Height / 72f * renderingResolution)
                                        );

                                    // Paint rectangle
                                    graphics.FillRectangle(highlightBrush, pixelRect);
                                }
                            } while (textExtractor.FindNext());
                        }
                    }

                    image.Save("result.png");
                    Process.Start("result.png");
                }
            }
        }
Exemplo n.º 22
0
        private static void Bridge()
        {
            IRenderer render = new VectorRender();
            Circle    circle = new Circle(render, 10);

            circle.Draw();
            circle.Resize(2);
            circle.Draw();

            render = new RasterRenderer();
            Circle circle2 = new Circle(render, 10);

            circle2.Draw();
            circle2.Resize(2);
            circle2.Draw();
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            if (!Directory.Exists(OutputFolder))
            {
                Directory.CreateDirectory(OutputFolder);
            }

            // Create LineDetector instance and load document
            LineDetector lineDetector = new LineDetector("demo", "demo");

            lineDetector.LoadDocumentFromFile(InputFile);

            // Create RasterRenderer instance and load document
            RasterRenderer rasterRenderer = new RasterRenderer("demo", "demo");

            rasterRenderer.LoadDocumentFromFile(InputFile);

            try
            {
                int pageCount = lineDetector.GetPageCount();

                for (int pageIndex = 0; pageIndex < pageCount; pageIndex++)
                {
                    Console.WriteLine("Processing page #{0}", pageIndex);

                    // Find horizontal lines on the page
                    FoundLinesCollection horzLines = lineDetector.FindLines(pageIndex, LineOrientationsToFind.OnlyHorizontal);
                    // Slice page by separating lines and create new PDF documents
                    Slice(pageIndex, horzLines, rasterRenderer);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
            finally
            {
                // Cleanup
                rasterRenderer.Dispose();
                lineDetector.Dispose();
            }


            Console.WriteLine();
            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            // Render first page of the document to PNG image file.
            renderer.Save("result.png", RasterImageFormat.PNG, 0, 300);

            // Open the output file in default image viewer.
            System.Diagnostics.Process.Start("result.png");
        }
Exemplo n.º 25
0
                    public static RasterRenderer FromBaseObject(BaseObject baseObj)
                    {
                        if (baseObj == null || baseObj.NativeObject == IntPtr.Zero)
                        {
                            return(null);
                        }
                        RasterRenderer obj = baseObj as  RasterRenderer;

                        if (object.Equals(obj, null))
                        {
                            obj = new RasterRenderer(CreatedWhenConstruct.CWC_NotToCreate);
                            obj.BindNativeObject(baseObj.NativeObject, "CRasterRenderer");
                            obj.IncreaseCast();
                        }

                        return(obj);
                    }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document
            renderer.LoadDocumentFromFile("multipage.pdf");

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Render document page to PNG image file.
                renderer.Save("image" + i + ".jpg", RasterImageFormat.JPEG, i, 96);
            }

            // Open the first output file in default image viewer.
            System.Diagnostics.Process.Start("image0.jpg");
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Render first page of the document to BMP image file.
                renderer.RenderPageToFile(i, RasterOutputFormat.BMP, "image" + i + ".bmp");
            }

            // Open the first output file in default image viewer.
            System.Diagnostics.Process.Start("image0.bmp");
        }
Exemplo n.º 28
0
        private void RenderFeature(SKCanvas canvas, IReadOnlyViewport viewport, ILayer layer, IStyle style, IFeature feature, float layerOpacity)
        {
            // Check, if we have a special renderer for this style
            if (StyleRenderers.ContainsKey(style.GetType()))
            {
                // Save canvas
                canvas.Save();
                // We have a special renderer, so try, if it could draw this
                var result = ((ISkiaStyleRenderer)StyleRenderers[style.GetType()]).Draw(canvas, viewport, layer, feature, style, _symbolCache);
                // Restore old canvas
                canvas.Restore();
                // Was it drawn?
                if (result)
                {
                    // Yes, special style renderer drawn correct
                    return;
                }
            }

            //return; //Not using any standard renderers ;)

            //// No special style renderer handled this up to now, than try standard renderers
            ////if (feature.Geometry is Point)
            ////    PointRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, _symbolCache, layerOpacity * style.Opacity);
            ////else
            //if (feature.Geometry is MultiPoint)
            //    MultiPointRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, _symbolCache, layerOpacity * style.Opacity);
            //else if (feature.Geometry is LineString)
            //    LineStringRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity);
            //else if (feature.Geometry is MultiLineString)
            //    MultiLineStringRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity);
            ////else if (feature.Geometry is Polygon)
            ////    PolygonRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity, _symbolCache);
            //else if (feature.Geometry is MultiPolygon)
            //    MultiPolygonRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity, _symbolCache);
            //else
            if (feature.Geometry is IRaster)
            {
                RasterRenderer.Draw(canvas, viewport, style, feature, layerOpacity * style.Opacity, _tileCache, _currentIteration);
            }
        }
Exemplo n.º 29
0
        static void Main()
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Load PDF document
            renderer.LoadDocumentFromFile("multipage.pdf");

            // Get size of the page in Points (standard PDF document units; 1 Point = 1/72")
            RectangleF rectangle = renderer.GetPageRectangle(0);

            int width, height;

            if (rectangle.Width < rectangle.Height) // portrait page orientation
            {
                width  = -1;                        // width will be calculated from height keeping the aspect ratio
                height = 100;
            }
            else // landscape page orientation
            {
                width  = 100;
                height = -1; // height will be calculated from width keeping the aspect ratio
            }

            // Render first page of the document to JPEG image file
            renderer.Save("thumbnail.jpg", RasterImageFormat.JPEG, 0, width, height);

            // Cleanup
            renderer.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("thumbnail.jpg");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
Exemplo n.º 30
0
        static void Main(string[] args)
        {
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();

            renderer.RegistrationName = "demo";
            renderer.RegistrationKey  = "demo";

            // Set high quality resolution 600 dpi (600 dots per inch)
            float renderingResolution = 600;

            // Load PDF document.
            renderer.LoadDocumentFromFile("multipage.pdf");

            for (int i = 0; i < renderer.GetPageCount(); i++)
            {
                // Render first page of the document to PNG image file.
                renderer.Save("image" + i + ".png", RasterImageFormat.PNG, i, renderingResolution);
            }

            // Open the first output file in default image viewer.
            System.Diagnostics.Process.Start("image0.png");
        }