Hi all,
I’m trying to build a keyword which can convert a pdf file to a base 64 string. I’ve managed to get the PDF contents into the base64 encoder. But the evaluate expression is returning an error with all the pdf contects. The code I’m using so far:
*** Settings ***
Library Collections
Library DateTime
Library String
Library JSONLibrary
Library OperatingSystem
Library Process
Library BuiltIn
*** Keywords ***
Convert PDF File to Base64 string with filename
[Arguments] ${filename}
${pdf_file_path}= Set Variable ${CURDIR}\…\testdata\${filename}
${formattedfilepath}= Replace String ${pdf_file_path} \ /
${file}= Evaluate open(“${formattedfilepath}”, “rb”).read()
${encoded_string}= Evaluate base64.b64encode(${file}) modules=base64
Log ${encoded_string}
RETURN ${encoded_string}
*** Test Cases ***
TC01 - Base64test
Convert PDF File to Base64 string with filename Document-31757.pdf
Below is the error RF is returning:
Many thanks in advance,
Peter