質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
SVG

SVGは、XMLを基盤とした2Dベクター画像記述言語。画像を線・面といった図形の集合体として扱うベクター画像のため、環境に適した表示が可能です。アニメーション機能もサポートされており、簡単なインタラクティブコンテンツ作成もできます。

PDF

PDF(Portable Document Format)とはISOによって国際標準として制定されている電子ドキュメント用の拡張子です。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

Q&A

1回答

635閲覧

svgのあるwebページをPDFダウンロード

yotaro-58

総合スコア14

SVG

SVGは、XMLを基盤とした2Dベクター画像記述言語。画像を線・面といった図形の集合体として扱うベクター画像のため、環境に適した表示が可能です。アニメーション機能もサポートされており、簡単なインタラクティブコンテンツ作成もできます。

PDF

PDF(Portable Document Format)とはISOによって国際標準として制定されている電子ドキュメント用の拡張子です。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

0グッド

0クリップ

投稿2020/11/13 06:43

svgでグラフを描写しているページがあるのですが、このページをそのままjavascriptなどでPDFにしてダウンロードしたいです。
webページ上にボタンを設けてそのボタンをクリックするとPDFがダウンロードされるようにしたいです。

サンプルですが、ページは以下のような感じです。

<html> <head> <title>test</title> </head> <body> <h2>test1</h2> <svg width=300 height=300 id="mysvg1"> <rect width="300" height="300" fill="black" stroke="lime" /> <polyline stroke="aqua" points="150,0 150,300" /> <polyline stroke="aqua" points="0,150 300,150" /> <circle cx="150" cy="150" r="5" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="10" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="15" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="20" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="25" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="30" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="35" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="40" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="45" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="50" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="75" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="100" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="125" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="150" stroke="aqua" stroke-width="1" fill="none" /> <circle cx="150" cy="150" r="175" stroke="aqua" stroke-width="1" fill="none" /> <text x="25" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">250</text> <text x="50" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">200</text> <text x="75" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">150</text> <text x="100" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">100</text> <text x="125" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">50</text> <text x="175" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">50</text> <text x="200" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">100</text> <text x="225" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">150</text> <text x="250" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">200</text> <text x="275" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">250</text> <text x="160" y="25" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">250</text> <text x="160" y="50" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">200</text> <text x="160" y="75" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">150</text> <text x="160" y="100" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">100</text> <text x="160" y="125" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">50</text> <text x="160" y="175" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">50</text> <text x="160" y="200" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">100</text> <text x="160" y="225" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">150</text> <text x="160" y="250" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">200</text> <text x="160" y="275" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">250</text> </svg> <h2>test2</h2> <svg width=300 height=300 id="mysvg2"> <rect width="300" height="300" fill="black" stroke="lime" /> <polyline stroke="aqua" points="150,0 150,300" /> <polyline stroke="aqua" points="0,150 300,150" /> <circle cx="150" cy="150" r="175" stroke="aqua" stroke-width="1" fill="none" /> <text x="25" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">250</text> <text x="50" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">200</text> <text x="75" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">150</text> <text x="100" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">100</text> <text x="125" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">50</text> <text x="175" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">50</text> <text x="200" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">100</text> <text x="225" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">150</text> <text x="250" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">200</text> <text x="275" y="160" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">250</text> <text x="160" y="25" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">250</text> <text x="160" y="50" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">200</text> <text x="160" y="75" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">150</text> <text x="160" y="100" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">100</text> <text x="160" y="125" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">50</text> <text x="160" y="175" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">50</text> <text x="160" y="200" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">100</text> <text x="160" y="225" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">150</text> <text x="160" y="250" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">200</text> <text x="160" y="275" width="10" fill="aqua" font-size="10" text-anchor="middle" dominant-baseline="central">250</text> </svg> </body> </html>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

jsでpdfを扱うライブラリはいくつかあるようなのでそれを利用しても良いでしょう

ただWin10とかだと標準でMicrosoft Print to PDFドライバとか実装されてますので
そちらでpdf化した方が速いような気がします

投稿2020/11/13 06:56

yambejp

総合スコア114583

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問