Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG file from Google Presentation won't parse #306

Closed
tobyclh opened this issue Dec 24, 2021 · 4 comments
Closed

SVG file from Google Presentation won't parse #306

tobyclh opened this issue Dec 24, 2021 · 4 comments

Comments

@tobyclh
Copy link

tobyclh commented Dec 24, 2021

Hi

I have some files from exported from Google presentation that cannot be parse for some reason.

drawing = svg2rlg(args.input)

Log

    drawing = svg2rlg(args.input)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 1436, in svg2rlg
    drawing = svgRenderer.render(svg_root)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 544, in render
    main_group = self.renderSvg(node, outermost=True)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 819, in renderSvg
    self.renderNode(child, group)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 575, in renderNode
    item = self.renderG(n, clipping=clipping)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 853, in renderG
    item = self.renderNode(child, parent=gr)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 575, in renderNode
    item = self.renderG(n, clipping=clipping)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 853, in renderG
    item = self.renderNode(child, parent=gr)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 587, in renderNode
    item = self.renderG(n)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 853, in renderG
    item = self.renderNode(child, parent=gr)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 607, in renderNode
    item = self.shape_converter.convertShape(name, n, clipping)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 930, in convertShape
    shape = getattr(self, method_name)(node)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 1166, in convertPath
    xn, yn = points[-2] + nums[0], points[-1] + nums[1]
IndexError: list index out of range

Screenshot of the SVG

image

If I change
xn, yn = points[-2] + nums[0], points[-1] + nums[1]
to
xn, yn = points[-2] + nums[0], points[-1] + nums[-1]
it will parse but will produce an incorrect result.

Incorrect result

The middle image is offset a bit wrong somehow?
image

Link to the said SVG

@github-actions
Copy link

Thank you for raising your first issue! Your help to improve svglib is much appreciated!

@claudep
Copy link
Collaborator

claudep commented Dec 24, 2021

I cannot reproduce the error with svglib master. Can you tell us which version of svglib you are using?

@tobyclh
Copy link
Author

tobyclh commented Dec 24, 2021 via email

@tobyclh
Copy link
Author

tobyclh commented Dec 28, 2021

Upon building it from master the issue resolves.
Thank you!

@tobyclh tobyclh closed this as completed Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants