- Check the working directory when the app is deployed. The working directory might be different from the development environment. Therefore you may need to change the file location to the working directory or provide the full path to the water mark image
- Try adding try-catch block, this might help identifying the specific issue:
watermark on pdf report in deployed app will not work
1 view (last 30 days)
Show older comments
Following code for the watermark will not work in deployed app, but works fine in matlab app designer:
import mlreportgen.dom.*
%--------------------------------------------------------------------------
CustomProjName = compose("%s",app.Customer_ProjectName);
rpt = Document(CustomProjName,"pdf");
open(rpt);
currentLayout = rpt.CurrentPageLayout;
currentLayout.PageSize.Height = "297mm";
currentLayout.PageSize.Width = "210mm";
currentLayout.PageSize.Orientation = "portrait";
currentLayout.PageMargins.Top = '0.0mm';
wm = mlreportgen.dom.Watermark('Hexagons_word_GP_v4.png');
wm.Width = '205mm';
wm.Height = [];
rpt.CurrentPageLayout.Watermark = wm;
0 Comments
Answers (1)
Venkat Siddarth Reddy
on 26 Dec 2023
I understand that you are trying to add watermark to a report and generate it using MATLAB App designer. However, the above code is working in MATLAB App Designer, but not in the deployed/complied application.
From the code provided, I observed that the watermark image path given is just the file name.So please verify the following:
try
% Add existing code here
disp('Watermark added successfully');
catch ME
% Display an error message
disp('Error adding watermark:');
disp(ME.message);
end
To know more about error handling in MATLAB, please refer to the following documentation:
I hope this resolves the issue
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!