Set correct dimensions on HPGL export

This commit is contained in:
Gijs 2024-03-29 10:17:28 +01:00
parent b81705d105
commit 64839e50bd

12
app.py
View File

@ -290,6 +290,16 @@ def catalogue():
#
# FIGLET 2 SVGBOB INTERACTIVE CATALOGUE
def resizeSVG (m):
width = int(m.group(1))
height = int(m.group(2))
viewbox = f'0 0 {width} {height}'
newHeight = 420
newWidth = (width/height) * newHeight
return f'<svg xmlns="http://www.w3.org/2000/svg" viewbox="{viewbox}" width="{newWidth}mm" height="{newHeight}mm" class="svgbob">'
@app.route('/hpgl/<id>')
def hpgl (id):
@ -309,6 +319,8 @@ def hpgl (id):
svg = re.sub(r'\<rect class="backdrop" x="\d+" y="\d+" width="\d+" height="\d+">\<\/rect\>', '', svg, flags=re.M)
svg = re.sub(r'<svg xmlns="http://www.w3.org/2000/svg" width="(\d+)" height="(\d+)" class="svgbob">', resizeSVG,svg)
#print(svg)
# store as a temporary file