diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-06-19 16:04:34 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-06-19 20:44:58 +0000 |
commit | b73ce7bcd72a97c780176d9f63681a5415c06422 (patch) | |
tree | 2e0b3b4f2996344101b9af67ce761708255b05ef /samples | |
parent | d3610056e36b9211e9ed3806a3f99a1184e9413e (diff) | |
download | pdfium-b73ce7bcd72a97c780176d9f63681a5415c06422.tar.xz |
Fixing metadata not read from linearized file.chromium/3136
This still won't work if the info dict is not on the first page
without first calling FPDFAvail_IsFormAvail or FPDFAvail_IsPageAvail,
as these are the methods that trigger parsing the rest of the data.
Bug: pdfium:664
Change-Id: I0b0193e415a1153dcfb8bfba0e0482da6b6ba53c
Reviewed-on: https://pdfium-review.googlesource.com/6610
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/pdfium_test.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index 86f6f89d24..14aa6c187d 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -74,12 +74,14 @@ enum OutputFormat { struct Options { Options() : show_config(false), + show_metadata(false), send_events(false), pages(false), md5(false), output_format(OUTPUT_NONE) {} bool show_config; + bool show_metadata; bool send_events; bool pages; bool md5; @@ -625,6 +627,8 @@ bool ParseCommandLine(const std::vector<std::string>& args, const std::string& cur_arg = args[cur_idx]; if (cur_arg == "--show-config") { options->show_config = true; + } else if (cur_arg == "--show-metadata") { + options->show_metadata = true; } else if (cur_arg == "--send-events") { options->send_events = true; } else if (cur_arg == "--ppm") { @@ -1108,6 +1112,19 @@ void RenderPdf(const std::string& name, (void)FPDF_GetDocPermissions(doc.get()); + if (options.show_metadata) { + const char* metaTags[] = {"Title", "Author", "Subject", "Keywords", + "Creator", "Producer", "CreationDate", "ModDate"}; + for (const char* metaTag : metaTags) { + char metaBuffer[4096]; + int len = FPDF_GetMetaText(doc.get(), metaTag, metaBuffer, 4096); + printf("%-12s = %ls (%d bytes)\n", metaTag, + GetPlatformWString(reinterpret_cast<unsigned short*>(metaBuffer)) + .c_str(), + len); + } + } + std::unique_ptr<void, FPDFFormHandleDeleter> form( FPDFDOC_InitFormFillEnvironment(doc.get(), &form_callbacks)); form_callbacks.form_handle = form.get(); |