ByteScout PDF Suite - VB.NET - Pdf to image with custom size with pdf renderer sdk - ByteScout

ByteScout PDF Suite – VB.NET – Pdf to image with custom size with pdf renderer sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Suite – VB.NET – Pdf to image with custom size with pdf renderer sdk

pdf to image with custom size with pdf renderer sdk in VB.NET and ByteScout PDF Suite

Simple tutorial on how to do pdf to image with custom size with pdf renderer sdk in VB.NET

This page helps you to learn from code samples for programming in VB.NET. ByteScout PDF Suite was created to assist pdf to image with custom size with pdf renderer sdk in VB.NET. ByteScout PDF Suite is the bundle that provides six different SDK libraries to work with PDF from generating rich PDF reports to extracting data from PDF documents and converting them to HTML. This bundle includes PDF (Generator) SDK, PDF Renderer SDK, PDF Extractor SDK, PDF to HTML SDK, PDF Viewer SDK and PDF Generator SDK for Javascript.

Want to speed up the application development? Then this VB.NET, code samples for VB.NET, developers help to speed up the application development and writing a code when using ByteScout PDF Suite. If you want to implement this functionality, you should copy and paste code below into your app using code editor. Then compile and run your application. Enjoy writing a code with ready-to-use sample VB.NET codes to implement pdf to image with custom size with pdf renderer sdk using ByteScout PDF Suite.

Visit our website to get a free trial version of ByteScout PDF Suite. Free trial contains many of source code samples to help you with your VB.NET project.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.vb
      
Imports System.Collections.Generic Imports Bytescout.PDFRenderer Class Program Friend Shared Sub Main(args As String()) ' Specify Image Generation Inputs Dim imageGenerationInputs As 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. Dim renderer As New RasterRenderer() renderer.RegistrationName = "demo" renderer.RegistrationKey = "demo" ' Load PDF document. renderer.LoadDocumentFromFile("multipage.pdf") ' Specify Rendering Options to fine tune output generation Dim RenderingOptions As New RenderingOptions() RenderingOptions.TIFFCompression = TIFFCompression.None RenderingOptions.VectorSmoothingMode = GraphicsTransformationQuality.HighQuality ' Loop through each custom size specified For Each itmCustomSize As KeyValuePair(Of Int32, Int32) In imageGenerationInputs.CustomSizes ' Loop through all pages For pageIndex As Integer = 0 To renderer.GetPageCount() - 1 ' Perform save as PNG, if specified If imageGenerationInputs.EnableSaveAsPng Then Dim pngImageName As String = {code}quot;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") End If ' Perform save as JPG, if specified If imageGenerationInputs.EnableSaveAsJpeg Then Dim jpgImageName As String = {code}quot;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") End If Next ' Perform save as TIFF, if specified If imageGenerationInputs.EnableSaveAsTiff Then Dim tiffImageName As String = {code}quot;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") End If Next ' Cleanup renderer.Dispose() Console.ReadLine() End Sub End Class Class ImageGenerationInputs #Region "Constructors" Public Sub New() CustomSizes = New List(Of KeyValuePair(Of Integer, Integer))() EnableSaveAsPng = True End Sub #End Region #Region "Properties" Public Property CustomSizes As List(Of KeyValuePair(Of Int32, Int32)) Public Property EnableSaveAsPng As Boolean Public Property EnableSaveAsJpeg As Boolean Public Property EnableSaveAsTiff As Boolean #End Region #Region "Methods" Public Sub AddCustomSize(ByVal width As Int32, ByVal height As Int32) CustomSizes.Add(New KeyValuePair(Of Integer, Integer)(width, height)) End Sub #End Region End Class

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next