- 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 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Venkat Siddarth Reddy
2023-12-26
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!