You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Transparency of translucent gradients in PDF images is ignored #7269
bugSomething isn't workingpdfRelated to PDF export or PDF embedding.visualizeRelated to the visualize category, which is about drawing and illustrating
I have a PDF figure with a translucent gradient (translucent-gradient.pdf) that I'm using in a Typst document. The rendered PDF ignores the transparency of the gradient in the source PDF and outputs an opaque gradient.
This is how it should look like:
This is how it is appears in the Typst-rendered PDF:
This is how I'm inserting the figure into the document:
#figure(
image("figures/figure-4.pdf", width: 97.5%),
scope: "parent",
placement: top,
caption: [Lorem ipsum dolor sit amet.]
)
<fig-4>
Interestingly, this issue only happens when I apply the transparency to the box as a whole. When I set the transparency directly in the color within the gradient, it works as expected. Here is a PDF of the working version: translucent-gradient-working.pdf.
I found that the issue only happens when the transparency is applied to the whole rectangle. When I reduce the opacity in the color within the gradient, it works as expected. I updated the issue description and uploaded a PDF that works as expected in Typst.
changed the title [-]Typst ignores the transparency of translucent gradients in PDF figures[/-][+]Typst ignores the transparency of translucent gradients in PDF images[/+]on Oct 30, 2025
changed the title [-]Typst ignores the transparency of translucent gradients in PDF images[/-][+]Transparency of translucent gradients in PDF images is ignored[/+]on Oct 30, 2025
It seems to work fine in Acrobat, Chrome, mupdf, ghostscript, and PDFBox. It's somewhat broken in Firefox and completely broken in Apple Preview for me.
Not sure if this is related (if not, I can create a different issue), but it looks like gradients in embedded PDFs are not appearing in iOS's PDF reader:
A quick question: is there any practical workaround to avoid this issue? I tried exporting the figures as SVG, but the output becomes distorted. I also attempted to write a simple PDF↔SVG conversion CLI using hayro, but my Rust skills are not up to the task (I'm also not completely sure that the resulting SVG would render correctly).
I'm preparing to submit a paper that includes this figure, so I want to ensure that readers can open the final PDF without rendering problems, regardless of which PDF viewer they use. In the worst case, I can rasterize the images, but I would like to avoid that if possible.
I used Affinity Designer to generate my figures (figure-4.pdf and figure-5.pdf). The LaTeX documents were just generated with Overleaf with the code above.
Okay wow, I think I might have found a solution for both, SVG import and PDF import. Thanks a lot for providing the sample files, that was very helpful. I will see whether I can implement it soon.
Out of curiosity, what did these last couple of PDFs show that wasn’t already clear in the earlier examples? I’m mainly wondering whether LaTeX handles this differently.
I'm not sure, as mentioned I tried it previously in Latex and it didn't seem to work, but when just copy-pasting yours it does seem to work. Then, I simply inspected their PDF and checked what they do different.
@LaurenzV are you planning to make a new release of krilla with the fix for SVGs soon? I'm just considering whether I should have a local Typst fork that uses the latest commit from krilla.
I'll use a local build from the Git version of krilla to generate a batch of documents. Just to confirm: the issue has been fixed for SVG figures, but not for PDF figures, correct?
I merged the fix for PDF imports in April (LaurenzV/krilla#342), and I even added your PDF as a regression test. So I would be surprised if it isn't fixed now.
bugSomething isn't workingpdfRelated to PDF export or PDF embedding.visualizeRelated to the visualize category, which is about drawing and illustrating
Activity
apcamargo commentedon Oct 30, 2025
I found that the issue only happens when the transparency is applied to the whole rectangle. When I reduce the opacity in the color within the gradient, it works as expected. I updated the issue description and uploaded a PDF that works as expected in Typst.
[-]Typst ignores the transparency of translucent gradients in PDF figures[/-][+]Typst ignores the transparency of translucent gradients in PDF images[/+][-]Typst ignores the transparency of translucent gradients in PDF images[/-][+]Transparency of translucent gradients in PDF images is ignored[/+]LaurenzV commentedon Oct 30, 2025
I'm not sure I can reproduce, in the webapp I get this in the preview:
and this in the final PDF:
Is that not the expected look?
Enivex commentedon Oct 30, 2025
Could be an issue with whatever pdf reader is being used
apcamargo commentedon Oct 30, 2025
I tested it in multiple PDF readers. I don't think that's the issue
apcamargo commentedon Oct 30, 2025
The minimal example is not working. Here's the actual PDF I used to trigger the bug:
buggy-figure.pdf.It displays fine in Typst's webapp, but failed in the PDF readers I tried (including macOS's default reader).
LaurenzV commentedon Oct 30, 2025
It seems to work fine in Acrobat, Chrome, mupdf, ghostscript, and PDFBox. It's somewhat broken in Firefox and completely broken in Apple Preview for me.
Enivex commentedon Oct 30, 2025
That's actually the one that usually causes issues
apcamargo commentedon Nov 10, 2025
Not sure if this is related (if not, I can create a different issue), but it looks like gradients in embedded PDFs are not appearing in iOS's PDF reader:
iOS:

PDF.js:

PDF file (see page 8).
LaurenzV commentedon Nov 10, 2025
Yes, it's probably the same issue.
apcamargo commentedon Nov 30, 2025
A quick question: is there any practical workaround to avoid this issue? I tried exporting the figures as SVG, but the output becomes distorted. I also attempted to write a simple PDF↔SVG conversion CLI using
hayro, but my Rust skills are not up to the task (I'm also not completely sure that the resulting SVG would render correctly).I'm preparing to submit a paper that includes this figure, so I want to ensure that readers can open the final PDF without rendering problems, regardless of which PDF viewer they use. In the worst case, I can rasterize the images, but I would like to avoid that if possible.
15 remaining items
LaurenzV commentedon Dec 4, 2025
Are you sure this is raw Latex? The metadata suggests it's using some other intermediate program:
apcamargo commentedon Dec 4, 2025
I used Affinity Designer to generate my figures (
figure-4.pdfandfigure-5.pdf). The LaTeX documents were just generated with Overleaf with the code above.LaurenzV commentedon Dec 6, 2025
Thanks, I will do some more digging when I find the time to do so, maybe I can figure something out.
LaurenzV commentedon Dec 6, 2025
Okay wow, I think I might have found a solution for both, SVG import and PDF import. Thanks a lot for providing the sample files, that was very helpful. I will see whether I can implement it soon.
LaurenzV commentedon Dec 6, 2025
SVG import should be fixed: LaurenzV/krilla#320
apcamargo commentedon Dec 6, 2025
That's great! Thank you!
Out of curiosity, what did these last couple of PDFs show that wasn’t already clear in the earlier examples? I’m mainly wondering whether LaTeX handles this differently.
LaurenzV commentedon Dec 6, 2025
I'm not sure, as mentioned I tried it previously in Latex and it didn't seem to work, but when just copy-pasting yours it does seem to work. Then, I simply inspected their PDF and checked what they do different.
apcamargo commentedon Dec 31, 2025
@LaurenzV are you planning to make a new release of
krillawith the fix for SVGs soon? I'm just considering whether I should have a local Typst fork that uses the latest commit fromkrilla.LaurenzV commentedon Dec 31, 2025
I wasn't planning on making a new release before the next Typst release, so if you need it it would be best to link to the git version for now.
apcamargo commentedon Mar 3, 2026
Thanks, @LaurenzV!
I'll use a local build from the Git version of
krillato generate a batch of documents. Just to confirm: the issue has been fixed for SVG figures, but not for PDF figures, correct?LaurenzV commentedon Mar 3, 2026
I think this should be the case, but probably worth double-checking.
apcamargo commentedon May 29, 2026
@laurmaedje this bug hasn't been fixed. Last time I check (back in March), PDFs were still problematic.
LaurenzV commentedon May 29, 2026
I merged the fix for PDF imports in April (LaurenzV/krilla#342), and I even added your PDF as a regression test. So I would be surprised if it isn't fixed now.
apcamargo commentedon May 29, 2026
That's after my testing, then. Thanks!