PDF page rotation without using UI

Hi guys,

I have searched a lot but failed to know how to rotate PDF page. I just want to rotate a single page pdf to 90 degrees to the left. Is there a UiPath solution for this?

Hi @iamthejuan,

Pls try this solution.let me know if you have any issue.

image

@You can try with another way if you know dotnet invoke code activity.Below is the reference site
https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/Page-Setting/How-to-rotate-the-PDF-file-in-C.html

Regards,
Omkar P

1 Like

Thank you @Reddy_Paluri, I want to try the invoke code, I just don’t know exactly what package should I download in UiPath to make it work.

@iamthejuan,

pls try below steps before invoke code activity

ItextSharp library it is open sources


I believe first add below namespaces also

Regards,
Omkar P

1 Like

Hi @Reddy_Paluri,

I’m encountering this error even for line one, bot for CSharp and VB.Net.

pls add namespace and type manually no copy paste.


Hi @Reddy_Paluri,

I’m not sure if I’m doing it wrong, I’m still getting an error.

Hi @iamthejuan,

pls find attached xaml for your requirement.If you have any issue let me know.
@above solution not working for you i tried new and simple way it is working fine.Pls follow steps
1)Install iText7 Community
2)Import namespace.
3)Inside Invoke code pls provide your input and output folder path.
iText.Kernel.Pdf;



pdf rotation.xaml (5.1 KB)

Regards,
Omkar P

6 Likes

Wow! Thank you @Reddy_Paluri, it worked! I no longer need to use third party tool to rotate the PDF. Thank you for the effort! :slightly_smiling_face:

Hi there,

Imported the namespace. Getting this error

Hi Rahul,

Make sure you opted for C#.

@iamthejuan

Thanks, I forgot to change the type while creating a new file.

It is working fine. Thanks!

1 Like

This is awesome. :slightly_smiling_face:

Just a little query. I checked the same code with three differently rotated PDF. It worked fine for all 3 and gave me the correct layout after rotation. Not into coding much but the default angle in the code was 270. Can you please explain that part of code if possible, how just 270 degree rotation is working fine for all.

Hi @alpharobot,

Welcome to Uipath Forum :smiley:

The default rotation is 0 you need to pass 90 or 180 or 270 it will rotate clockwise based on our rotation degree.

Code Explanation:

1)First 2 lines of code is input and out folder path
2)3 line is user input the rotation of pdf(90or180or 270)
3)4 line pdf document object we need to pass input and output it will read input pdf and write into new pdf
4)6-16 line we need get all number of pages and get page by page number
5)it will execute always else part
6)finally we need to close document object.

if you have any knowledge on Dot net you can copy and paste in to visual studio and debug for your better understanding or here uipath studio code editor put mouse over each part of line you will know the information why we need to use of this line.

Regards,
Omkar P

2 Likes

Hi @iamthejuan,

If it is working fine please mark it as solution.Still if you have any issues let me know.

Regards,
Omkar P

1 Like

Thanks for this, it was helpful!

1 Like

Welcome :smiley:

2 Likes

Hi @Reddy_Paluri

Hope you are doing great!

Sorry again for the trouble but can this code be edited so as to rotate the same copy of the PDF and not create a new one instead.

Many thanks in advance.

Hi @alpharobot,

If you have any issues please reach us no trouble :smiley:

You can edit this code no issues as per your requirement.I think we cant do same copy of the pdf instead of new one because it will through error like object reference set an instance or pdf document error will through.

I am assuming not sure i d’nt try.If you have old copy try to delete.

Regards,
Omkar P

1 Like

Thanks @Reddy_Paluri for the kindness.

I have tried to alter the code but no luck. I need to rotate the same PDF without creating a new one.

I even tried to keeping the input and output file name same but the activity failed and it ends up creating a new one.