A Library is a package that contains multiple reusable components. Libraries are saved as
.nupkg files and can be installed as dependencies to workflows using Package Manager.
Creating a library is similar to Creating a Basic Process.
The difference is, packages are for creating reusable components to be used in the context of other projects.
Let us create a new custom library that can be used to convert files from one format to another format. Create a new Library called File_Conversion.
Once the UiPath Studio has opened, go to the Project pane and select the Rename option.
I am going to design a library where it is going to convert the PDF to Text format. So I am naming my new activity as
PDF to Text File
Next, you have to install the PDF package through Manage Packages. Go to the Manage Package and search for PDF activities under Official.
You will find UiPath.PDF.Activities, Select it and then click on the Install button
Once it is installed successfully, then click on Save and then accept the agreement.
Once the PDF activity has successfully installed, go to the UiPath Studio and drag and drop the Sequence and then add Read PDF Text activity inside the sequence.
The First activity which we are going to do here is to convert PDF to Text File, for that you don't need to create any content because this activity may be used in any other program or any other users. Instead of creating variables, create arguments which we are going to use to get input from the users or from other programs.
So let us create new arguments, the first one I need is an
inputpdffiles and the next one is
outputpath that means at which Path they wanted to save the text file, and the third one is
Enter the inputpdffiles inside the Read PDF Text activity and create a new variable in the variable pane for output property in the Properties Pane.
Add Write Text File activity inside the sequence and then enter the
outputpath argument and outputfilename argument, as shown below.
Now the contents of the PDF are read, and then the contents are transferred and written into the text file, this is how we are going to convert the content of PDF to Text.
As we do not have variables, we have arguments so we cannot be able to run the sequence; instead, we can publish this library and can be used in other programs.
Now, Save and click on the Publish tab on the Design Ribbon pane. Once the Publish Library wizard opened, click on the custom URL and select the Path (I have created the Libraries folder in the Documents folder) to save your file, and then click on Publish.
Once it is successfully published, you will receive the below message.
If you open your libraries folder, you can see a nupkg package that can be taken to any system so that we can use it for converting a PDF to a Text file.
Now let us go ahead and create a new process. I am creating a new process called Custom_Activity_Examples.
We have created a PDF Package, Now, go to the Manage Packages and then go to the settings and then add your package source inside the Manage Packages.
Click on Manage Packages, and then go to settings under Manage Packages and then click on the
+ symbol in the User Defined package sources.
After clicking on
+ symbol, give a name to package in the Name box and then enter the Path of your .nupkg file in the source box as shown below and then click on Add
After adding, you can see your LocalPackages under Manage Packages.
Now click on File_Conversion and then click on the Install button, and also, you can see the dependencies which are available in this package.
After installing, click on the Save button and then accept the agreement.
Once the process has opened in the UiPath Studio, If you search for File conversion activity in the Activities pane, you will find it.
Next, add Sequence inside the Designer pane and then add PDF to Text File activity inside the sequence.
Click on the PDF to Text File and enter the inputpdffile name to convert it to the text file in Properties Pane. I have many PDF files, so I am taking those files to convert.
And also, enter the Output file name and the Path for the Output file in the Properties Pane.
Now, Save and Run the sequence; after the execution, the PDF file will be converted to Text format.
So we have successfully converted PDF files to the Text file.