Problem with transparency in LO User Guides

Although transparency in images appears to cause no problems in PDFs created by LO, in fact it sometimes interferes with printing on some of the equipment used by Lulu to produce printed copies of our books. When this happens, Lulu removes the book from availability until the problem file is fixed.

The recommended fix is to “flatten” the PDF. I have not found any way to do this during PDF creation using LO. It can be done using Adobe Acrobat Pro, which I do not have.

Another solution could be to flatten (remove the transparency) the problem images, but our books contain a lot of screenshots and other images and I don’t know an easy way to identify all of the problem images, nor do I know how to flatten them.

If anyone knows a way to overcome this problem, please let me know. I would prefer to not pay for, or use, Acrobat Pro.

My favorite is PDFtk Server (PDFtk Server Manual, PDFtk Server Examples) but it can be finicky. Try Sejda helps with your PDF tasks which has a limited license but will likely work. I note it describes Flatten as Makes fillable PDFs read-only.

Hello Jean

I have PDF Reader Pro installed on my Mac Mini. It has an option Save As Flattened PDF. I have never tried this option, but willing to have a go.

What file would like me to flatten?

I have had PDF Reader Pro for a long time and it was cheaper than Acrobat Reader Pro. It works for me when I am creating PDFs.

Regards

Peter Schofield
psauthor@gmail.com
Technical Writer, LO Documentation Team

Hello Jean

Just tried PDF Reader Pro on the Draw Guide pdf. It was very quick to flatten and file size is 12.8Mb. Original file size was 12.9Mb.

Regards

Peter Schofield
psauthor@gmail.com
Technical Writer, LO Documentation Team

One way might be to unzip the document, run some command line tool to manipulate all the images and finally zip it up again.

Later, or tomorrow, I will upload the file I need flattened. Worth a try. Thanks.
Jean

That’s more effort than I’d be willing to do, but an interesting idea.
Jean

Preview (which comes with macOS) supposedly flattens PDFs, but that’s what I used to create the file that’s having the problem. Either I’ve missed an option somewhere, or the problem is actually something else, or Preview flattens forms but not images, or… who knows?

Jean

Hello Jean

Preview can flatten PDF files.
Select File > Print.
Select Save as PDF from the PDF drop-down list at the bottom of the print dialog, then save the file.
It appears to work when I try to edit in PDF Reader Pro.

Regards

Peter Schofield
psauthor@gmail.com
Technical Writer, LO Documentation Team

That’s what I’ve been doing, but the resulting file has been rejected by Lulu. Something else may be the problem. My guess that flattening (with a non-Adobe product) would fix it appears to not be a sufficient solution.

Jean

Send the file and I will flatten using PDF Reader Pro and return.

Peter Schofield
psauthor@gmail.com
Technical Writer, LO Documentation Team

Disclaimer: I know almost nothing about this…

But I tested my google foo

  1. What image types support transparency?

GIF and PNG and tiff

Jpg does not

ImageMagic should be able to remove transparency from the command line based on what I saw at the link below (on my phone, no computer access at the moment)

https://gist.github.com/AppleBetas/7ac9f40373ac54efce4826059d081cad

Not sure of an easy way to quickly find an image with a transparent background and not sure that is the only problem, but…

May be able to unzip the container, user the command line to fix transparency, then repackage.

GIMP may provide a means to find transparency with a script but need a computer for better checking on that.

It is a long shot, but might work.

If I could find this with a macro then simply walk the images to find the problem images.

Would still probably need something like GIMP too remove. No idea if draw can do that.

Andrew Pitonyak

Get BlueMail for Android

Yes, you can use imagemagic to do this from the command line.

convert image.png -background white -alpha remove -alpha off white.png

Feel free to replace white with any other color you want. Imagemagick documentation says this about the -alpha remove operation:

This operation is simple and fast, and does the job without needing any extra memory use, or other side effects that may be associated with alternative transparency removal techniques. It is thus the preferred way of removing image transparency.

A bit more searching tells me that:

identify -format ‘%[channels]’ foo.png

will print rgba or rgb if there is or is not an alpha channel, respectively.

There could be an alpha channel present with no data in it which wouldn’t actually have any transparency, but that is a bit more complicated.

If I just want to know if there is a transparent pixel in an image

identify -format ‘%[opaque]’ a.png

If you have a document and you want me to test a process on it, let me know.

jeanweber
April 8

Although transparency in images appears to cause no problems in PDFs created by LO, in fact it sometimes interferes with printing on some of the equipment used by Lulu to produce printed copies of our books. When this happens, Lulu removes the book from availability until the problem file is fixed.

The recommended fix is to “flatten” the PDF. I have not found any way to do this during PDF creation using LO. It can be done using Adobe Acrobat Pro, which I do not have.

Another solution could be to flatten (remove the transparency) the problem images, but our books contain a lot of screenshots and other images and I don’t know an easy way to identify all of the problem images, nor do I know how to flatten them.

If anyone knows a way to overcome this problem, please let me know. I would prefer to not pay for, or use, Acrobat Pro.

Hi.
A couple of options described here.
In simplest form with pdftk,

@PeeWee I have put the problem PDF (produced by Preview in macOS) in English > Writer Guide > 7.5 > Work in Progress.
https://nextcloud.documentfoundation.org/f/1249261

https://imagemagick.org/ is definitely powerful but the options are daunting. The issue is processing an existing pdf with transparent background images in it, not the images. Often these tools convert vector graphics to raster at the same time, which I consider corrupting the file.

I wanted to put a stamp on a pdf the other day. Adobe uses pdf format for stamps but scanned files are normally a raster format, sometimes embedded in a pdf, but it surprised me the native format is pdf and it didn’t support raster formats. Anyway, I needed a pdf of the appropriate dimensions for A4 with a transparent background, say using Adobe Acrobat Reader. I had no success with LibreOffice Draw and ended up with a convoluted workflow. @pitonyak Do you want to have a crack at raster to transparent background pdf with ImageMagick?


@jeanweber Why don’t you raise an enhancement request as a longer-term solution? Flattening an image seems a reasonable option for LibreOffice export to pdf. I was wondering if turning off Create PDF form would flatten it. Alternatively, maybe Images needs an option to Remove transparency.

image

Hello Jean

I have flattened the PDF file for the Writer Guide. It is now in NextCloud English > Writer Guide > 7.5 > Work in Progress and the file name has Flatten at the end. Please check see if it is OK.
[https://nextcloud.documentfoundation.org/apps/files/?dir=/LibreOffice Documentation/English/Writer Guide/7.5/Work in Progress&openfile=1249277](https://nextcloud.documentfoundation.org/apps/files/?dir=/LibreOffice Documentation/English/Writer Guide/7.5/Work in Progress&openfile=1249277)

Regards

Peter Schofield
psauthor@gmail.com
Technical Writer, LO Documentation Team

Try to export as PDF/A-1, which does not allow transparency and thus
LibreOffice “should” flatten the PDF. If it does not, that is a bug.
PDF/A-2 and PDF/A-3 do allow transparency.

1 Like

Thank you! That looks like the best solution, requiring no other programs for post-processing. I’ve done the export, and it gave me a message that transparencies were removed. I’ve checked the resulting PDF, which looks fine. Later I’ll try submitting it to Lulu and see if it’s acceptable. The file size is much larger than the other one, but for this purpose that isn’t a problem.
Jean

Thanks. I’ll test it on Lulu when I get a chance. However, if @lmamane’s suggestion about PDF/A-1 is successful (acceptable to Lulu), I’ll use that in my regular workflow.
Jean