MATLAB Answers

Need documentation for hgexport function

25 views (last 30 days)
Ivan Abraham
Ivan Abraham on 20 Jan 2017
Commented: Allen Goldstein on 21 Jan 2021
After being introduced in R2007 even in R2016 there is very little documentation for the hgexport() function. Many different sources seem to use the function in numerous and different ways. Where can I find a comprehensive account of the many ways hgexport can be used? Specifically R2016 has a built in export settings called "Documents", "Presentations", "default". I would like to use the hgexport() function to load the Presentations style and apply it.
s = hgexport('readstyle','Presentations')
Seems to not help.
Error using hgexport
Style 'Presentations' does not exist.
Error in hgexport

Answers (1)

Walter Roberson
Walter Roberson on 20 Jan 2017
hgexport('factorystyle') returns a built-in style.
exportsetupdlg.m checks the figure appdata 'Exportsetup' property to see if a style has been applied to the figure. If not then it looks for default style information and if not it initializes with factorystyle.
The settings you are looking at, Documents and Presentations, do not exist until the exportsetupdlg initialization is run. Internally it uses the names MSWord and PowerPoint
The style information for MSWord and PowerPoint is looked for in prefdir subdirectory ExportSetup in files MSWord.txt and PowerPoint.txt . It will write them there if it does not find them. So you could customize those files.
MSWord style defaults to the same as factorystyle.
PowerPoint style defaults to bold scaled fontsize 140 with fixed width lines.
Look near lines 1450 in exportsetupdlg.m
hgexport() can also be called with a figure, then a filename, then a style, then 'Format', then the name of one of the supported formats. The supported formats are extracted from the printtables() command which uses information about what is locally available. Look starting at roughly line 350 in filemenufcn.m
  1 Comment
Allen Goldstein
Allen Goldstein on 21 Jan 2021
If you want to use the screen resoluton, you need to change the resolution to 0.
style = hgexport('factorystyle'); % get the style
style.Resolution = 0; % Resolution = 0 means use the screen resolution

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by