Skip to content

Transparent Gradient does not export to PDF correctly #2546

@schang412

Description

@schang412

Description

When applying a gradient with alpha, the PDF export puts a white background behind the gradient.

Preview on webapp behaves as expected
PNG export behaves as expected.
PDF export does not match preview nor PNG, it places a white background behind the gradient.

// nested rectangles
#rect(fill: rgb(50%, 50%, 0%))[
  #rect(fill: rgb(50%, 0%, 0%))[#h(100%)]
]

// transparent rectangles
#rect(fill: rgb(50%, 50%, 0%, 120))[
  #rect(fill: rgb(50%, 0%, 0%, 120))[#h(100%)]
]

// gradient has white background in PDF export
#let transparent = rgb(255, 255, 255, 0)
#rect(fill: rgb(50%, 50%, 0%, 100))[
  #rect(fill: gradient.linear(transparent, transparent, rgb(50%, 0%, 0%), transparent, transparent))[#h(100%)]
]

// for completeness, a color with a specified alpha value also fails
#rect(fill: rgb(50%, 50%, 0%, 100))[
  #rect(fill: gradient.linear(transparent, transparent, rgb(50%, 0%, 0%, 120), transparent, transparent))[#h(100%)]
]

I am not 100% familiar with how a PDF document works, but somewhere in the chain, I suspect that the gradient's transparency information is lost.

Reproduction URL

No response

Operating system

Web app

Typst version

  • I am using the latest version of Typst

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood contributionSuitable for contribution, but unlike "good first issue", it may need prior experiencehelp wantedExtra attention is neededpdfRelated to PDF export or PDF embedding.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions