Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Use SVGDocument as the main entry point for basic SVG operations in Python. Create or load an SVG document, inspect the DOM, edit elements and attributes, save the result as SVG, or pass the document to conversion APIs when you need PDF, PNG, or another output format.
Aspose.SVG for Python via .NET provides a DOM-based API for common SVG document tasks. These operations are the foundation for most workflows: creating SVG files, loading existing documents, adding or updating elements, inspecting document structure, finding nodes with selectors, and saving the result.
This section is a hub for the core document workflows. Use it to choose the article that matches your task, then move to the focused how-to page for complete Python examples.
A typical Python workflow starts with SVGDocument. You create or load the document, access the root <svg> element, find or create nodes, update attributes, and save the document. If the target output is not SVG, continue with the conversion APIs.
| Workflow stage | Main API | Related article |
|---|---|---|
| Create or load | SVGDocument | Create SVG File |
| Inspect structure | outer_html, get_elements_by_tag_name() | Navigate SVG |
| Find target elements | query_selector(), query_selector_all(), evaluate() | Navigate SVG |
| Read or update attributes | get_attribute(), set_attribute(), has_attribute(), remove_attribute() | Work with SVG Attributes |
| Edit content | create_element_ns(), set_attribute(), append_child() | Edit SVG File |
| Save as SVG | SVGDocument.save() | Save SVG File |
| Export to another format | Converter.convert_svg() | Convert SVG Files in Python |
Use SVGDocument.save() when you want to keep the document as SVG. Use conversion APIs when you need a different output format such as PDF, PNG, JPG, BMP, TIFF, GIF, or XPS. This distinction matters because saving preserves SVG markup, while conversion renders or exports the document to another format.
For export workflows, see Convert SVG Files in Python, Convert SVG to PDF in Python, and Convert SVG to PNG in Python.
Aspose.SVG also provides free online SVG applications for quick tasks such as conversion, image vectorization, SVG merging, sprite generation, SVG to Base64 encoding, and text vectorization. Use them to test a workflow before implementing it in Python.
SVGDocument is the main class for creating, loading, navigating, editing, and saving SVG documents.
Use SVGDocument() to create a blank document, SVGDocument(svg_content, base_uri) for SVG markup stored in memory, or SVGDocument(path_or_url) for an existing SVG file or URL.
Find or create SVG elements, update attributes with set_attribute(), add nodes with DOM methods, and save the document with SVGDocument.save().
Use get_attribute(), set_attribute(), has_attribute(), and remove_attribute() on SVG elements, then save the edited document.
Use tag-name search, CSS selectors with query_selector() or query_selector_all(), or XPath queries with document.evaluate().
Save the document when the output should remain SVG. Convert it when you need PDF, PNG, JPG, or another non-SVG output format.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.