MATLAB: How can a preserve hyperlinks on figures when saving them for use outside of matlab

figurehyperlinkjavalabel;printsaveurlweb

I want to add some hyperlinks to some of the datapoints on my figures. Robert Uhlig helped me out and now I can do it on a figure opened by matlab, using the code written in the answer of this question. This one:
x=[1:1:5];
a=rand*10;
y=[2,a,3,5,4];
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
plot(x,y)
hold on
plot(2,a,'.','markersize',40)
% Create and display the text label
url = 'cam.ac.uk';
labelStr = ['<html><a href="">' 'SPEC' '</a></html>'];
jLabel = javaObjectEDT('javax.swing.JLabel', labelStr);
% Adjust label position
ah = gca;
set(ah,'Units','pixels')
axesPos = get(ah,'Position');
drawnow(); % necessary to fix the axes positions
Px = round(ah.Position(1) + ah.Position(3)*(2-ah.XLim(1))/(ah.XLim(2)-ah.XLim(1))); % x-position is alway 2
Py = round(ah.Position(2) + ah.Position(4)*(a-ah.YLim(1))/(ah.YLim(2)-ah.YLim(1)));
[hjLabel,hContainer] = javacomponent(jLabel, [Px-30/2,Py+10,30,20], gcf); % center for x, move 5px above y
set(ah,'Units','normalized')
% Modify the mouse cursor when hovering on the label
hjLabel.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.HAND_CURSOR));
% Set the label's tooltip
hjLabel.setToolTipText(['Visit the ' url ' website']);
% Set the mouse-click callback
set(hjLabel, 'MouseClickedCallback', @(h,e)web(['http://' url], '-browser'))
However, I also want to save this figure to be able to use it without running matlab. I have not found a file format yet which preserves the hyperlink in a working condition.
So I would like to be able to save the figure, close matlab, and open the figure independent of matlab, with the working hyperlink on it.
What should I do to achieve this?

Best Answer

You can either export the figure to a HTML file, such that the diagrams appear as graphics and append the link manually. Or A PDF should be working also. But I assume, embedding a link, which is contained in a Java control in a PDF will not work directly.
Related Question