0

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

A4twoside

Sample Image

ExportedBusinessCard0

Desired output

Desired output

2
  • You need to iterate over the images by number; let us call the iterator i. The x-position will be (i mod 2) * columnWidth + leftMargin and the y-position will be i \ 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. Commented Dec 13, 2024 at 17:04
  • @AndrewMorton , Thank you for your reply and can you answer as an answer Commented Dec 14, 2024 at 2:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.