How to Merge Multiple PDF files in Single Pdf in BluePrism

kaushal

New Member
Hi Team,

Can someone help me to get merge multiple PDF files in single pdf file. I just want to know is any option available in Blue Prism to merge it.
Your support and response will be highly appreciated and helpful to me. Thanks in advance.

Regards-
Kaushal
 

Sachin_Kharmale

Active Member
Hi @kaushal ,

If you want to merge multiple pdf into single pdf with Blue Prism.
1.You need to convert pdf file pages into images. Once you convert all pdf file pages into images and stored in output directory.
2.Then you need to combine all images present in output Directory and merge into single pdf file.


for above task you need to write python code. with the help of python code you can merge multiple pdf into single pdf.
use bellow python script to merge pdf.


Python:
import fitz
import sys
import glob
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
imagelist = []
FileList=glob.glob("D:\PY\MultiplePDFTOSinglePDF\Input\*.pdf")
count=0
for file in FileList:
        doc = fitz.open(file)
        for i in range(doc.pageCount):
            page = doc.loadPage(i) #number of page
            zoom_x = 2.0
            zomm_y = 2.0
            mat = fitz.Matrix(zoom_x, zomm_y)
            pix = page.getPixmap(matrix = mat)
            
            output = "D:\PY\MultiplePDFTOSinglePDF\OutputImages\PDFImage"+str(count)+".jpg"
            count=count+1
            pix.writePNG(output)
            print("Extarct image from pdf and stored on : "+output)
ImageFileList=glob.glob("D:\PY\MultiplePDFTOSinglePDF\OutputImages\*.jpg")
for imagefile in ImageFileList:
    image1 = Image.open(imagefile)
    im1 = image1.convert('RGB')
    imagelist.append(im1)
imagelist.pop()  
im1.save("D:\\PY\\MultiplePDFTOSinglePDF\\"+"Multiple.pdf",save_all=True, append_images=imagelist)

Then you need to call above python script from Blue Prism.
For invoking python script from blue prism refer bellow post.
https://www.rpaforum.net/threads/ml-integration-with-blue-prism.8021/#post-27097


I hope it will help you..!
 
Top