I want to know if is possible to duplicate/copy the same image in the same PDF with the libraries iTextSharp.
I already have the image to duplicate and generate its not a problem but when I copy it (with a for cicle) the image doesn't copy but only moves to the new position.
Thanks a lot, Giovanni
Dim documento As New Document(PageSize.A4, MillimetersToPoints(10), MillimetersToPoints(10), MillimetersToPoints(10), MillimetersToPoints(10))
Dim filestream As New FileStream("C:\test.pdf", FileMode.Create, FileAccess.Write, FileShare.None)
Dim Scrittura As PdfWriter = PdfWriter.GetInstance(documento, FileStream)
Dim baseFont As BaseFont = baseFont.CreateFont(baseFont.HELVETICA_BOLD, baseFont.CP1252, baseFont.EMBEDDED)
Dim img As iTextSharp.text.Image
Dim DataEncoder As DataMatrix.net.DmtxImageEncoder
Dim DataEncodeOption As DataMatrix.net.DmtxImageEncoderOptions
Dim DataImg As System.Drawing.Image
Dim Databitmap As Bitmap
Dim BarcodeImage As Bitmap
DataEncoder = New DataMatrix.net.DmtxImageEncoder
DataEncodeOption = New DataMatrix.net.DmtxImageEncoderOptions
DataEncodeOption.SizeIdx = DataMatrix.net.DmtxSymbolSize.DmtxSymbol18x18
DataEncodeOption.Scheme = DataMatrix.net.DmtxScheme.DmtxSchemeAscii
DataEncodeOption.ModuleSize = 1
DataEncodeOption.MarginSize = 1
DataImg = DataEncoder.EncodeImage(My.Forms.AvvioProgramma.MyInfo.Progressivo, DataEncodeOption)
Databitmap = New Bitmap(DataImg)
BarcodeImage = Databitmap
BarcodeImage.Save("C:\prova.jpg")
img = Image.GetInstance("C:\prova.jpg")
documento.Open()
Dim contentByte As PdfContentByte = Scrittura.DirectContent
contentByte.BeginText()
contentByte.SetFontAndSize(baseFont, 12)
contentByte.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Tubotec", posXTitolo, posYTitolo, 0)
img.SetAbsolutePosition(posXDM, posYDM)
contentByte.AddImage(img)
contentByte.ShowTextAligned(PdfContentByte.ALIGN_LEFT, My.Forms.AvvioProgramma.MyInfo.Progressivo, posXPar, posYPar, 0)
contentByte.EndText()
documento.Close()