Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to include the stamp directly as a svg #6

Open
VincentWo opened this issue Apr 21, 2024 · 1 comment
Open

Add option to include the stamp directly as a svg #6

VincentWo opened this issue Apr 21, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@VincentWo
Copy link

Hi there,
I really love this template! I would like to have the possibility to directly include a stamp using the library without having to use external tools (especially since I am using typst in my browser and don't want to do the workflow of downloading the document, looking up the syntax, looking up the download place of the stamp, opening it again, print it...

I achieved this in a rather hacky way by putting place(top + left, image("stamp.svg")) into the background property at this line Would you be open to such an addition? (Obviously in a less hardcoded way)

@Sematre Sematre added the enhancement New feature or request label Apr 21, 2024
@Sematre
Copy link
Owner

Sematre commented Apr 21, 2024

I would love to have this option built-in. Unfortunately, I haven't found a good solution for this yet.

Deutsche Post only distributes stamps in the form of PDFs and as far as I can tell, the only sane way to process stamps from them is to use the DIN A4 Normalpapier (Einlegeblatt) format. That means the best solution would be for Typst to have a built-in function to overlay PDFs, just like you can do in LaTeX:

\usepackage{pdfoverlay}
\pdfoverlaySetPDF{TestPrint.pdf}

But since this is not possible (yet?), my idea is to have users be able to declare the stamp like this:

#show: letter-simple.with(
  // [...]
  stamp: image("TestPrint.svg"),
  // [...]
)

For that to work, you would first need to convert the PDF from Deutsche Post to an SVG. The best solution that I could find was the Inkscape CLI:

$ inkscape TestPrint.pdf -o TestPrint.svg

Now you're able to include the picture in Typst, just like you suggested. This is the resulting address box.
Letter_with_stamp

For comparison, here's the resulting address box using qpdf.
Letter_with_stamp_using_qpdf

Not a bad result, considering this is what the SVG version would look like in earlier Typst versions when I started this project.
Screenshot from 2024-04-22 01-33-05

Despite the result, I'm still kind of not satisfied with the SVG version. I'm open for any suggestions on this topic. I'm also attaching my benchmark stamp from Deutsche Post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants