-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Iosu Sanchez
committed
May 18, 2021
1 parent
32ed8c2
commit 06cf669
Showing
11 changed files
with
33,247 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
This script removes UNREGISTERED watermark from a StarUML exported SVG | ||
and converts it to PDF | ||
""" | ||
import lxml.etree as ET | ||
from svglib.svglib import svg2rlg | ||
from reportlab.graphics import renderPDF | ||
import glob, os, shutil | ||
|
||
os.chdir("./svg") | ||
for file in glob.glob("*.svg"): | ||
output = file[:-4] + '.pdf' | ||
with open(file, 'r') as f: | ||
doc = ET.parse(f) | ||
for elem in doc.xpath("//*[local-name() = 'text' and text()='UNREGISTERED']"): | ||
if elem.attrib['fill'] == '#eeeeee' and elem.attrib['stroke'] == 'none' and elem.attrib['font-size'] == '24px': | ||
parent = elem.getparent() | ||
parent.remove(elem) | ||
tmp = ".tmp.svg" | ||
with open(tmp, 'wb') as f2: | ||
f2.write(ET.tostring(doc, pretty_print=True)) | ||
drawing = svg2rlg(tmp) | ||
renderPDF.drawToFile(drawing, output) | ||
os.remove(tmp) | ||
shutil.move(output, "../pdf/" + output) | ||
|
||
print(output + " rendered.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python3 watermark.py |