`exportgraphics` to PDF causes Java error in Arch/Manjaro Linux

5 visualizaciones (últimos 30 días)
Chunyu Xiao
Chunyu Xiao el 29 de Mayo de 2022
Respondida: Abhishek Chakram el 28 de Sept. de 2023
Hello everyone,
When I try to export the figure to PDF vector graphics, the exportgrachics function fails with Java error and generates a empty PDF.
A minimal example could be:
ezplot('sin(x)')
exportgraphics(gcf,'sin.pdf')
and the corresponding Java error is:
Error using exportgraphics
java.lang.NullPointerException
at org.apache.fop.fonts.autodetect.FontInfoFinder.find(FontInfoFinder.java:219)
at org.apache.fop.fonts.FontAdder.add(FontAdder.java:63)
at org.apache.fop.fonts.FontDetectorFactory$DefaultFontDetector.detect(FontDetectorFactory.java:105)
at org.apache.fop.fonts.FontManager.autoDetectFonts(FontManager.java:229)
at org.apache.fop.fonts.DefaultFontConfigurator.configure(DefaultFontConfigurator.java:82)
at
org.apache.fop.svg.PDFDocumentGraphics2DConfigurator.createFontInfo(PDFDocumentGraphics2DConfigurator.java:143)
at
org.apache.fop.svg.PDFDocumentGraphics2DConfigurator.configure(PDFDocumentGraphics2DConfigurator.java:87)
at com.mathworks.hg.print.FOPFontConfigurator.configurePDFFonts(FOPFontConfigurator.java:57)
at com.mathworks.hg.print.FOPPDFVectorStrategy.startJob(FOPPDFVectorStrategy.java:89)
at com.mathworks.hg.util.HGVectorOutputHelper.open(HGVectorOutputHelper.java:74)
The same problem occurs in my both Arch and Manjaro system, the system infomations are below:
  • MATLAB version: R2022a
  • Linux kernel: Arch 5.18, Manjaro 5.15
  • System default Java: java18-openjdk
The function worked very well in MATLAB R2021b before, but I have uninstalled the previous version.
Since Arch/Manjaro is not officially support by MathWorks, I have to turn to the community for help. I would appreciate if anyone could give me some solutions or suggestions. Thanks for your attention.
  1 comentario
Tri Nguyen
Tri Nguyen el 24 de Jun. de 2022
I got this issue too, after I ran pacman update. Looking forword to some solution.

Iniciar sesión para comentar.

Respuestas (1)

Abhishek Chakram
Abhishek Chakram el 28 de Sept. de 2023
Hi Chunyu Xiao,
It is my understanding that you have encountered a Java error when using the exportgraphics function to export a figure to PDF in MATLAB on Arch/Manjaro Linux, it could be due to a compatibility issue with the Java Runtime Environment (JRE) on your system.
Here are a few steps you can try to resolve the issue:
1. Update your Java installation: Make sure you have the latest version of Java installed on your system. You can update Java by running the following command in the terminal:
sudo pacman -Syu jre-openjdk
This command will update the JRE to the latest version available in the Arch Linux repositories.
2. Set the Java version for MATLAB: MATLAB might be using a different Java version than the one installed on your system. To ensure MATLAB uses the updated Java version, you can try setting the MATLAB_JAVA environment variable to the path of the JRE installation. Open a terminal and run the following command:
export MATLAB_JAVA=/usr/lib/jvm/java-<version>-openjdk
Replace <version> with the appropriate version number of the JRE installed on your system.
3. Use an alternative method to export to PDF: If the above steps do not resolve the issue, you can try using an alternative method to export the figure to PDF. For example, you can use the print [AJ1] function with the -dpdf option to save the figure as a PDF file:
print('figure_name.pdf', '-dpdf')
Replace 'figure_name.pdf' with the desired file name and path.
Best Regards,
Abhishek Chakram

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by