Problem with transparency in LO User Guides

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

I always have “Create PDF Form” turned off when I produce a PDF for printing. That flattens the form, but unfortunately does not affect transparency. However, using Archive PDF/A-1b did remove transparency.
Jean

1 Like

That needs to find it’s way into the documentation guide and possibly the Writer and/or Draw guide.

OK Jean

Not a problem to flatten PDF files. If it happens again, send me the finished PDF that is ready for Lulu and I will flatten it.
I will look at PDF/A-1 to see what it is all about.

Regards

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

The flattened file provided by Peter still contains transparency, according to Lulu. From my reading, most so-called “flattening” appears to deal with things like form fields, while leaving transparency and layers in images.

The file produced from LO using the setting for PDF/A-1 does not contain transparency. I hope the revised book will print okay without other problems.

Jean

Just to be clear:
For purposes of reading onscreen and printing on non-commercial (home and office) printers, a PDF needs the settings we usually use, which are different from the settings needed for commercial printing, including Lulu’s print-on-demand. For example, for reading onscreen, “export outlines” should be selected; this puts a “table of contents” list in the sidebar in most PDF viewers. For commercial printing, that setting should not be selected. Similarly PDF/A-1b should NOT be selected when producing out usual PDFs for distribution through the LO website and wiki.
Jean

In Tools - Options - LibreOffice - Print there is an option to reduce transparency to No Transparency when printing to file. Does this remove the transparency from images in PDFs.