Reputation: 527
I'm wrinting a Jenkins job with the help of shell script to export a page in Confluence as PDF and store it as output after the build. How can I achieve that ?
Upvotes: 0
Views: 1936
Reputation: 527
Finally foud a solution :
curl -D- -u user:password -X GET -H "Content-Type: application/json" "<confluence_ url>/spaces/flyingpdf/pdfpageexport.action?pageId=123456789" > curl_ouput.txt
## Read response and extract URL for downloading file
FILE_LOCATION=$(grep "Location: " curl_ouput.txt | sed 's/Location: //g')
## Remove newline character at the end of the url
FILE_LOCATION=${FILE_LOCATION%?}
## Download PDF file
curl -D- -u user:password -X GET -H "Content-Type: text/html;charset=UTF-8" <confluence_url>${FILE_LOCATION} --output fileName.pdf
rm -f curl_ouput.txt
Upvotes: 1
Reputation: 31
Use wkhtmltopdf to perform the conversion from html to pdf.
You can also convert an existing website to PDF
$wkhtmltopdf https://wiki.jenkins.io/display/JENKINS/Confluence+Publisher+Plugin#space-menu-link-content demo.pdf
Note: technically Google Chrome's rendering engine is Blink, which is a fork of Webkit. There is >90% of common code between Blink and Webkit, so you should get a similar result.
if your getting error
QXcbConnection: Could not connect to display
Aborted (core dumped)
try to install
sudo apt-get install xvfb
and then try this
xvfb-run wkhtmltopdf https://wiki.jenkins.io/display/JENKINS/Confluence+Publisher+Plugin#space-menu-link-content demo.pdf
Then you will find this pdf file as output in jenkins workspace.
Upvotes: 0