: How to fix transparency issue in pdf output from Inkscape? I'm creating some histograms for use in a scientific article, The final figure is supposed to be a few graphs, each with two sets
I'm creating some histograms for use in a scientific article, The final figure is supposed to be a few graphs, each with two sets of data plotted showing how similar they are. In my example, I used Julia to generate two sets of data, and used Gadfly to draw the overlay to an SVG file. This was achieved by layering the histograms with some transparency in the bars. I opened the SVG file in Inkscape and added text descriptions and then saved it as a pdf for use in my tex file. However, the pdf do not display the transparency and just put one layer on top of the other with no interaction between the two. Oddly enough, the thumbnail preview panel in Evince does show the picture properly, which led me to think that it was simply a deficiency of Evince. I tried viewing the pdf in Okular, but there both the thumbnail preview and the pdf itself do not show the transparency. I'm somewhat confused as to where the problem actually is.
I dropboxed the SVG in question here and the PDF output here. The thumbnail in Evince looks like , which is what I'm shooting for (except not for ants).
I'd really appreciate any advice on the matter. Thanks for the read!
More posts by @Berryessa866
2 Comments
Sorted by latest first Latest Oldest Best
As suggested in (see the second answer, not the first)
www.inkscapeforum.com/viewtopic.php?t=15739
setting alpha channel value instead of opacity works.
Unfortunately, I've read the solution after finishing a complex design which had hundreds of shapes in it. Therefore, manually setting opacity back to 100% and then setting to alpha channel value to something lower than 255 was not an option. Fortunately, "sed" utility of *NIX systems saved me (note that SVG is nothing but a text file). Here is the command that I used
sed 's/opacity:0.([0-9]*)(;fill[^ ]*fill-opacity:)1/opacity:120.1/' input_with_opacity.svg > output_with_alpha.svg
It switches between values of opacity and alpha channel (named fill-opacity) for all objects in the file. For instance, if you have a line
style="opacity:0.2;fill:#2bd9cf;fill-opacity:1;stroke:none;display:inline"
in the original file, it will become
style="opacity:1;fill:#2bd9cf;fill-opacity:0.2;stroke:none;display:inline"
in the new file. Well, it may need some tweaking for your files, but it should not be too hard to do so. One caveat is that you may need to ungroup all your objects before running this since "style" format for grouped objects may be different.
Unfortunately the PDF format available from Inkscape does not support transparency. To still be able to create a PDF with an Inkscape drawing having transparent objects we will have to convert these to bitmap first.
For a single object or group this can be done with the Filter > Transparency utilities > Light Eraser.
We have to be aware that this filter does not preserve colors as expected. To obtain the results of such a conversion as it is displayed below I had to add another 90% opacity to the columns object's fill and stroke property.
PDF with partly converted to bitmap with Light Eraser shown in Evince
When using another application for converting to PDF we get much better results. An Open Source application capable of doing so would be Open/Libre Office, which allows transparency on PDF export (objects are not converted to bitmaps):
SVG imported to Libre Office, exported to PDF as shown in Evince
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.