New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exporting with alpha/transparency in a PDF #108
Comments
What are the two commands that you're using (export_fig and print)? in other words, which parameters are you using? Also, which platform and Matlab release? |
MATLAB R2015a 64bit Also doesn't work with |
Oh, I see... export_fig saves in EPS then converts back to PDF. |
I am not familiar with pdfmark, but if you can modify eps2pdf.m in a way that would fix the problem then I would be happy to incorporate your fix in the main version. |
I am working on a workaround for this. |
I think it would be best to create a super-simple white figure that only has a single simple semi-transparent alpha-patch, and then generate the EPS export using the following command: print(gcf, '-painters', '-loose', '-depsc2', 'test.eps') This would make the EPS text file much smaller and you should be able to easily identify the alpha patch near the bottom of the file. EPS files are simply text files that contain PostScript directives, so you can easily experiment with your solution by simply editing the generated EPS file in any text editor (e.g., the Matlab editor) and then re-displaying the image file to see if the change helped. Once you figure out how to post-process the EPS manually, this can be automated. You can look at print2eps.m (below line #233) for some EPS post-processing examples. The basic idea is to use the Let me know if you still need my additional help with this. |
I have already done pretty much exactly what you've suggested haha. This works for making all patches transparent: |
Suggestion: take a look at the color values. If you don't see anything obvious, you could possibly modify them as a signal. For example:
|
…altmany#108) Requires use of '-transparent' argument
This shows the fix (#111) (notice the thin lines from export_fig compared to the thick lines from MATLAB (yet still the thinnest MATLAB can do) ) Fix may get stuck on rare cases where ID color values are the exact same as other patches but should be good for most of the time. |
Fixed via merge of pull #111 |
…altmany#108) Requires use of '-transparent' argument
* upstream/master: (37 commits) Fixed clipboard export in R2015b (thanks to Dan K via FEX) Update README URLs based on HTTP redirects Custom GS installation webpage for MacOS. Thanks to Andy Hueni via FEX bug fix Typo fix: earlier commit was for issue altmany#112, not altmany#110 Fixed issue altmany#110: use same renderer in print2eps as export_fig (thanks to Jesús Pestana Puerta) Suggest a workaround for issue altmany#41 (missing font path; thanks Mariia Fedotenkova) Do not suggest workarounds for certain errors that have already been handled previously typo fix; added credit comment Moved transparency/alpha fix to print2eps.m Changed to always maintain alpha (removed `-transparent` flag dependency) Check whether `using_hg2` is true and only apply for HG2 Implemented a fix to maintain transparency (alpha) in PDF files (issue altmany#108) Requires use of '-transparent' argument Alert if trying to export transparent patches/areas to non-PNG outputs (issue altmany#108) Fixed issue altmany#103: magnification must never become negative; also fixed reported error msg in parsing input params Fixed issue altmany#91 (thanks to Carlos Moffat) Fixed problem with anti-aliasing on old Matlab releases Fixed issue altmany#83: use numeric handles in HG1 Added -nofontswap option to avoid font-swapping in EPS/PDF Added extra debug info in case of ghostscript error; code indentation Added -update option to download and install the latest version of export_fig Suppress warning in R2015b; cache result for improved performance ...
* upstream/master: Better support + backward compatibility for transparency (issue altmany#108) Bug fix from latest release of the eps2pdf.m file (workaround for issue altmany#41) Added -c option for specifying crop amounts separately for each of the 4 image sides
I am losing transparency in a PDF file for areas that have alpha. MATLAB exports the PDF with the vector components displayed correctly with transparency but export_fig does not.
This sounds similar to issue #3 but I am pretty sure MATLAB isn't embedding a rastered version in the PDF (I can zoom all the way in and the shaded areas are still sharp).
The text was updated successfully, but these errors were encountered: