ByteScout Premium Suite - VB.NET - Create multipage tiff to pdf with pdf sdk - ByteScout

ByteScout Premium Suite – VB.NET – Create multipage tiff to pdf with pdf sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Premium Suite – VB.NET – Create multipage tiff to pdf with pdf sdk

How to create multipage tiff to pdf with pdf sdk in VB.NET and ByteScout Premium Suite

Step-by-step tutorial on how to create multipage tiff to pdf with pdf sdk in VB.NET

These sample source codes on this page below are displaying how to create multipage tiff to pdf with pdf sdk in VB.NET. ByteScout Premium Suite is the set that includes 12 SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording and you can use it to create multipage tiff to pdf with pdf sdk with VB.NET.

These VB.NET code samples for VB.NET guide developers to speed up coding of the application when using ByteScout Premium Suite. Follow the instructions from scratch to work and copy the VB.NET code. Enjoy writing a code with ready-to-use sample VB.NET codes.

ByteScout Premium Suite free trial version is available on our website. VB.NET and other programming languages are supported.

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.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

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium 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 Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next