PDF page rotation without using UI

@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.

Hi @alpharobot,

In the 4 line pdf doc first it will read and write so at same time one file can’t do read and write.

You can delete old pdf for input folder.

Regards,
Omkar P

1 Like

Alright I will check on this.

Thanks for the help!

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