ByteScout PDF SDK - VB.NET - Create Multipage Tiff to PDF - ByteScout

ByteScout PDF SDK – VB.NET – Create Multipage Tiff to PDF

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – VB.NET – Create Multipage Tiff to PDF

How to create multipage tiff to PDF in VB.NET using ByteScout PDF SDK

The tutorial shows how to create multipage tiff to PDF in VB.NET

On this page you will learn from code samples for programming in VB.NET.Writing of the code to create multipage tiff to PDF in VB.NET can be done by developers of any level using ByteScout PDF SDK. ByteScout PDF SDK can create multipage tiff to PDF. It can be used from VB.NET. ByteScout PDF SDK is the pdf library that can create, update and modify PDF files. Supports text with fonts and style selections, layers, form fields, drawing lines and objects, automatic tables, images. Can be used to create and fill pdf forms.

This rich sample source code in VB.NET for ByteScout PDF SDK includes the number of functions and options you should do calling the API to create multipage tiff to PDF. This VB.NET sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Code testing will allow the function to be tested and work properly with your data.

Trial version of ByteScout PDF SDK is available for free. Source code samples are included to help you with your VB.NET app.

Try ByteScout PDF SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

Program.vb
      
Imports System.Drawing Imports System.Drawing.Imaging Imports System.IO Imports Bytescout.PDF ''' <summary> ''' This example demonstrates how to create PDF from multipage TIFF image. ''' </summary> Class Program Shared Sub Main() ' Create new document Dim pdfDocument = New Document() pdfDocument.RegistrationName = "demo" pdfDocument.RegistrationKey = "demo" ' Get TIFF file in BitMap Dim multipageTiffImage As Bitmap = Drawing.Image.FromFile("MultipageTiffFile.tiff") ' Tiff images can contain multiple images named as frame Dim count = multipageTiffImage.GetFrameCount(FrameDimension.Page) For idx = 0 To count - 1 ' Save each frame to a bytestream multipageTiffImage.SelectActiveFrame(FrameDimension.Page, idx) Dim byteStream As New MemoryStream() multipageTiffImage.Save(byteStream, ImageFormat.Tiff) Dim sysImage = FixImageOrientation(byteStream) Using sysImage Dim image = New Bytescout.PDF.Image(sysImage, ImageCompression.DCT, 75) Dim w As Single = sysImage.Width / sysImage.HorizontalResolution * 72.0F Dim h As Single = sysImage.Height / sysImage.VerticalResolution * 72.0F ' Create PDF page Dim page = New Page(w, h) Dim canvas = page.Canvas canvas.DrawImage(image, 0, 0, w, h) ' Add PDF document pdfDocument.Pages.Add(page) End Using Next ' Save document to file pdfDocument.Save("result.pdf") ' Cleanup pdfDocument.Dispose() ' Open document in default PDF viewer app Process.Start("result.pdf") End Sub ''' <summary> ''' Fix image orientation ''' </summary> Private Shared Function FixImageOrientation(ByVal fileStream As Stream) As System.Drawing.Image Dim sysImage As System.Drawing.Image = System.Drawing.Image.FromStream(fileStream, False, False) ' fix orientation by EXIF rotation tag Const exifRotationTag As Integer = &H112 Dim propertyItemIDs As Integer() = sysImage.PropertyIdList Dim found As Integer = Array.BinarySearch(propertyItemIDs, 0, propertyItemIDs.Length, exifRotationTag) If found > -1 Then Dim pi As PropertyItem = sysImage.GetPropertyItem(exifRotationTag) Dim orientation As Integer = pi.Value(0) Select Case orientation Case 2 sysImage.RotateFlip(RotateFlipType.RotateNoneFlipX) Case 3 sysImage.RotateFlip(RotateFlipType.Rotate180FlipNone) Case 4 sysImage.RotateFlip(RotateFlipType.RotateNoneFlipY) Case 5 sysImage.RotateFlip(RotateFlipType.Rotate90FlipX) Case 6 sysImage.RotateFlip(RotateFlipType.Rotate90FlipNone) Case 7 sysImage.RotateFlip(RotateFlipType.Rotate270FlipX) Case 8 sysImage.RotateFlip(RotateFlipType.Rotate270FlipNone) Case Else End Select sysImage.RemovePropertyItem(&H112) End If Return sysImage End Function End Class

Try ByteScout PDF SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Get ByteScout PDF SDK Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Tutorials:

prev
next