I'm Trying to export merge multi image to one page two sides (2 by 5) in A4 size output in VB.NET. So the total image is 10 in 1 A4 page
Please Guide Me
Thanks
Imports System.IO
Public Class Form1
Private PATH As String = Directory.GetCurrentDirectory()
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim img1 As Image = Image.FromFile(PATH & "\ExportedBusinessCard0.png")
Dim img2 As Image = Image.FromFile(PATH & "\ExportedBusinessCard0.png")
Dim b As Bitmap = MergeImages(img1, img2, 10)
End Sub
Private Function MergeImages(ByVal image1 As Image, ByVal image2 As Image, ByVal space As Integer) As Bitmap
Dim bitmap As New Bitmap(image1.Width + image2.Width + space, Math.Max(image1.Height, image2.Height))
Using g As Graphics = Graphics.FromImage(bitmap)
g.Clear(Color.White)
g.DrawImage(image1, 0, 0)
g.DrawImage(image2, image1.Width + space, 0)
End Using
Dim img As Image = bitmap
img.Save(PATH & "\A4twoside.jpg")
Return bitmap
End Function
End Class
Result from code
Sample Image
Desired output



(i mod 2) * columnWidth + leftMarginand the y-position will bei \ 5 * rowHeight + topMargin. A backslash does integer division in VB.NET. I recommend using pencil and paper to work out how to also include padding.