J'essaie d'utiliser le Javascript pour exporter les amCharts au format PDF en suivantGarbled Texte dans AmCharts Exporter au format PDF
[Codepen](https://codepen.io/team/amcharts/pen/35076c4d7b6eef7764dacc61f72adadc)
les étapes de ce site Web, mais le PDF a le texte indéchiffrable (mots chinois), je veux utiliser UTF -8, comment puis-je le réparer? Et pourquoi le degré de résolution du graphique est si bas? Merci. enter image description here
html
<h2 id="OPASS" class="display-5 col-md-offset-4 col-md-12">測試圖表</h2>
javascript
var downloadPDF = function() {
console.log("Starting export...");
var ids = ["chartdiv", "Passion_chart", "Anchor_chart", "Switch_chart", "Synergy_chart"];
var charts = {}, charts_remaining = ids.length;
for (var i = 0; i < ids.length; i++) {
for (var x = 0; x < AmCharts.charts.length; x++) {
if (AmCharts.charts[x].div.id == ids[i])
charts[ids[i]] = AmCharts.charts[x];
}
}
for (var x in charts) {
if (charts.hasOwnProperty(x)) {
var chart = charts[x];
chart["export"].capture({}, function() {
this.toJPG({}, function(data) {
// Save chart data into chart object itself
this.setup.chart.exportedImage = data;
// Reduce the remaining counter
charts_remaining--;
// Check if we got all of the charts
if (charts_remaining == 0) {
// Yup, we got all of them
// Let's proceed to putting PDF together
generatePDF();
}
});
});
}
}
function generatePDF() {
// Log
console.log("Generating PDF...");
// Initiliaze a PDF layout
var layout = {
"content": []
};
// Let's add a custom title
layout.content.push({
"text": document.getElementById("OPASS").innerHTML,
"fontSize": 24
});
// Now let's grab actual content from our <p> intro tag
layout.content.push({
"text": document.getElementById("intro").innerHTML
});
// Add bigger chart
layout.content.push({
"image": charts["chartdiv"].exportedImage,
"fit": [523, 300]
});
chart["export"].toPDF(layout, function(data) {
this.download(data, "application/pdf","amCharts.pdf");
});
}
}
vous avez probablement fait quelque chose de mal dans votre code (ligne 37?) –
Désolé, je WNAT demander où est le code ligne 37? – Amber
c'est ce que je veux savoir: p voir, vous n'avez pas posté de code qui a un problème, vous avez posté un lien vers le code qui fonctionne comme nécessaire ... bien sûr, vous ne pouvez pas déboguer le problème vous-même Ne sais pas assez pour le faire, mais personne ne peut déboguer du code qui n'existe pas –