Hi Zhilje,
1. I'm able to access your fork, and I'm wondering if the master branch is where you are seeing this error? Yes it is the master branch.
2. Just to confirm if the highlighted line is actually what causes the issue. I'm asking because I didn't see anything related to the "n()" function call. I looked at the code and it doesn't looks like this line is getting called when the Print button is clicked. I've tried to replicate the error again today after synching my fork with your master branch and I am no longer getting the error message. In the developer console I do see the following message "Canvas area exceeds the maximum limit (width * height > 16777216).". This seems to be the source of the error. I will provide some more details below on what I am trying to do below.
3. You mentioned this issue happens in the latest UI, I'm wondering if you can reproduce it using the legacy UI? The legacy UI can be found in branches starting with legacy. For example, "legacy/7.1" is the legacy UI used for WebViewer 7.1. This turned out to be a very good question.... see below.
4. Are there any ways you can share to us so that we can reproduce? In order to reproduce the problem I could provide you with a copy of an ipa that you can run on an iOS device. In order to do that I would need to know your Device ID (UDID) before I build the ipa file. Or we can do a screen sharing session and I can show you my code. This may be easier.
The structure of your code is different in the latest UI. What I've done is to Replace printPages in components\helpers\print.js with the following (in the old UI this replacement was done in components/PrintModal\PrintModal.js):
export const printPages = pages => {
let isCordovaPrinter = window.parent.cordova && window.parent.cordova.plugins.printer;
let printHandler;
if (isCordovaPrinter) {
/ printHandler = document.createElement('div');
printHandler.style.display = 'block';
printHandler.style.height = '100%';
} else {
printHandler = document.getElementById('print-handler');
printHandler.innerHTML = '';
}
const fragment = document.createDocumentFragment();
pages.forEach((page, index) => { // error Canvas area exceeds the maximum limit.....". happens in this code block
if (isCordovaPrinter) {
page.style.display = 'block';
page.style.maxWidth = '100%';
page.style.maxHeight = '100%';
page.style.width = '100%';
page.style.height = '100%';
page.style.objectFit = 'contain';
if (index > 0) {
page.style.pageBreakAfter = 'always';
}
}
fragment.appendChild(page);
});
printHandler.appendChild(fragment);
if (isCordovaPrinter) {
const html = document.createElement('html');
html.style.width = '100%';
html.style.height = '100%';
html.style.padding = 0;
html.style.margin = 0;
const body = document.createElement('body');
body.style.width = '100%';
body.style.height = '100%';
body.style.padding = 0;
body.style.margin = 0;
body.appendChild(printHandler);
html.appendChild(body);
window.parent.cordova.plugins.printer.print(html, 'Document.html');
} else if (isSafari && !isChromeOniOS) {
// Print for Safari browser. Makes Safari 11 consistently work.
document.execCommand('print');
} else {
window.print();
}
};
So I guess what I am really after is a solution that will work for printing on iOS within an Ionic application.
Note that if I remove my code to use the Cordova printer plugin i.e. just use Print.js as it is, then the process just fails silently when it gets to:
export const printPages = pages => {
const printHandler = document.getElementById('print-handler');
printHandler.innerHTML = '';
Kind regards,
David