I have been using svglib for years. I am creating a new program whereas SVG files are inserted into a PDF file.
The SVG files are created in R package SVGLITE v2.0.0.
I am getting this error.
'lxml.etree._Element' object has no attribute 'ancestors'
Python simple code to include an SVG file in a PDF
`from lxml import etree
from reportlab.graphics import renderPDF
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
from reportlab.platypus import Image
from reportlab.lib import utils
import svglib
import string
from svglib.svglib import svg2rlg
def add_image(image_path, intInputRowNumber, intInputColumnNumber):
try:
print("DEBUG0001")
drawing = svg2rlg(image_path) # <======================= BOMBS OUT HERE
print("DEBUG0002")
drawing.transform = (0.25,0,0,0.25,0,0)
#
DEBUG0001
Render Error'lxml.etree._Element' object has no attribute 'ancestors'
DEBUG0001
Render Error'lxml.etree._Element' object has no attribute 'ancestors'
DEBUG0001
Render Error'lxml.etree._Element' object has no attribute 'ancestors'
DEBUG0001
DEBUG0002
DEBUG0003
DEBUG0004
Normal Render
foo1-3.svg are graphs. They bomb out. ""No-Image-Available.svg" is a simple file. It inserts fine.
I'm gonna guess and say that SVGLITE is creating SVG files that svglib does not like.
Hello,
I have been using svglib for years. I am creating a new program whereas SVG files are inserted into a PDF file.
The SVG files are created in R package SVGLITE v2.0.0.
I am getting this error.
'lxml.etree._Element' object has no attribute 'ancestors'
Python simple code to include an SVG file in a PDF
`from lxml import etree from reportlab.graphics import renderPDF from reportlab.pdfgen import canvas from reportlab.lib.units import inch from reportlab.platypus import Image from reportlab.lib import utils import svglib import string from svglib.svglib import svg2rlg
def add_image(image_path, intInputRowNumber, intInputColumnNumber):
try: print("DEBUG0001") drawing = svg2rlg(image_path) # <======================= BOMBS OUT HERE print("DEBUG0002") drawing.transform = (0.25,0,0,0.25,0,0) #
Header Row
my_canvas = canvas.Canvas("lou.pdf") my_canvas.setPageSize((11.5inch, 40inch)) add_image("foo1.svg", 1, 1) add_image("foo2.svg", 1, 2) add_image("foo3.svg", 1, 3) add_image("No-Image-Available.svg", 1, 4) my_canvas.save()`
When I run this I get the following:
DEBUG0001 Render Error'lxml.etree._Element' object has no attribute 'ancestors' DEBUG0001 Render Error'lxml.etree._Element' object has no attribute 'ancestors' DEBUG0001 Render Error'lxml.etree._Element' object has no attribute 'ancestors' DEBUG0001 DEBUG0002 DEBUG0003 DEBUG0004 Normal Render
foo1-3.svg are graphs. They bomb out. ""No-Image-Available.svg" is a simple file. It inserts fine.
I'm gonna guess and say that SVGLITE is creating SVG files that svglib does not like.
Any ideas.
Thanks,
Lou