Fill Gradients reversed when exporting to PDF

I recently added some rounded rectangles to a document and filled them with a linear gradient (color fade to transparent) but when I export the document as a PDF, the gradients are reversed - dense color where they should be transparent and transparent where the color should be dense. Am I missing a setting (using default export to PDF settings).

I’m also seeing the rounded corners of my rectangles showing up as white cropped corners - i.e. at the edge of the rounded corners it should be transparent, but there is a sharp white corner. I’m assuming these issues are related.

Thanks for any help :slight_smile:

Well, it looks like a bug with the linear gradient. When I use a solid or one of the other styles of gradients, I don’t see the same errors - so - I guess it’s a bug.

Just my luck to find a bug the first time I use Writer for a serious document - lol

Please attach a sample file, reduce the size as much as possible without private information, and paste the information in Menu/Help/About LibreOffice, there is a copy icon.

Here is a demo file - just export it as a PDF - notice the white corners and the reversed gradients.
Gradient Bug.odt (23.1 KB)

If I use Lossless compression when exporting to pdf I get a file size of 35 KB and it looks pretty much exactly the same as shown in Writer.

Gradient Bug108336Lossless.pdf (34.1 KB)

If I use JPEG compression I get a file size of 53 KB and squares at the corners. This is kind of expected because jpg does not support transparency so the rounded rectangle will have a background. I suppose white is default as the page background is usually white.

It is hard to see the situation could be improved for jpg compression. If the background were a photograph, the rounded corners could be any mixture of colours.

If you think it really is bug, you could submit one, How to Report Bugs in LibreOffice - The Document Foundation Wiki

1 Like

That totally makes sense - and yes, when I tested it just now, selecting lossless compression fixes the issue. I guess what was throwing me off initially is that the gradients were “working” - just flipped - which made me think that the alpha channel was working, just not correctly.

I just checked my document and indeed, selecting lossless compression does fix the issue (as a PDF), although my file size goes from 292KB to 1.2MB - which isn’t a deal-killer by any stretch. However, after poking around a bit, I realized that the jump in size is due to an image I’m using as a fill - when I remove it, my file size goes to 209KB. Maybe images should be treated separately (yay! more complexity! lol).

I guess I don’t really consider that a bug … but it might be nice to get a warning when you export with a gradient that they might not work without “Lossless Compression” turned on.

Thanks for taking the time to troubleshoot that :slight_smile:

If you have jpg images that you want in the same pdf then Insert > Image and insert the jpg. Export to pdf Lossless will bundle the original jpg inside the pdf, the gradient will be png. The size should then be similar to jpg compression of the pdf.

NOTE: On Windows, copying a jpg from another programme will paste it into LibreOffice as png with a larger size. This is a limitation of Windows ancient clipboard technology. Always Insert the image or drag the file from a file manager