表データ抽出

このサンプルでは、PDFドキュメントから表形式でデータを抽出することができる表データ抽出機能の使用方法を紹介しています。 サイドバーに表データ抽出のパネルが表示されていない場合には、ツールバーにある「表データ抽出」アイコンをクリックしてください。 データを抽出したい領域を選択(ドラッグ)してください。選択された領域上のデータを表形式で抽出されます。 サイドバー上のオプションを調整することで抽出結果が変化します。範囲を選択し直す場合は、[キャンセル]ボタンをクリックしてください。 サイドバー上のボタンをクリックすることで、指定した形式(CSV、TSV、JSON、XLSX、XML、HTMLのいずれか)でデータをコピーまたはファイル保存できます。

window.onload = function() { //DsPdfViewer.LicenseKey = "***key***"; const viewer = new DsPdfViewer("#viewer", { supportApi: getSupportApiSettings(), restoreViewStateOnLoad: false, language: "ja" }); viewer.addDefaultPanels(); const panelHandle = viewer.addTableExtractionPanel(); viewer.expandPanel(panelHandle); // ツールバーのレイアウトを変更します viewer.toolbarLayout.viewer = { default: ["extract-table", "open", "$navigation", "$split", "text-selection", "pan", "$zoom", "$fullscreen", "download", "print", "rotate", "view-mode", "hide-annotations", "doc-properties", "about"], mobile: ["extract-table", "open", "$navigation", "$split", "text-selection", "pan", "$zoom", "$fullscreen", "download", "print", "rotate", "view-mode", "hide-annotations", "doc-properties", "about"], fullscreen: ["$fullscreen", "extract-table", "open", "$navigation", "$split", "text-selection", "pan", "$zoom", "$fullscreen", "download", "print", "rotate", "view-mode", "hide-annotations", "doc-properties", "about"] }; viewer.applyToolbarLayout(); var pdfUrlToOpen = "/diodocs/pdfviewer/demos/product-bundles/assets/pdf/red-negatives-table.pdf"; viewer.open(pdfUrlToOpen).then(function() { viewer.zoomMode = 1; }); }
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>表データ抽出</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="./src/styles.css"> <script src="/diodocs/pdfviewer/demos/product-bundles/build/dspdfviewer.js"></script> <script src="/diodocs/pdfviewer/demos/product-bundles/build/wasmSupportApi.js"></script> <script src="/diodocs/pdfviewer/demos/resource/js/init.js"></script> <script src="./src/app.js"></script> </head> <body> <div id="viewer"></div> </body> </html>
#viewer { height: 100%; }