These source code samples are assembled by their programming language and functions they apply. ByteScout Premium Suite is the bundle that includes twelve SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording. It can be applied to convert digital photos to pdf with pdf sdk using VB.NET.
The following code snippet for ByteScout Premium Suite works best when you need to quickly convert digital photos to pdf with pdf sdk in your VB.NET application. IF you want to implement the functionality, just copy and paste this code for VB.NET below into your code editor with your app, compile and run your application. Use of ByteScout Premium Suite in VB.NET is also described in the documentation included along with the product.
If you want to try other source code samples then the free trial version of ByteScout Premium Suite is available for download from our website. Just try other 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)
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
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
Get Your API Key
Explore Web API Docs
Explore Web API Samples
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
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: