readPDFFormData
PDF フォームからのデータの読み取り
説明
例
PDF フォームからのデータの読み取り
readPDFFormData
を使用して、weatherReportForm1.pdf
のフォーム フィールドからデータを読み取ります。関数は、PDF フォーム フィールドからのデータを格納する struct を返します。
filename = "weatherReportForm1.pdf";
data = readPDFFormData(filename)
data = struct with fields:
event_type: "Thunderstorm Wind"
event_narrative: "Large tree down between Plantersville and Nettleton."
複数のフォームからのデータの読み取り
ファイル データストアを使用して、複数のファイルのフォーム フィールドからデータを読み取ります。
気象レポート フォーム用のファイル データストアを作成します。フォームは "weatherReportFormN.pdf"
という名前です。ここで、N
はフォームの番号です。ワイルドカード "*" を使用してファイル名を指定し、この構造のファイル名をすべて見つけます。読み取り関数を readPDFFormData
に指定するには、関数ハンドルを使用してこの関数を fileDatastore
に入力します。
fds = fileDatastore("weatherReportForm*.pdf",'ReadFcn',@readPDFFormData)
fds = FileDatastore with properties: Files: { ' .../tp7aac4f0b/textanalytics-ex39762425/weatherReportForm1.pdf'; ' .../tp7aac4f0b/textanalytics-ex39762425/weatherReportForm2.pdf'; ' .../tp7aac4f0b/textanalytics-ex39762425/weatherReportForm3.pdf' ... and 1 more } Folders: { '/tmp/Bdoc24a_2528353_921476/tp7aac4f0b/textanalytics-ex39762425' } UniformRead: 0 ReadMode: 'file' BlockSize: Inf PreviewFcn: @readPDFFormData SupportedOutputFormats: ["txt" "csv" "dat" "asc" "xlsx" "xls" "parquet" "parq" "png" "jpg" "jpeg" "tif" "tiff" "wav" "flac" "ogg" "opus" "mp3" "mp4" "m4a"] ReadFcn: @readPDFFormData AlternateFileSystemRoots: {}
データストア内のファイルをループ処理して、各 PDF フォームを読み取ります。
data = []; while hasdata(fds) textData = read(fds); data = [data; textData]; end data
data=4×1 struct array with fields:
event_type
event_narrative
入力引数
filename
— ファイルの名前
string スカラー | 文字ベクトル
ファイルの名前。string スカラーまたは文字ベクトルとして指定します。
readPDFFormData
は、AcroForm PDF ファイル (インタラクティブ フォーム) のみをサポートします。
データ型: string
| char
password
— PDF ファイルを開くためのパスワード
string スカラー | 文字ベクトル
PDF ファイルを開くためのパスワード。文字ベクトルまたは string スカラーとして指定します。
例: "skroWhtaM"
データ型: string
| char
出力引数
data
— 出力 struct
struct
出力 struct。data
フィールドは、PDF のフォーム フィールドの名前に対応します。フォーム フィールド名が有効な struct フィールド名ではなかった場合、関数によってそれらが自動的に編集され、有効な名前が作成されます。
バージョン履歴
R2018a で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)