MATLAB Community

MATLAB, community & more

Publish to PDF 20

Posted by Michael Katz,

Sometimes one of my colleagues comes up with a big idea that’s so brilliant, it can be succinctly summarized in a small phrase that downplays its impact. Publish to PDF pretty much says it all. In MATLAB R2009b you can now publish your MATLAB code directly to a PDF-file.

If you’re like me, you probably used to publish to doc and then use Google docs to convert it to a PDF. Well now you can go to PDF directly, and get a higher quality document than you would by going through Word and then to pdf.

That’s pretty much the whole peanut butter sandwhich right there. The easiest way to set this up is through a Publish Configuration.

Publish to PDF from a publish configuration

Here is an image of the output of the sine wave publishing demo (click to see a larger version):

Published PDF of sine wave demo


You can also watch this lovely video on how this new feature works.


Comments are closed.

20 CommentsOldest to Newest

Daniel Armyr replied on : 1 of 20

A word of caution when using this feature, though. It appears that in some cases when regenerating a file, all plots are not properly updated. Bug report has been written.

Other than that, this has been at the top of my wish-list for many years.

OysterEngineer replied on : 5 of 20

When I first learned of the Publish feature in MatLab, I thought it might be useful to help to document my code. But, I haven’t figured out a work-flow that makes that work well.

Since then, I’ve concluded that the Publish feature is really best for making technical lectures. Thus, MatLab has used this feature well for their own training materials & I suspect that many professors use it also in technical classes.

Daniel Armyr replied on : 6 of 20

I use publish to document pretty much everything I do. first make one file which does everything that might require human och other machine interaction but as little else as possible. Save your data.
Then make a publishable file where you read out your data and do signal processing as well as cosmetics on it. That file is the one you publish.

OysterEngineer replied on : 7 of 20


It seems like some of your post was truncated.

Reading between the lines, it seems like your workflow would require 2 separate copies of the guts of the code. How do you manage the process of keeping the guts identical?

Sune replied on : 8 of 20

I have the same problem as reported by Daniel Armyr on november 17th 2009, ie. my plots are not updated when I regenerate a file publishing to pdf. What is the status of this bug?


Mike replied on : 9 of 20


We update our products twice a year (generally March and October) with new features and bug fixes…stay tuned.

houssemus replied on : 10 of 20

hi, i used to this option in Matlab 2009b, but with the 2011, i’m having an error message don’t know why,

??? Java exception occurred: F:\Program
(Le fichier spécifié est introuvable)

Tim Placek replied on : 12 of 20

We are also having problems with R2010a MATLAB being unable to produce valid PDF file structures. The HTML publications are fine except they don’t adhere to wrapping long lines. If you have any suggestions we would appreciate it as this is our main means of having our students submit exam solutions.

Michael Katz replied on : 13 of 20

I’m not sure what you mean by “valid PDF structures.” Please open a technical support request, and can help work around it, or file a bug so we can fix the issue. Thanks.

Cody Cziesler replied on : 14 of 20

I’m having the same problem as Tim. Publishing to a PDF when the output of a snippet of code is longer than the page width causes the output to be cut off at the right edge of the screen.

Michael Katz replied on : 15 of 20


Thanks, I think I understand the problem better now. Please contact technical support, and I’ll file a bug for the developers.

Ethan M replied on : 16 of 20

I use Matlab some for publishing. Report generation is great for alots of applications. I can get many figures into the *.html or *.pdf report files. However, I have observed that there is a memory leak in matlab during report regeneration and that trying to save many images results in errors. Any suggestion regarding this?

Michael Katz replied on : 17 of 20


No there should not be a memory leak. Please contact technical support so they can follow up with the developer and fix any bugs, if necessary.

Peter replied on : 18 of 20

Hello Everyone,

I’m currently working on the TargetLink Automatic Documentation Generation. In addition, I am able to convert document in to the PDF and RTF formate but I required document in Word or Doc format. The actual problem is that I can able to convert document in to the Word format but it works only in my computer but it doesn’t work in the others computer because the images can’t display in the other computer. So if you have a solution for my problem then please mail me……..

Thanks in advance

Andrew replied on : 19 of 20

Is there a way to modify the font sizes when publishing to PDF? I would like to make my section headings to have a smaller font size.