2

meteor を利用したサイトからページの pdf を作成しようとしています。このページには、かなりのスタイルといくつかの d3 チャートが含まれています。私は自分の目標を達成するためにchipcastledotcom:jspdfとを追加しました。new3rs:html2canvas

私の計画は、html2canvas を jsPDF の.addImage()機能と組み合わせて使用​​して、グラフを pdf に追加することです。私の目標に向けた最初のステップとして、Web ページ (ロゴ) に既存の画像を取り、新しく作成したキャンバス要素に描画し、html2canvas 内で呼び出して、jsPDF の関数canvas.toDataURL('image/jpg')の引数として使用しようとしています。.addImage()

img最終的に、ロゴ画像は、d3 チャートを要素に変換して作成した画像に置き換えられます。私の問題は、pdf が生成されているが、画像が空白であることです。

サイトのユーザーとしてpdf生成を呼び出す前に、画像がWebページにはっきりと表示されるため、画像の負荷の問題ではないと思います。

私が取得したデータのURLは以下です。=私が戻ってきたデータURLの最後は、私にはまったくtoDataURL()正しく見えません(ただし、何を期待すべきかは本当にわかりません):

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t+KAAAU+UlEQVR4Xu3VAQ0AAAjDMPBvGh0sxcF7ku84AgQIECBA4L3Avk8gAAECBAgQIDAG3RMQIECAAIGAgEEPlCgCAQIECBAw6H6AAAECBAgEBAx6oEQRCBAgQICAQfcDBAgQIEAgIGDQAyWKQIAAAQIEDLofIECAAAECAQGDHihRBAIECBAgYND9AAECBAgQCAgY9ECJIhAgQIAAAYPuBwgQIECAQEDAoAdKFIEAAQIECBh0P0CAAAECBAICBj1QoggECBAgQMCg+wECBAgQIBAQMOiBEkUgQIAAAQIG3Q8QIECAAIGAgEEPlCgCAQIECBAw6H6AAAECBAgEBAx6oEQRCBAgQICAQfcDBAgQIEAgIGDQAyWKQIAAAQIEDLofIECAAAECAQGDHihRBAIECBAgYND9AAECBAgQCAgY9ECJIhAgQIAAAYPuBwgQIECAQEDAoAdKFIEAAQIECBh0P0CAAAECBAICBj1QoggECBAgQMCg+wECBAgQIBAQMOiBEkUgQIAAAQIG3Q8QIECAAIGAgEEPlCgCA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K5CYII=

これまたは私が理解していないことに対する修正/回避策はありtoDataURL()ますか?

これは、私が達成しようとしていることを示す jsfiddle (完全に動作します) です: https://jsfiddle.net/jdcast/tqfdkusp/

同様/同じ問題に関するこの以前の SO の質問に出くわしましたが、解決策がないように見えたことに注意してください。

ありがとう!

4

1 に答える 1