How to write on in a PDF with Uipath?

I am looking for a way to write on a pdf in the upper right corner a text in UiPath.
So far I have not found a direct way to do it.
Does anyone know how to do it ?

Hi @Fabio_Villamil,

I don’t think there will be an activity for that. At least I’ve never seen one. What you probably will need to do is use a C# library such as PDF Sharp.

To use it inside UiPath you can use the Invoke Code activity.

There are a couple of examples on stackoverflow and other forums: c# 4.0 - PDFsharp edit a pdf file - Stack Overflow

Hi @Fabio_Villamil ,
Have you tried with type into operations with pdf editor
regards,

Do you know how to import that library to UiPath ?, so far i dont know how to do it but i think this could be the best option to dont use any UI interaction

I have a code snippet for it, combining 1-2 free to use pdf libraries and then invoking certain methods using invoke code. I use it to do the same, write some text in an existing pdf. In my use case, a footer text at the bottom of the document but it all comes down to the same thing. (You can use offset coordinates to place the text).

I don’t have direct access to this code example, and when I do I need to remove some sensitive elements for it first before I can post it here, but I’ll try and share it later, hopefully today if I don’t forget.

(And if I do PM me if you need in a day or so ;))

2 Likes

Went faster than I thought…

Get these two libraries. You can find them on nuget.org if I’m right.
image

Make sure you also import the namespaces.

This should make this code work.

AddFooterToPDF.xaml (11.3 KB)

This adds a watermark (aka the text) to each page except the first page.
2 arguments are used: the file path of the pdf and the text. Since it is a custom job you may want to add more parameters regarding font, color, pages or position.
So for your purposes you’ll need to customize the code in order to fit your needs.

Disclaimer: the watermark might not always be visible, depending on the layering. (So if the pdf contains other objects which get a larger z-index). I never bothered to look into that further, since this watermark feature was more of a nice to have gimmick than a must-have project requirement. I’m sure there are some code wizards who can build upon this further.

First of all, thank you so much for take from your time to answer, second im gonna test it and whatever question that i have i will let you know

I downloaded the bot file nuget packages and put in the next path

C:\Users\Usuario\AppData\Local\Programs\UiPath\Studio\Packages
But show this issue, its not compatible with Windows Project, any idea how to solve this?

Hmm… you may need to convert it.
You could open it in a temporary legacy project first, and then see if you can migrate it to windows and see if it works. You then might also need those 2 packages to be upgraded to windows compatible couterparts.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.