only produce the path element, not the whole file
See original GitHub issueI would like to embed the QR svg element produced by this library in my own svg producing software, and the only way I see to do that, is to write the file into a StringIO
, then extracting the element I need.
according to the docstring for QRCode.svg
,
If only the code itself is desired, set the xmldecl to false. This will result in a fragment that contains only the “drawn” portion of the code.
however, if I do that, I only get rid of the leading <?xml version="1.0" encoding="UTF-8"?>
, not also the root svg
element. I would like the naked path
element, and I would like it returned in a string, not written to a file.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to get only the last part of a path in Python?
Use os.path.normpath , then os.path.basename : >>> os.path.basename(os.path.normpath('/folderA/folderB/folderC/folderD/')) 'folderD'.
Read more >Paths - SVG: Scalable Vector Graphics - MDN Web Docs
The <path> element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves,...
Read more >Paths — SVG 2
A path is defined by including a 'path' element on which the d property specifies the path data. The path data contains the...
Read more >Path Operations - Essential Java Classes - Oracle Help Center
A relative path cannot be constructed if only one of the paths includes a root element. If both paths include a root element,...
Read more >Maximum Path Length Limitation - Win32 apps | Microsoft Learn
When using an API to create a directory, the specified path cannot be so long that you cannot append an 8.3 file name...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you use BytesIO, you’ll have to decode the value into the used encoding (default: UTF-8) before passing it into re.search / re.match
Omitting the SVG element isn’t possible. It’s possible to omit additionally the namespace delaration; this is useful if you want to embed the generated QR Code in HTML files.
Anyway, extracting the path should be trivial.
BTW, you don’t have to write to a file: