MATLAB Spoken Here

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.

20 CommentsOldest to Newest

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.

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.

@OysterEngineer:
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.

@Daniel,

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?

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?

Sune

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:
java.io.FileNotFoundException: F:\Program
Files\MATLAB\R2011a\toolbox\matlab\codetools\private\fop_config.xml
(Le fichier spécifié est introuvable)

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.
Thanks,
Tim

@Tim,
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.

@Michael
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.

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?

@Ethan,

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.

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

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.

These postings are the author's and don't necessarily represent the opinions of MathWorks.