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

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

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

How to create multipage tiff to pdf with pdf sdk in VB.NET using ByteScout PDF Suite

This code in VB.NET shows how to create multipage tiff to pdf with pdf sdk with this how to tutorial

The sample source codes on this page shows how to create multipage tiff to pdf with pdf sdk in VB.NET. What is ByteScout PDF Suite? It 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. It can help you to create multipage tiff to pdf with pdf sdk in your VB.NET application.

These VB.NET code samples for VB.NET guide developers to speed up coding of the application when using ByteScout PDF Suite. Simply copy and paste in your VB.NET project or application you and then run your app! Want to see how it works with your data then code testing will allow the function to be tested and work properly.

You can download free trial version of ByteScout PDF Suite from our website to see and try many others source code samples for VB.NET.

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