diff --git a/public/resume-5.html b/public/resume-5.html
index 3ca6bc2..bb0c50a 100644
--- a/public/resume-5.html
+++ b/public/resume-5.html
@@ -1034,6 +1034,35 @@
photoReady = Promise.resolve(null);
}
+ function flattenColors(el) {
+ var s = getComputedStyle(el);
+ var props = ['color','background-color','border-color','border-top-color','border-bottom-color','border-left-color','border-right-color','box-shadow','background'];
+ var originals = {};
+ props.forEach(function(p) {
+ var v = s.getPropertyValue(p);
+ if (v && v.indexOf('color-mix') !== -1) {
+ originals[p] = el.style.getPropertyValue(p);
+ el.style.setProperty(p, v);
+ }
+ });
+ var children = el.children;
+ for (var i = 0; i < children.length; i++) {
+ flattenColors(children[i]);
+ }
+ return originals;
+ }
+
+ function restoreColors(el, originals) {
+ Object.keys(originals).forEach(function(p) {
+ if (originals[p]) el.style.setProperty(p, originals[p]);
+ else el.style.removeProperty(p);
+ });
+ var children = el.children;
+ for (var i = 0; i < children.length; i++) {
+ restoreColors(children[i], originals);
+ }
+ }
+
photoReady.then(function (dataUrl) {
console.log('[PDF] step 1: photo ready, dataUrl:', dataUrl ? 'yes (' + dataUrl.length + ' chars)' : 'null');
if (dataUrl && photo) photo.setAttribute('src', dataUrl);
@@ -1046,6 +1075,8 @@
})
.then(function () {
console.log('[PDF] step 4: html2pdf loaded, type:', typeof html2pdf);
+ console.log('[PDF] step 4: flattening color-mix() values...');
+ var snapshot = flattenColors(doc);
console.log('[PDF] step 4: starting generation...');
return html2pdf().from(doc).set({
margin: 10,
@@ -1053,7 +1084,9 @@
image: { type: 'jpeg', quality: 0.95 },
html2canvas: { scale: 2, useCORS: true, backgroundColor: '#fff' },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
- }).save();
+ }).save().then(function() {
+ restoreColors(doc, snapshot);
+ });
})
.then(function (result) {
console.log('[PDF] step 5: generation COMPLETE, result:', result);
diff --git a/src/pages/resume-5.html b/src/pages/resume-5.html
index 7c4fea1..f477d6c 100644
--- a/src/pages/resume-5.html
+++ b/src/pages/resume-5.html
@@ -903,6 +903,35 @@
photoReady = Promise.resolve(null);
}
+ function flattenColors(el) {
+ var s = getComputedStyle(el);
+ var props = ['color','background-color','border-color','border-top-color','border-bottom-color','border-left-color','border-right-color','box-shadow','background'];
+ var originals = {};
+ props.forEach(function(p) {
+ var v = s.getPropertyValue(p);
+ if (v && v.indexOf('color-mix') !== -1) {
+ originals[p] = el.style.getPropertyValue(p);
+ el.style.setProperty(p, v);
+ }
+ });
+ var children = el.children;
+ for (var i = 0; i < children.length; i++) {
+ flattenColors(children[i]);
+ }
+ return originals;
+ }
+
+ function restoreColors(el, originals) {
+ Object.keys(originals).forEach(function(p) {
+ if (originals[p]) el.style.setProperty(p, originals[p]);
+ else el.style.removeProperty(p);
+ });
+ var children = el.children;
+ for (var i = 0; i < children.length; i++) {
+ restoreColors(children[i], originals);
+ }
+ }
+
photoReady.then(function (dataUrl) {
console.log('[PDF] step 1: photo ready, dataUrl:', dataUrl ? 'yes (' + dataUrl.length + ' chars)' : 'null');
if (dataUrl && photo) photo.setAttribute('src', dataUrl);
@@ -915,6 +944,8 @@
})
.then(function () {
console.log('[PDF] step 4: html2pdf loaded, type:', typeof html2pdf);
+ console.log('[PDF] step 4: flattening color-mix() values...');
+ var snapshot = flattenColors(doc);
console.log('[PDF] step 4: starting generation...');
return html2pdf().from(doc).set({
margin: 10,
@@ -922,7 +953,9 @@
image: { type: 'jpeg', quality: 0.95 },
html2canvas: { scale: 2, useCORS: true, backgroundColor: '#fff' },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
- }).save();
+ }).save().then(function() {
+ restoreColors(doc, snapshot);
+ });
})
.then(function (result) {
console.log('[PDF] step 5: generation COMPLETE, result:', result);