Hi, I used GeneratePDF extension in order for me to place the image into the PDF and able to set different position within the PDF file. Unfortunately, due to the latest UiPath studio version it will not allow any Legacy version to be used. Is there a way where I can have the similar function to replace the legacy version of GeneratePDF?
You can use this workaround as of now.
But for my requirement the drawings are in PDF format and not in Word. If I use the solution that you mentioned I need to convert to Word and after image is added then convert back to PDF again. I want the image to insert directly into the PDF and able to set different position via coordinates.
Hi @dvkc91
As this activity only support the legecy project. You can replicate the same by using invoke code/ Invoke VBA activity, You need to write a code in VBA something like this by calling this code & providing the image & pdf path it can be done.
Sub AddImageToPDF()
Dim pdfReader As Object
Dim pdfStamper As Object
Dim pdfContentByte As Object
Dim img As Object
Dim imgPath As String
Dim pdfPath As String
Dim outputPath As String
' Paths to the input PDF, image, and output PDF
pdfPath = "C:\path\to\input.pdf"
imgPath = "C:\path\to\image.jpg"
outputPath = "C:\path\to\output.pdf"
' Create iTextSharp objects
Set pdfReader = CreateObject("iTextSharp.text.pdf.PdfReader")
Set pdfStamper = CreateObject("iTextSharp.text.pdf.PdfStamper")
Set img = CreateObject("iTextSharp.text.Image")
' Open the PDF
pdfReader.Open pdfPath
pdfStamper.Create pdfReader, outputPath
' Get the content byte layer
Set pdfContentByte = pdfStamper.GetOverContent(1)
' Load the image
Set img = img.GetInstance(imgPath)
' Set the image position and size
img.SetAbsolutePosition 100, 500
img.ScaleToFit 200, 200
' Add the image to the PDF
pdfContentByte.AddImage img
' Close the stamper and reader
pdfStamper.Close
pdfReader.Close
MsgBox "Image added to PDF successfully!"
End Sub
This code is AI Generated but you can improve on this.
Hope this helps
I am not familiar in writing code in VBA or C#. Could you provide a more detailed code information in order to fulfill the requirements as per my settings that I attached previously?
Is there any other solution for this issue? Appreciate if can propose more solution to check which is more suitable.
Hi All, I am in need of help for this issue. Would appreciate if you can suggest more solution.