PdfReadError: Unable to find 'endstream' marker after stream at byte 0x2057

Hello! I’m trying to finish Certificate level II: Build a robot but I have an issue with which I’m struggling and have no idea how to solve it. :tired_face:

I get “PdfReadError: Unable to find ‘endstream’ marker after stream at byte 0x2057” error.

I will be grateful for any advice on how to handle this.

here is my conda:

channels:
- conda-forge
dependencies:
- python=3.7.5
- pip=20.1
- numpy=1.20.3
- pip:
  - rpaframework==12.1.0
  - robotframework-datadriver==1.4.1

Settings

*** Settings ***
Documentation     Orders robots from RobotSpareBin Industries Inc.
...               Saves the order HTML receipt as a PDF file.
...               Saves the screenshot of the ordered robot.
...               Embeds the screenshot of the robot to the PDF receipt.
...               Creates ZIP archive of the receipts and the images.

Resource          Keywords.robot
Library           RPA.Browser.Selenium
Library           RPA.Excel.Files
Library           RPA.HTTP
Library           RPA.Tables
Library           RPA.PDF
Library           RPA.Archive
Library           RPA.Dialogs
Library           RPA.Robocloud.Secrets```



*** Keywords ***
Get the URL and Open the robot order website
${url}= Get Secret website
Open Available Browser ${url}[url]
Maximize Browser Window

Add text input    url    label=input CSV URL
${response}=      Run dialog

[Return]    ${response.url}

Get orders
[Arguments] ${CSV_URL}

Download      ${CSV_URL}             overwrite=True
${orders}=    Read table from CSV    orders.csv    header=True

[Return]    ${orders}

Close the annoying modal
Click Button OK

Fill the form
[Arguments] ${rows}
${head}= Convert To Integer ${rows}[Head]
${body}= Convert To Integer ${rows}[Body]
${legs}= Convert To Integer ${rows}[Legs]
${address}= Convert To String ${rows}[Address]
Select From List By Value id:head ${head}
Click Element id-body-${body}
Input Text id:address ${address}
Input Text xpath:/html/body/div/div/div[1]/div/div[1]/form/div[3]/input ${legs}

Preview the robot
Click Element id:preview
Wait Until Element Is Visible id:robot-preview

Submit the order
Wait Until Keyword Succeeds ${GLOBAL_RETRY_AMOUNT} ${GLOBAL_RETRY_INTERVAL} Submit the order And Keep Checking Until Success

Submit the order And Keep Checking Until Success
Click Element order
Element Should Be Visible xpath://div[@id=“receipt”]/p[1]
Element Should Be Visible id:order-completion

Store the receipt as a PDF file
[Arguments] ${order_number}

${receipt_html}=      Get Element Attribute    receipt    outerHTML
Set Local Variable    ${file_path}             ${receipt_folder}/${order_number}.pdf
Html To Pdf           ${receipt_html}          ${file_path}

[Return]    ${file_path}

Take a screenshot of the robot
[Arguments] ${order_number}
Screenshot id:robot-preview ${CURDIR}${/}output${/}${order_number}.png
[Return] ${CURDIR}${/}output${/}${order_number}.png

Embed the robot screenshot to the receipt PDF file

[Arguments] ${screenshot} ${pdf}
Open Pdf ${pdf}
Add Watermark Image To Pdf ${screenshot} ${pdf}
Close Pdf ${pdf}

Go to order another robot
Click Button order-another

Create a ZIP file of the receipts
Archive Folder With Zip ${CURDIR}${/}output${/}receipts ${CURDIR}${/}output${/}receipt.zip```

Hi Paulina,

My first guess would be that this error is related to how you are passing in the arguments to the Add Watermark Image to Pdf keyword. If you look at the robotframework example provided on this page: RPA.PDF library keywords you will see that “image_path=” and “source_path=” are declared before passing the paths. Since I can’t see your Tasks section I’m not 100% sure how your arguments are being passed so apologies if you are already passing them in correctly.

Lastly, another possibility that you may want to explore in the documentation is that there may be a better keyword to use as well as reviewing the notes on all of the keywords you are using. I believe you are very close and the a review of the doc pages will reveal the answer :slight_smile:

I hope this helps!

Best,
Tim

1 Like

Hi! You can also try updating rpaframework to version 12.2.0 (there is a fix regarding the Add Watermark Image To Pdf keyword).

https://rpaframework.org/releasenotes.html

1 Like

Hi Tim! Thanks a lot for the hints! I made some changes according to your guidance and it works. Thanks again!

2 Likes