HTML zu PF über JSPDF, ▶ Zeichen wird beschädigtHTML

HTML-Programmierer
Anonymous
 HTML zu PF über JSPDF, ▶ Zeichen wird beschädigt

Post by Anonymous »

Ich versuche, ein HTML -Element zu konvertieren, das das ▶ Zeichen (U+25b6) enthält, aber in der PDF -Ausgabe ist es als %¶ . Egal was ich ausprobiert habe, ich konnte nicht herausfinden, wie ich es richtig anzeigen soll. Jede Hilfe wird sehr geschätzt.

Code: Select all

const {
jsPDF
} = window.jspdf;

let darkModeFlag = true;
async function getOutputDivClone() {
return document.getElementById("output").cloneNode(true)
}
async function exportPDF() {
const outputDiv = await getOutputDivClone();
const wrapBoth = document.createElement('div');
wrapBoth.style.backgroundColor = darkModeFlag ? '#1E1E1E' : '#FFFFFF';
outputDiv.style.backgroundColor = darkModeFlag ? '#1E1E1E' : '#FFFFFF';
wrapBoth.appendChild(outputDiv);
document.body.appendChild(wrapBoth);

const contentWidth = wrapBoth.offsetWidth;
const contentHeight = wrapBoth.offsetHeight;
let doc = new jsPDF({
orientation: contentWidth > contentHeight ? 'l' : 'p',
unit: 'px',
format: [contentWidth, contentHeight]
});
await new Promise(resolve => {
doc.html(wrapBoth, {
callback: resolve,
x: 0,
y: 0,
margin: [0, 0, 0, 0],
html2canvas: {
scale: 1,
logging: false,
allowTaint: false,
useCORS: true
}
});
});
wrapBoth.remove();
if (doc.internal.getNumberOfPages() > 1) {
for (let i = doc.internal.getNumberOfPages(); i > 1; i--) {
doc.deletePage(i);
}
}
doc.save(`test.pdf`);
}

document.addEventListener('DOMContentLoaded', async () => {
await exportPDF()
alert("done")
})< /code>
objinsp-summary {
cursor: pointer;
color: #d4d4d4;
}

summary {
list-style: none;
-webkit-appearance: none;
appearance: none;
}

summary::-webkit-details-marker {
display: none;
}

summary::marker {
display: none;
}

details>summary::before {
content: "▶";
display: inline-block;
margin-right: 5px;
transition: transform 0.2s;
}

details[open]>summary::before {
transform: rotate(90deg);
}< /code>



[>]


{}



log: ƒ log()


 length: 0


  name: "log"


[[Prototype]]: ƒ
anonymous()




error: ƒ error()


warn: ƒ warn()


info: ƒ info()


debug: ƒ debug()


clear: ƒ clear()


table: ƒ table()


count: ƒ count()


countReset: ƒ countReset()



assert: ƒ assert()


dir: ƒ dir()


dirxml: ƒ dirxml()


timeStamp: ƒ timeStamp()


trace: ƒ trace()


group:  ƒ group()


groupCollapsed: ƒ groupCollapsed()



groupEnd: ƒ groupEnd()


profile: ƒ profile()


profileEnd: ƒ profileEnd()



time: ƒ time()


timeEnd: ƒ timeEnd()


timeLog: ƒ timeLog()


[[Prototype]]: Object










Aus irgendeinem Grund gibt hier html2canvas einen CORS -Fehler

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post