HTML to PDF keyword

Hi, I am trying Html to PDF with the following code:

Export The Statement As A PDF
Wait Until Element Is Visible CSS:.customer-statements-report-container
{soa_html}= Get Element Attribute CSS:.customer-statements-report-container outerHTML Html To Pdf {soa_html} {CURDIR}{/}soa.pdf

The PDF output is not as expected.

I am supposed to output the box in blue to PDF:

Hi @yewengehoe. I can look into this issue later today. Really sorry that it has taken this long to answer you…

Try this solution. You might need to tune the img width to match your page size. Tell me how it goes.

Screenshot    locator=CSS:.customer-statements-report-container   filename=statement.png
Html To Pdf  <img src='statement.png' width='480'/>  ${CURDIR}${/}soa.pdf

Certificate level 1: Html to PDF

Only names can be added.

Hi! Thanks for reporting. There is this issue that will get fixed sometime in the future:

1 Like

The PDF file is still wrong if I run the ready-made robot from the Beginners’ Course.

FYI: The PDF generation should work better now.

Hello Guys, I’m currently going thru first LVL training, trying to build “Marias helper” but while I get to PDF generation part I can’t see the created PDF, moreover I’m not able to poit-out the directorry where the PDF should be, what I notice in the log files is that output directorry for the PDF is different than the given as open from> code below:
KEYWORD RPA.PDF . Html To Pdf ${sales_results_html}, ${OUTPUT_DIR}${/}sales_results.pdf

Documentation: Generate a PDF file from HTML content.
Start / End / Elapsed: 20220223 15:26:15.824 / 20220223 15:26:15.983 / 00:00:00.159

15:26:15.826 INFO Writing output to file C:\Users\limpy\AppData\Local\robocorp\temp\4d65822107fcc4be\tmpckt5l_pm\sales_results.pdf
KEYWORD RPA.PDF . Open Pdf ${OUTPUT_DIR}${/}sales_results.pdf

Documentation: Open a PDF document for reading.
Start / End / Elapsed: 20220223 15:25:49.419 / 20220223 15:25:49.421 / 00:00:00.002

15:25:49.421 FAIL FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\limpy\AppData\Local\robocorp\temp\4d65822107fcc4be\tmprbm0zdf2\sales_results.pdf’

*** Keywords ***
ExportTableAsPDF
Wait Until Element Is Visible id:sales-results
${sales_results_html}= Get Element Attribute id:sales-results outerHTML
Html To Pdf ${sales_results_html} ${OUTPUT_DIR}${/}sales_results.pdf

*** Keywords ***
OpenCreatedPDF
Open Pdf ${OUTPUT_DIR}${/}sales_results.pdf

can You please explain or direct me, how & where should I point out where is the file robot should look for ? or what am I doing wrong that PDF doesn’t appear - Yes I have PDF installed on my PC

Hi @limpylemming,

Can you please copy and paste in or attach your conda.yaml and robot.yaml? Based on your error it looks like the output directory in the robot.yaml is being set to the temp folder for this run.

Best,
Tim

conda.yaml:
channels:

Define conda channels here.

  • conda-forge

dependencies:

Define conda packages here.

If available, always prefer the conda version of a package, installation will be faster and more efficient.

Search :: Anaconda.org

robot.yaml:
tasks:
Run all tasks:
shell: python -m robot --report NONE --outputdir output --logtitle “Task log” tasks.robot

Run Example task:
robotTaskName: Example Task

condaConfigFile: conda.yaml
artifactsDir: output
PATH:

  • .
    PYTHONPATH:
  • keywords
  • libraries
  • variables

ignoreFiles:

  • .gitignore

I can’t see anything pointing out storage area, I would be glad to know how to manipulate it

Hi Tim, I’ve already pasted requested data, can You take a look & adwise ?

Hi there! If it helps, here’s a tested working robot example of filling an HTML template and saving the output PDF in the ./output directory.
Please pay attention to how I run it with VSCode or rcc (rcc run -t "Unicode HTML To PDF") through my robot.yaml and preparing the env given the conda.yaml (ignore the commented sections).

Let us know how it goes!