Exemplo n.º 1
0
 public PageBreakTest() : base("PageBreaks")
 {
     this.Options = RenderingOptions.WithDefaults(
         hiddenChars: true,
         paragraph: true);
 }
Exemplo n.º 2
0
 public HeaderTests() : base("Headers")
 {
     this.Options = RenderingOptions.WithDefaults(header: true);
 }
 /// <summary>
 ///     Generate component ReactJS action results
 /// </summary>
 /// <param name="componentName">Name of a component exposed from a js package</param>
 /// <param name="model">Data to be passed into a component</param>
 /// <param name="renderOptions"></param>
 /// <returns>ActionResult object</returns>
 public virtual ActionResult JsComponent(string componentName, object model, RenderingOptions renderOptions)
 {
     return(this.JsComponent(componentName, model, renderOptions, RenderingContext.Current.Rendering));
 }
Exemplo n.º 4
0
 public TableTests() : base("Tables")
 {
     this.Options = RenderingOptions.WithDefaults();
 }
Exemplo n.º 5
0
 public PdfRendererPage(PageNumber pageNumber, XGraphics graphics, RenderingOptions options)
     : this(pageNumber, graphics, options, Point.Zero)
 {
 }
Exemplo n.º 6
0
 public FooterTest() : base("Footers")
 {
     this.Options = RenderingOptions.WithDefaults(
         footer: true);
 }
Exemplo n.º 7
0
        public virtual void Export(string sourcePath, string outPath, RenderingOptions options = null)
        {
            switch (dstFormat_)
            {
            case ExportFormat.PDF:
                PdfRenderingOptions pdf_opts = options as PdfRenderingOptions;
                if (pdf_opts == null)
                {
                    pdf_opts = new PdfRenderingOptions();
                }

                using (PdfDevice device = new PdfDevice(pdf_opts, outPath))
                {
                    Render(sourcePath, device);
                }
                break;

            case ExportFormat.XPS:
                XpsRenderingOptions xps_opts = options as XpsRenderingOptions
                ;
                if (xps_opts == null)
                {
                    xps_opts = new XpsRenderingOptions();
                }

                using (XpsDevice device = new XpsDevice(xps_opts, outPath))
                {
                    Render(sourcePath, device);
                }
                break;

            case ExportFormat.MD:
                IDevice nullDev = null;
                Render(sourcePath, nullDev);
                break;

            case ExportFormat.MHTML:
                throw new NotImplementedException("Conversion to 'MHTML' isn't implemented yet.");

            //break;
            case ExportFormat.JPEG:
            case ExportFormat.PNG:
            case ExportFormat.BMP:
            case ExportFormat.TIFF:
            case ExportFormat.GIF:
                ImageRenderingOptions img_opts = options as ImageRenderingOptions;
                if (img_opts == null)
                {
                    img_opts = new ImageRenderingOptions();
                }
                switch (dstFormat_)
                {
                case ExportFormat.JPEG:
                    img_opts.Format = ImageFormat.Jpeg; break;

                case ExportFormat.PNG:
                    img_opts.Format = ImageFormat.Png; break;

                case ExportFormat.BMP:
                    img_opts.Format = ImageFormat.Bmp; break;

                case ExportFormat.TIFF:
                    img_opts.Format = ImageFormat.Tiff; break;

                case ExportFormat.GIF:
                    img_opts.Format = ImageFormat.Gif; break;
                }
                using (ImageDevice device = new ImageDevice(img_opts, outPath))
                {
                    Render(sourcePath, device);
                }

                break;
            }
        }
Exemplo n.º 8
0
 public Task SetOptions(RenderingOptions options)
 {
     State = options;
     return(base.WriteStateAsync());
 }
Exemplo n.º 9
0
 public ParagraphTests() : base("Paragraphs")
 {
     this.Options = RenderingOptions.WithDefaults(hiddenChars: true, word: false);
 }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            // Specify Image Generation Inputs
            ImageGenerationInputs imageGenerationInputs = new ImageGenerationInputs();

            imageGenerationInputs.AddCustomSize(width: 320, height: 420);
            imageGenerationInputs.AddCustomSize(width: 600, height: 800);

            imageGenerationInputs.EnableSaveAsPng  = true;
            imageGenerationInputs.EnableSaveAsJpeg = true;
            imageGenerationInputs.EnableSaveAsTiff = true;

            // 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 to fine tune output generation
            RenderingOptions renderingOptions = new RenderingOptions();

            renderingOptions.TIFFCompression     = TIFFCompression.None;
            renderingOptions.VectorSmoothingMode = GraphicsTransformationQuality.HighQuality;

            // Loop through each custom size specified
            foreach (var itmCustomSize in imageGenerationInputs.CustomSizes)
            {
                // Loop through all pages
                for (int pageIndex = 0; pageIndex < renderer.GetPageCount(); pageIndex++)
                {
                    // Perform save as PNG, if specified
                    if (imageGenerationInputs.EnableSaveAsPng)
                    {
                        var pngImageName = $"output_{itmCustomSize.Key}x{itmCustomSize.Value}_page{pageIndex + 1}.png";

                        // Save png image per page, per custom size
                        renderer.Save(
                            destFileName: pngImageName,
                            outputFormat: RasterImageFormat.PNG,
                            pageIndex: pageIndex,
                            width: itmCustomSize.Key,
                            height: itmCustomSize.Value,
                            renderingOptions: renderingOptions
                            );

                        Console.WriteLine(pngImageName + " - Generated");
                    }

                    // Perform save as JPG, if specified
                    if (imageGenerationInputs.EnableSaveAsJpeg)
                    {
                        var jpgImageName = $"output_{itmCustomSize.Key}x{itmCustomSize.Value}_page{pageIndex + 1}.jpg";

                        // Save jpg image per page, per custom size
                        renderer.Save(
                            destFileName: jpgImageName,
                            outputFormat: RasterImageFormat.JPEG,
                            pageIndex: pageIndex,
                            width: itmCustomSize.Key,
                            height: itmCustomSize.Value,
                            renderingOptions: renderingOptions
                            );

                        Console.WriteLine(jpgImageName + " - Generated");
                    }
                }

                // Perform save as TIFF, if specified
                if (imageGenerationInputs.EnableSaveAsTiff)
                {
                    var tiffImageName = $"output_{itmCustomSize.Key}x{itmCustomSize.Value}.tiff";

                    // Save tiff image per page, per custom size
                    renderer.SaveMultipageTiff(
                        destFileName: tiffImageName,
                        startPageIndex: 0,
                        endPageIndex: renderer.GetPageCount() - 1,
                        width: itmCustomSize.Key,
                        height: itmCustomSize.Value,
                        renderingOptions: renderingOptions);

                    Console.WriteLine(tiffImageName + " - Generated");
                }
            }

            // Cleanup
            renderer.Dispose();

            Console.ReadLine();
        }
Exemplo n.º 11
0
 public PdfRenderer(PdfDocument pdfDocument, RenderingOptions renderingOptions)
 {
     _pdfDocument = pdfDocument;
     this.Options = renderingOptions;
 }