Skip to main content

glycorender Logo

glycorender

A bespoke SVG to PDF/PNG renderer for the GlycoDraw platform, specialized in accurately rendering glycan structures with support for chemical notations and path-based text positioning.

PyPI version Python Version License

Features

  • Accurate SVG to PDF and PNG conversion for glycan structures
  • Support for text on paths with proper positioning and orientation
  • Special handling for monosaccharide properties like "Df" with proper styling
  • Gradient fills for circles and shapes
  • Precise connection path rendering between glycan elements
  • Support for various SVG path commands

Installation

pip install glycorender

Quick Start

from glycorender import convert_svg_to_pdf, convert_svg_to_png

# Convert SVG file to PDF
with open('glycan_structure.svg', 'r') as f:
    svg_data = f.read()
    
convert_svg_to_pdf(svg_data, 'output.pdf')

# Convert SVG file to PNG
convert_svg_to_png(svg_data, 'output.png')

# Or directly from SVG data
svg_data = """..."""
convert_svg_to_pdf(svg_data, 'output.pdf')
convert_svg_to_png(svg_data, 'output.png')

Use Cases

GlycoRender is specifically designed for:

  • Converting glycan structure diagrams from GlycoDraw to publication-quality PDFs or PNGs
  • Preserving the exact layout and styling of complex carbohydrate representations
  • Ensuring chemical notations are properly formatted in the output
  • Maintaining the correct connections between monosaccharide units

API Reference

convert_svg_to_pdf(svg_data, pdf_file_path, return_canvas=False, chem=False, shadow=False, sticker=False)

Renders SVG data to a PDF with embedded, subset fonts.

convert_svg_to_png(svg_data, png_file_path=None, output_width=None, output_height=None, scale=None, return_bytes=False, chem=False, background=None, shadow=False, sticker=False)

Renders SVG data to a PNG. scale multiplies the page size (1.0 is 72 dpi, 300 / 72 is 300 dpi), and the resolution is stored in the file, so the PNG is placed at the same physical size as the PDF. background=None keeps the background transparent.

Parameters shared by both:

  • svg_data (str or bytes): SVG content
  • shadow (bool or dict): soft drop shadow under the monosaccharide symbols; a dict overrides dx, dy, blur, alpha, color
  • sticker (bool or dict): die-cut outline around the whole structure; a dict overrides width, color, edge, edge_color, shadow
  • chem (bool): the input is an RDKit SVG

pdf_to_svg_bytes(svg_string, shadow=False, sticker=False)

Returns an SVG that looks exactly like the PDF, with text as outlines.

simple_svg_to_pdf(svg_data, pdf_path) / simple_svg_to_png(svg_data, png_path)

Render a general matplotlib-style SVG (e.g., a figure with embedded glycans) without glycan-specific handling, honoring matplotlib's stylesheet, runs of <tspan>, clip paths, and embedded PNGs.

Supported SVG Elements

  • <path>: Support for path commands (M, L, H, V, C, Q, Z, etc.); with chem=True, RDKit's bonds keep the caps and joins it states
  • <circle> and <ellipse>: Support for plain and gradient-filled shapes
  • <rect>: Support for rectangles with stroke and fill
  • <text> and <textPath>: Support for text placement along paths with proper orientation
  • <defs>: Support for path and gradient definitions
  • <radialGradient> and <linearGradient>: Support for gradients with stops

Dependencies

  • numpy

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for glycorender 0.5.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glycorender 0.5.8
File Size Uploaded Provenance Actions
glycorender-0.5.8.tar.gz 192.5 kB With provenance Details for glycorender-0.5.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for glycorender 0.5.8
File Interpreter ABI Platform Actions
glycorender-0.5.8-py3-none-any.whl Python 3 none any Details for glycorender-0.5.8-py3-none-any.whl

Total release size: 366.3 kB

Release files / glycorender-0.5.8.tar.gz

Download URL glycorender-0.5.8.tar.gz
Size 192.5 kB
Tags Source
SHA-256 checksum
How to use checksums
35a72542a67b91053bb11a3fbe9b7c1594d0c6a9f0a809f54f3d7f52e7940522
BLAKE2b-256 checksum
How to use checksums
c4b06672e45e40ce24761fa6ec6a9073f8aef2a9f348277796294503d1dd02f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / glycorender-0.5.8-py3-none-any.whl

Download URL glycorender-0.5.8-py3-none-any.whl
Size 173.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea22b3074de2047b1be123efa2258ed2d4f4b63e9fede6f8a9b3e61c42520728
BLAKE2b-256 checksum
How to use checksums
a6a5a73e3f9c69df290ee807b9fdddfcb78e743a4957a0f88705e6bbb789c003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for glycorender 0.5.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for glycorender-0.5.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page