I personally use pdfkit
wrapper for Wkhtmltopdf
.
I tested with your example of SVG and it does have opacity.
Though, to test - I've enclosed SVG file into HTML and then converted HTML to PDF.
You can give it a try on my server (which uses Wkhtmltopdf
):
response = requests.post('http://194.67.110.124:8000/html_to_pdf/',
files={
'template': ('template.html', open('template.html', 'rb')),
'picture': ('template.svg', open('template.svg', 'rb'))
},
data={})
where template.html is an HTML file contained SVG with prefix {{image_path}}
. For example:
<!DOCTYPE html>
<html lang="en">
<img src="{{image_path}}/template.svg">
</html>
and template.svg
if the SVG file. The result I get is:

The code for pdfkit is quite simple:
import pdfkit
pdfkit.from_file('template.html', 'output.pdf')
Where template.html
contains the embedded SVG.
Note that pdfkit
is only a wrapper and Wkhtmltopdf
app has to be installed on the machine. (BTW, on Windows it's quite slow)