Skip to content

Commit 4fc23fc

Browse files
author
okay
committed
[export] export to svg instead of pdf
1 parent d72cdfa commit 4fc23fc

File tree

2 files changed

+4
-47
lines changed

2 files changed

+4
-47
lines changed

tools/exportFromZip

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ done
244244
for f in "${tmpfolder}"/foreground*.svg; do
245245
# debug
246246
#cp -v "$f" ~/debug/"$(basename "$f")"
247-
sed -i "s/stroke-width\:[\.0-9]\+/stroke-width:${STROKE_WIDTH}/g;s/opacity\:[\.0-9]\+/opacity:${OPACITY}/g" "$f"
247+
sed "s/stroke-width\:[\.0-9]\+/stroke-width:${STROKE_WIDTH}/g;s/opacity\:[\.0-9]\+/opacity:${OPACITY}/g" "$f" > "$f.clean"
248248
[ ! $? -eq 0 ] && echo "Failed to reset stroke-width and opacity in '$f'" && exit 1
249249
done
250+
250251
# - optimize svg with svgo
251252
if command -v "svgo" > /dev/null; then
252253
for f in "${tmpfolder}"/foreground*.svg; do
@@ -255,48 +256,5 @@ if command -v "svgo" > /dev/null; then
255256
done
256257
fi
257258

258-
# Convert svg to pdf
259-
if command -v "inkscape" > /dev/null; then
260-
for f in "${tmpfolder}"/foreground*.svg; do
261-
inkscape "$f" -d 200 --export-pdf="${f%.svg}.pdf"
262-
[ ! $? -eq 0 ] && echo "Failed to convert to pdf via inkscape '$f'" && exit 1
263-
done
264-
pdftk "${tmpfolder}"/foreground*.pdf cat output "${tmpfolder}"/foreground.pdf
265-
[ ! $? -eq 0 ] && echo "Failed to merge inkscape pdfs" && exit 1
266-
elif command -v "rsvg-convert" > /dev/null; then
267-
rsvg-convert -a -f pdf "${tmpfolder}"/foreground*.svg -o "${tmpfolder}"/foreground.pdf
268-
[ ! $? -eq 0 ] && echo "Failed to convert to pdf via rsvg-convert" && exit 1
269-
else
270-
convert -density 100 "${tmpfolder}"/foreground*.svg -transparent white "${tmpfolder}"/foreground.pdf
271-
[ ! $? -eq 0 ] && echo "Failed to convert to pdf via convert" && exit 1
272-
fi
273-
274-
# Use multistamp instead of multibackground to preserve transparency
275-
pdftk "${tmpfolder}"/background.pdf multistamp "${tmpfolder}"/foreground.pdf output "${filename}.pdf"
276-
[ ! $? -eq 0 ] && echo "Failed to merge background and foreground pdfs" && exit 1
277-
278-
filesize=$(ls -la "${filename}.pdf" | awk '{print $5}' | numfmt --to=iec-i --suffix=B --format="%.3f")
279-
280-
echo "Written ${filesize} to ${filename}.pdf"
281-
282-
if [ -z $KEEP_TEMPDIR ]; then
283-
rm -Rf "${tmpfolder}"
284-
else
285-
echo "Left temporary dir '${tmpfolder}'"
286-
fi
287-
288-
if [ -n "$ASK_RENAME" ]; then
289-
xdg-open "${filename}.pdf"
290-
[ -n "$OUTPUT_UUID" ] && echo "Last modified: ${DOCUMENTS_DATES[$OUTPUT_UUID]}"
291-
echo
292-
read -rp "New name w/o extension, '!rm' to delete '${filename}.{pdf,tar.gz}', Enter to skip: " NEWFILENAME
293-
echo
294-
if [ -n "$NEWFILENAME" ]; then
295-
if [ "$NEWFILENAME" == "!rm" ]; then
296-
rm -v "${filename}.pdf" "${filename}.tar.gz"
297-
else
298-
mv -vi "${filename}.pdf" "${NEWFILENAME}.pdf"
299-
mv -vi "${filename}.tar.gz" "${NEWFILENAME}.tar.gz"
300-
fi
301-
fi
302-
fi
259+
mkdir -p "${filename}" 2>/dev/null
260+
cp "${tmpfolder}"/foreground*.svg "${filename}"

tools/rM2svg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import re
1818
__prog_name__ = "rm2svg"
1919
__version__ = "0.0.2.1"
2020

21-
2221
# Size
2322
default_x_width = 1404
2423
default_y_width = 1872

0 commit comments

Comments
 (0)