Problème d'exportation .mlx en PDF

Bonjour,
Lors de mon utilisation de la fonction 'export', je rencontre une erreur que je n'arrive pas à résoudre.
Voici comment j'utilise la fonction ( à la fin de mon fichier .mlx concerné) et le message d'erreur associé :
Le code :
export('myfile.mlx', 'export_PDF.pdf');
L'erreur :
Error using assert
Unable to open or load the Editor.
Error in matlab.desktop.editor.HeadlessEditorDocument/ensureRtcReady (line 123)
assert(obj.IsRtcReady == RtcEditorState.CREATED, ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in matlab.desktop.editor.HeadlessEditorDocument/get.Opened (line 467)
obj.ensureRtcReady;
^^^^^^^^^^^^^^^^^^^
Error in matlab.desktop.editor.Document/get.Opened (line 837)
isopen = obj.Editor.Opened;
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in export (line 153)
if editorDocument.Opened
^^^^^^^^^^^^^^^^^^^^^^^^
Si quelqu'un peut m'aider !
Merci

 Réponse acceptée

Samar
Samar le 8 Mai 2026 à 9:47

0 votes

Hi Romain,
I understand MATLAB is throwing an error: "Unable to open or load the Editor." This error is a known limitation/bug of 'export' when it is called from inside the same running .mlx file, especially in MATLAB R2025b.
Why this happens
  • export internally tries to open the Live Editor document using a headless editor instance (HeadlessEditorDocument).
  • When export is executed from within the currently active Live Script, the editor document is already in use, so MATLAB fails with 'Unable to open or load the Editor'
Recommended workarounds
Option 1: Run export from a separate script
  • Create a small .m file:
export('myfile.mlx','export_PDF.pdf');
  • Run it after the live script finishes.
  • This avoids editor re‑entrancy and works reliably.
Option 2: Use Live Editor UI
  • Open the .mlx file and use:
  • Live Editor → Export → PDF
  • This uses the interactive editor path and bypasses the headless editor issue.
Refer this MathWorks Documentation: https://www.mathworks.com/help/matlab/ref/export.html
Option 3: Save first, then export
  • Sometimes helps if the issue is triggered by unsaved state:
save('myfile.mlx');
export('myfile.mlx','export_PDF.pdf');
I hope this resolves the issue!
Thanks,
Samar

1 commentaire

Romain
Romain le 11 Mai 2026 à 7:25
Hi Samar,
Thank you for your reply.
I tried both Option 1 and Option 3, but unfortunately they do not work on my side. I still get the same error: “Unable to open or load the Editor.”
Regarding Option 2, I am already aware that exporting manually through the Live Editor UI works. However, my goal is to automate the export process, ideally through a button, so using the manual UI export is not suitable for my use case.
Could you please let me know if there is another workaround or a recommended way to programmatically export an .mlx file to PDF without relying on the Live Editor UI?
Thanks,
Romain

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2025b

Question posée :

le 4 Mai 2026 à 8:28

Commenté :

le 11 Mai 2026 à 7:25

Community Treasure Hunt

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

Start Hunting!