Skip to content

Transparency of translucent gradients in PDF images is ignored #7269

Closed

Description

@apcamargo

Description

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:

Image

This is how it is appears in the Typst-rendered PDF:

Image

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.

Reproduction URL

No response

Operating system

Web app

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Oct 30, 2025
  2. added
    pdf
    on Oct 30, 2025
  3. apcamargo commented on Oct 30, 2025

    @apcamargo
    ContributorAuthor

    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.

  4. 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
  5. added
    visualize
    on Oct 30, 2025
  6. 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
  7. LaurenzV commented on Oct 30, 2025

    @LaurenzV
    Collaborator

    I'm not sure I can reproduce, in the webapp I get this in the preview:

    Image

    and this in the final PDF:

    Image

    Is that not the expected look?

  8. Enivex commented on Oct 30, 2025

    @Enivex
    Collaborator

    Could be an issue with whatever pdf reader is being used

  9. apcamargo commented on Oct 30, 2025

    @apcamargo
    ContributorAuthor

    I tested it in multiple PDF readers. I don't think that's the issue

  10. apcamargo commented on Oct 30, 2025

    @apcamargo
    ContributorAuthor

    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).

  11. LaurenzV commented on Oct 30, 2025

    @LaurenzV
    Collaborator

    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.

  12. Enivex commented on Oct 30, 2025

    @Enivex
    Collaborator

    including macOS's default reader

    That's actually the one that usually causes issues

  13. apcamargo commented on Nov 10, 2025

    @apcamargo
    ContributorAuthor

    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:
    Image

    PDF.js:
    Image

    PDF file (see page 8).

  14. LaurenzV commented on Nov 10, 2025

    @LaurenzV
    Collaborator

    Yes, it's probably the same issue.

  15. apcamargo commented on Nov 30, 2025

    @apcamargo
    ContributorAuthor

    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.

  16. 15 remaining items

  17. LaurenzV commented on Dec 4, 2025

    @LaurenzV
    Collaborator

    Are you sure this is raw Latex? The metadata suggests it's using some other intermediate program:

    Image
  18. apcamargo commented on Dec 4, 2025

    @apcamargo
    ContributorAuthor

    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.

  19. LaurenzV commented on Dec 6, 2025

    @LaurenzV
    Collaborator

    Thanks, I will do some more digging when I find the time to do so, maybe I can figure something out.

  20. LaurenzV commented on Dec 6, 2025

    @LaurenzV
    Collaborator

    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.

  21. LaurenzV commented on Dec 6, 2025

    @LaurenzV
    Collaborator

    SVG import should be fixed: LaurenzV/krilla#320

  22. apcamargo commented on Dec 6, 2025

    @apcamargo
    ContributorAuthor

    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.

  23. LaurenzV commented on Dec 6, 2025

    @LaurenzV
    Collaborator

    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.

  24. apcamargo commented on Dec 31, 2025

    @apcamargo
    ContributorAuthor

    @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.

  25. LaurenzV commented on Dec 31, 2025

    @LaurenzV
    Collaborator

    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.

  26. apcamargo commented on Mar 3, 2026

    @apcamargo
    ContributorAuthor

    Thanks, @LaurenzV!

    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?

  27. LaurenzV commented on Mar 3, 2026

    @LaurenzV
    Collaborator

    I think this should be the case, but probably worth double-checking.

  28. apcamargo commented on May 29, 2026

    @apcamargo
    ContributorAuthor

    @laurmaedje this bug hasn't been fixed. Last time I check (back in March), PDFs were still problematic.

  29. LaurenzV commented on May 29, 2026

    @LaurenzV
    Collaborator

    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.

  30. apcamargo commented on May 29, 2026

    @apcamargo
    ContributorAuthor

    That's after my testing, then. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpdfvisualize

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions