web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / add text and image to ...
Power Automate
Unanswered

add text and image to existing pdf in power automate desktop

(0) ShareShare
ReportReport
Posted on by 159

Hi,

I want to add text and image in existing pdf using power automate desktop

Tried many things but still its not working

 

tried power shell script

Set-Location C:\.nuget\packages\freespire.pdf\8.6.0\lib\net6.0\
[void] [Reflection.Assembly]::LoadFile("C:\.nuget\packages\freespire.pdf\8.6.0\lib\net6.0\Spire.Pdf.dll")


spire.pdf.pdfdocument

$pdfdocument = New-Object spire.pdf.pdfdocument
$ImagePage=New-Object spire.pdf.Graphics.PdfImage
$page=New-Object spire.pdf.PdfPageBase
$font=New-Object spire.pdf.Graphics.PdfFont
$brush=New-Object spire.pdf.Graphics.PdfSolidBrush
$pdfdocument.LoadFromFile("C:\Downloads\ESS time entry\example.pdf")
$NumberofPages=$pdfdocument.Pages.Count
$page = $pdfdocument.Pages(0)
$ImagePage=$ImagePage.PdfImage.FromFile("C:\Downloads\ESS time entry\New Bitmap Image.bmp")
$page.Canvas.DrawString("abcdef", font, brush, 15, 25)

 

but nothing works

 

can anyone please help

 

Thanks

Neeraj

I have the same question (0)
  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @neerajpokh 

     

    Thank you for bringing this question to our community forum. I truly appreciate the opportunity to delve into such an out-of-the-box topic. It was a thoroughly enjoyable experience crafting solutions for it.

    I managed to accomplish this using .NET scripts.

     

    Full flow screenshot:

    Deenuji_2-1709652582172.png

     

    Assembly reference:

    Deenuji_3-1709652688238.png

     

    .Net Script Configuration:

    Deenuji_4-1709652731206.png

    Parameters:

    Deenuji_5-1709652776536.png

     

    Results:

    Deenuji_0-1709652431947.png

    Deenuji_1-1709652503932.png

    Code:

    SET InputFilePath TO $'''C:\\Users\\Documents\\PAD_Document.pdf'''
    SET OutputFilePath TO $'''C:\\Users\\Downloads\\Output_result.pdf'''
    SET Append_Text TO $'''Hello!! This is deenu from PAD community!!'''
    SET Image_Path TO $'''C:\\Deenu\\PAD_Image.jpg'''
    Scripting.RunDotNetScript Imports: $'''iTextSharp.text
    iTextSharp.text.pdf''' Language: System.DotNetActionLanguageType.CSharp ReferenceRootPath: $'''C:\\Deenu\\Assemblies''' Script: $'''
    // Create a reader for the input PDF
    using (var reader = new PdfReader(inputPdfFilePath))
    {
    // Create a stamper for adding content to the input PDF
    using (var stamper = new PdfStamper(reader, new FileStream(outputPdfFilePath, FileMode.Create)))
    {
    // Iterate through the pages of the PDF
    for (int i = 1; i <= reader.NumberOfPages; i++)
    {
    // Get the content byte array for the current page
    PdfContentByte content = stamper.GetOverContent(i);

    // Example: Add text

    content.BeginText();
    content.SetFontAndSize(BaseFont.CreateFont(), 12);
    content.SetTextMatrix(100, 50); // Set position
    content.ShowText(text);
    content.EndText();

    // Example: Add image

    Image image = Image.GetInstance(imagePath);
    image.SetAbsolutePosition(100, 100); // Set position
    content.AddImage(image);
    }
    }
    }''' @'name:inputPdfFilePath': InputFilePath @'type:inputPdfFilePath': $'''String''' @'direction:inputPdfFilePath': $'''In''' @'name:text': Append_Text @'type:text': $'''String''' @'direction:text': $'''In''' @'name:imagePath': Image_Path @'type:imagePath': $'''String''' @'direction:imagePath': $'''In''' @'name:outputPdfFilePath': OutputFilePath @'type:outputPdfFilePath': $'''String''' @'direction:outputPdfFilePath': $'''In'''

     

     

     

    ------------------------------------------------------------------------------------------------------------------------

     

    If I've resolved your query, please consider accepting it as the solution and giving it a thumbs up to help others find answers faster.

     

     

  • neerajpokh Profile Picture
    159 on at

    Hi @Deenuji 

    tried the same code but its not working for me

    neerajpokh_0-1709662126013.png

     

     

     

    neerajpokh_1-1709662169174.png

     

     

    throwing error

    neerajpokh_2-1709662242945.png

     

     

    neerajpokh_3-1709662337306.png

    please help

  • neerajpokh Profile Picture
    159 on at

    Hi @Deenuji 

    output file is also not opening

    neerajpokh_4-1709664318690.png

     

  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @neerajpokh 

    Please use version 5.5.13.3

    Deenuji_0-1709693093004.png

    My recommendation is to initially try the code in a Visual Studio console application. This way, we can properly identify all the dependencies before integrating the code with PAD.

     

     

  • neerajpokh Profile Picture
    159 on at

    Hi @Deenuji 

    thank you so much it works for me

  • neerajpokh Profile Picture
    159 on at

    Hi @Deenuji

    is it possible to find particular text and get x and y coordinates for that text

     

    Like - 

    neerajpokh_0-1710169555157.png

     

    want to find x and y coordinates for that highlighted text in pdf.

    Please help

    Thanks

    Neeraj

  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @neerajpokh 
    In my perspective, I believe it's possible, but I would greatly appreciate it if you could initiate a discussion on this topic.

  • neerajpokh Profile Picture
    159 on at

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard