pdf to image convert

Hi,

Please help me out for converting pdf to image,

Suppose if i have 4 pages of a pdf i want that 4 pages to be saved individually as image jpg/png format.

Thanks
 

Sachin_Kharmale

Active Member
Hi Ravikumar,

If you want to convert pdf files to image then you can do it with the help of python code.
write python code to convert pdf file to image and call it from blue prism code stage.


bellow python code will convert pdf to Image

Python:
import fitz
import sys

pdffile = "Your PDF File Path"
doc = fitz.open(pdffile)
page = doc.loadPage(0) #number of page

zoom_x = 2.0
zomm_y = 2.0
mat = fitz.Matrix(zoom_x, zomm_y)
pix = page.getPixmap(matrix = mat)

#pix = page.getPixmap()
output = "D:\OCR\Output\pdfImage.jpg"
#output =  sys.argv[2];
pix.writePNG(output)
print("Pdf Convert to Image")


I hope it will help you..!
 
Hi @Sachin_Kharmale

How to call python code with blueprism code stage?
Hi @Sachin_Kharmale,

i have tried with the given code, but i am getting some error. pls find the attachment.


Code:

String result="sa";
string ErrorMsg="";
bool isError=true;
try{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = Python_Executable_File_Path;//cmd is full path to python.exe
start.Arguments = Script_Path;

start.UseShellExecute = false;
start.RedirectStandardOutput = true;
using(Process process = Process.Start(start))
{
using(StreamReader reader = process.StandardOutput)
{
result = reader.ReadToEnd();

}
}
} catch (Exception exp) {
ErrorMsg=exp.Message;
isError=false;
}
Exception=ErrorMsg;
Success=isError;

ScriptOutput=result;



View attachment 1578160724194.png

View attachment 1578160857132.png


View attachment 1578160898609.png


View attachment 1578161151697.png
 

Sachin_Kharmale

Active Member
Hi @ravikumarj023 ,

For Error 1- Value to be stored in not compatible with the destination for output parameter 'Success'
You have taken Data Item for store result success make its data type to flag.


For rest of errors try to import namespaces on your object init page as mentioned in bellow screen shot.
View attachment 1578288012895.png


I hope it will help you.!
 

Kassia

New Member
Hello, maybe you can try converter tool, I have used Deli PDF Converter and I think this converter tool is very effective. In addition, if you just need to convert 4 pages, this tool is free to use, so I think you can have a try, here is the link, you can check if necessary.
 

windfondquist

New Member
Hi @Sachin_Kharmale,

i have tried with the given code, but i am getting some error. pls find the attachment.


Code:

String result="sa";
string ErrorMsg="";
bool isError=true;
try{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = Python_Executable_File_Path;//cmd is full path to python.exe
start.Arguments = Script_Path;

start.UseShellExecute = false;
start.RedirectStandardOutput = true;
using(Process process = Process.Start(start))
{
using(StreamReader reader = process.StandardOutput)
{
result = reader.ReadToEnd();

}
}
} catch (Exception exp) {
ErrorMsg=exp.Message;
isError=false;
}
Exception=ErrorMsg;
Success=isError;

ScriptOutput=result;



View attachment 5044

View attachment 5045


View attachment 5046

pdf converter
View attachment 5047
Hello. I am looking for software to edit a pdf/convert to word
Hopefully, it can edit/convert / allow a copy to clipboard of secure pdf files

Thanks in advance
 
Last edited:
Top