ByteScout PDF Suite - VB.NET - Convert digital photos to pdf with pdf sdk - ByteScout

ByteScout PDF Suite – VB.NET – Convert digital photos to pdf with pdf sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Suite – VB.NET – Convert digital photos to pdf with pdf sdk

How to convert digital photos to pdf with pdf sdk in VB.NET and ByteScout PDF Suite

Learn to code in VB.NET to convert digital photos to pdf with pdf sdk with this step-by-step tutorial

We made thousands of pre-made source code pieces for easy implementation in your own programming projects. What is ByteScout PDF Suite? It is the set that includes 6 SDK products 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 convert digital photos to pdf with pdf sdk in your VB.NET application.

Want to save time? You will save a lot of time on writing and testing code as you may just take the VB.NET code from ByteScout PDF Suite for convert digital photos to pdf with pdf sdk below and use it in your application. Follow the instructions from scratch to work and copy the VB.NET code. Use of ByteScout PDF Suite in VB.NET is also described in the documentation included along with the product.

ByteScout PDF 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 Bytescout.PDF ''' <summary> ''' This example demonstrates how to add images in their proper orientation and size ''' </summary> Class Program Shared Sub Main() ' Create new document Dim pdfDocument As Document = New Document() pdfDocument.RegistrationName = "demo" pdfDocument.RegistrationKey = "demo" ' Input image array Dim arrImages = New String() {"Image1.jpg", "Image2.jpg"} ' Process each image For Each itmImage In arrImages Dim sysImage = FixImageOrientation(itmImage) Using sysImage Dim image = New 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 PDF document pdfDocument.Save("result.pdf") ' Cleanup pdfDocument.Dispose() ' Open result document in default associated application (for demo purpose) Dim processStartInfo As ProcessStartInfo = New ProcessStartInfo("result.pdf") processStartInfo.UseShellExecute = True Process.Start(processStartInfo) End Sub ''' <summary> ''' Fix image orientation ''' </summary> Private Shared Function FixImageOrientation(ByVal fileName As String) As System.Drawing.Image Dim sysImage As System.Drawing.Image = System.Drawing.Image.FromFile(fileName, 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 System.Drawing.Imaging.PropertyItem = sysImage.GetPropertyItem(exifRotationTag) Dim orientation As Integer = pi.Value(0) Select Case orientation Case 2 sysImage.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX) Case 3 sysImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone) Case 4 sysImage.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipY) Case 5 sysImage.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipX) Case 6 sysImage.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone) Case 7 sysImage.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipX) Case 8 sysImage.RotateFlip(System.Drawing.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