pdf_engine.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef PDF_PDF_ENGINE_H_
  5. #define PDF_PDF_ENGINE_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include <string>
  9. #include <vector>
  10. #include "base/callback.h"
  11. #include "base/containers/span.h"
  12. #include "base/time/time.h"
  13. #include "base/values.h"
  14. #include "build/build_config.h"
  15. #include "pdf/document_layout.h"
  16. #include "printing/mojom/print.mojom-forward.h"
  17. #include "third_party/abseil-cpp/absl/types/optional.h"
  18. #include "third_party/skia/include/core/SkColor.h"
  19. #include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
  20. #include "ui/base/window_open_disposition.h"
  21. #include "ui/gfx/geometry/point_f.h"
  22. #include "ui/gfx/geometry/rect.h"
  23. #include "ui/gfx/geometry/rect_f.h"
  24. #if BUILDFLAG(IS_WIN)
  25. #include <windows.h>
  26. #endif
  27. class SkBitmap;
  28. namespace blink {
  29. class WebInputEvent;
  30. struct WebPrintParams;
  31. } // namespace blink
  32. namespace gfx {
  33. class Point;
  34. class Rect;
  35. class Size;
  36. class SizeF;
  37. class Vector2d;
  38. } // namespace gfx
  39. namespace chrome_pdf {
  40. class Thumbnail;
  41. class UrlLoader;
  42. struct AccessibilityActionData;
  43. struct AccessibilityFocusInfo;
  44. struct AccessibilityLinkInfo;
  45. struct AccessibilityHighlightInfo;
  46. struct AccessibilityImageInfo;
  47. struct AccessibilityTextFieldInfo;
  48. struct AccessibilityTextRunInfo;
  49. struct DocumentAttachmentInfo;
  50. struct DocumentMetadata;
  51. using SendThumbnailCallback = base::OnceCallback<void(Thumbnail)>;
  52. enum class FontMappingMode {
  53. // Do not perform font mapping.
  54. kNoMapping,
  55. // Perform font mapping in renderer processes using Blink/content APIs.
  56. kBlink,
  57. };
  58. enum class DocumentPermission {
  59. kCopy,
  60. kCopyAccessible,
  61. kPrintLowQuality,
  62. kPrintHighQuality,
  63. };
  64. // Do one time initialization of the SDK.
  65. // If `enable_v8` is false, then the PDFEngine will not be able to run
  66. // JavaScript.
  67. void InitializeSDK(bool enable_v8, FontMappingMode font_mapping_mode);
  68. // Tells the SDK that we're shutting down.
  69. void ShutdownSDK();
  70. // This class encapsulates a PDF rendering engine.
  71. class PDFEngine {
  72. public:
  73. // Maximum number of parameters a nameddest view can contain.
  74. static constexpr size_t kMaxViewParams = 4;
  75. enum class FocusFieldType {
  76. // Focus is not on any form field.
  77. kNoFocus,
  78. // Focus is on a form text field or form combobox text field.
  79. kText,
  80. // Focus is on a non-text field.
  81. kNonText,
  82. };
  83. // Named destination in a document.
  84. struct NamedDestination {
  85. // 0-based page number.
  86. unsigned long page;
  87. // View fit type (see table 8.2 "Destination syntax" on page 582 of PDF
  88. // Reference 1.7). Empty string if not present.
  89. std::string view;
  90. // Number of parameters for the view.
  91. unsigned long num_params;
  92. // Parameters for the view. Their meaning depends on the `view` and their
  93. // number is defined by `num_params` but is at most `kMaxViewParams`. Note:
  94. // If a parameter stands for the x/y coordinates, it should be transformed
  95. // into the corresponding in-screen coordinates before it's sent to the
  96. // viewport.
  97. float params[kMaxViewParams];
  98. // A string of parameters for view fit type XYZ in the format of "x,y,zoom",
  99. // where x and y parameters are the in-screen coordinates and zoom is the
  100. // zoom level. If a parameter is "null", then current value of that
  101. // parameter in the viewport should be retained. Note: This string is empty
  102. // if the view's fit type is not XYZ.
  103. std::string xyz_params;
  104. };
  105. // The interface that's provided to the rendering engine.
  106. class Client {
  107. public:
  108. virtual ~Client() = default;
  109. // Proposes a document layout to the client. For the proposed layout to
  110. // become effective, the client must call PDFEngine::ApplyDocumentLayout()
  111. // with the new layout options (although this call can be asynchronous).
  112. virtual void ProposeDocumentLayout(const DocumentLayout& layout) = 0;
  113. // Informs the client that the given rect needs to be repainted.
  114. virtual void Invalidate(const gfx::Rect& rect) {}
  115. // Informs the client to scroll the plugin area by the given offset.
  116. virtual void DidScroll(const gfx::Vector2d& offset) {}
  117. // Scroll the horizontal/vertical scrollbars to a given position.
  118. // Values are in screen coordinates, where 0 is the top/left of the document
  119. // and a positive value is the distance in pixels from that line.
  120. virtual void ScrollToX(int x_screen_coords) {}
  121. virtual void ScrollToY(int y_screen_coords) {}
  122. // Scroll by a given delta relative to the current position.
  123. virtual void ScrollBy(const gfx::Vector2d& delta) {}
  124. // Scroll to zero-based `page`.
  125. virtual void ScrollToPage(int page) {}
  126. // Navigate to the given url.
  127. virtual void NavigateTo(const std::string& url,
  128. WindowOpenDisposition disposition) {}
  129. // Navigate to the given destination. Zero-based `page` index. `x`, `y` and
  130. // `zoom` are optional and can be nullptr.
  131. virtual void NavigateToDestination(int page,
  132. const float* x,
  133. const float* y,
  134. const float* zoom) {}
  135. // Updates the cursor.
  136. virtual void UpdateCursor(ui::mojom::CursorType new_cursor_type) {}
  137. // Updates the tick marks in the vertical scrollbar.
  138. virtual void UpdateTickMarks(const std::vector<gfx::Rect>& tickmarks) {}
  139. // Updates the number of find results for the current search term. If
  140. // there are no matches 0 should be passed in. Only when the plugin has
  141. // finished searching should it pass in the final count with `final_result`
  142. // set to true.
  143. virtual void NotifyNumberOfFindResultsChanged(int total,
  144. bool final_result) {}
  145. // Updates the index of the currently selected search item. Set
  146. // `final_result` to true only when there is no subsequent
  147. // `NotifyNumberOfFindResultsChanged()` call.
  148. virtual void NotifySelectedFindResultChanged(int current_find_index,
  149. bool final_result) {}
  150. virtual void NotifyTouchSelectionOccurred() {}
  151. // Prompts the user for a password to open this document. The callback is
  152. // called when the password is retrieved.
  153. virtual void GetDocumentPassword(
  154. base::OnceCallback<void(const std::string&)> callback) {}
  155. // Play a "beeping" sound.
  156. virtual void Beep() {}
  157. // Puts up an alert with the given message.
  158. virtual void Alert(const std::string& message) {}
  159. // Puts up a confirm with the given message, and returns true if the user
  160. // presses OK, or false if they press cancel.
  161. virtual bool Confirm(const std::string& message) = 0;
  162. // Puts up a prompt with the given message and default answer and returns
  163. // the answer.
  164. virtual std::string Prompt(const std::string& question,
  165. const std::string& default_answer) = 0;
  166. // Returns the url of the pdf.
  167. virtual std::string GetURL() = 0;
  168. // Send an email.
  169. virtual void Email(const std::string& to,
  170. const std::string& cc,
  171. const std::string& bcc,
  172. const std::string& subject,
  173. const std::string& body) {}
  174. // Put up the print dialog.
  175. virtual void Print() {}
  176. // Submit the data using HTTP POST.
  177. virtual void SubmitForm(const std::string& url,
  178. const void* data,
  179. int length) {}
  180. // Creates and returns new URL loader for partial document requests.
  181. virtual std::unique_ptr<UrlLoader> CreateUrlLoader() = 0;
  182. // Searches the given string for "term" and returns the results. Unicode-
  183. // aware.
  184. struct SearchStringResult {
  185. int start_index;
  186. int length;
  187. };
  188. virtual std::vector<SearchStringResult> SearchString(
  189. const char16_t* string,
  190. const char16_t* term,
  191. bool case_sensitive) = 0;
  192. // Notifies the client that the document has finished loading.
  193. virtual void DocumentLoadComplete() {}
  194. // Notifies the client that the document has failed to load.
  195. virtual void DocumentLoadFailed() {}
  196. // Notifies that an unsupported feature in the PDF was encountered.
  197. virtual void DocumentHasUnsupportedFeature(const std::string& feature) {}
  198. // Notifies the client about document load progress.
  199. virtual void DocumentLoadProgress(uint32_t available, uint32_t doc_size) {}
  200. // Notifies the client about focus changes for form fields.
  201. virtual void FormFieldFocusChange(FocusFieldType type) {}
  202. // Returns true if the plugin has been opened within print preview.
  203. virtual bool IsPrintPreview() const = 0;
  204. // Get the background color of the PDF.
  205. virtual SkColor GetBackgroundColor() const = 0;
  206. // Sets selection status.
  207. virtual void SetIsSelecting(bool is_selecting) {}
  208. virtual void SelectionChanged(const gfx::Rect& left,
  209. const gfx::Rect& right) {}
  210. // The caret position in the editable form (if applicable) changed.
  211. virtual void CaretChanged(const gfx::Rect& caret_rect) {}
  212. // Notifies the client that the PDF has been edited.
  213. virtual void EnteredEditMode() {}
  214. // Notifies the client about focus changes for the document.
  215. virtual void DocumentFocusChanged(bool document_has_focus) {}
  216. // Sets selected text.
  217. virtual void SetSelectedText(const std::string& selected_text) = 0;
  218. // Sets the link under cursor.
  219. virtual void SetLinkUnderCursor(const std::string& link_under_cursor) = 0;
  220. // If the link cannot be converted to JS payload struct, then it is not
  221. // possible to pass it to JS. In this case, ignore the link like other PDF
  222. // viewers.
  223. // See https://crbug.com/312882 for an example.
  224. virtual bool IsValidLink(const std::string& url) = 0;
  225. };
  226. virtual ~PDFEngine() = default;
  227. // Most of these functions are similar to the Pepper functions of the same
  228. // name, so not repeating the description here unless it's different.
  229. virtual void PageOffsetUpdated(const gfx::Vector2d& page_offset) = 0;
  230. virtual void PluginSizeUpdated(const gfx::Size& size) = 0;
  231. virtual void ScrolledToXPosition(int position) = 0;
  232. virtual void ScrolledToYPosition(int position) = 0;
  233. // Paint is called a series of times. Before these n calls are made, PrePaint
  234. // is called once. After Paint is called n times, PostPaint is called once.
  235. virtual void PrePaint() = 0;
  236. virtual void Paint(const gfx::Rect& rect,
  237. SkBitmap& image_data,
  238. std::vector<gfx::Rect>& ready,
  239. std::vector<gfx::Rect>& pending) = 0;
  240. virtual void PostPaint() = 0;
  241. virtual bool HandleInputEvent(const blink::WebInputEvent& event) = 0;
  242. virtual void PrintBegin() = 0;
  243. virtual std::vector<uint8_t> PrintPages(
  244. const std::vector<int>& page_numbers,
  245. const blink::WebPrintParams& print_params) = 0;
  246. virtual void PrintEnd() = 0;
  247. virtual void StartFind(const std::string& text, bool case_sensitive) = 0;
  248. virtual bool SelectFindResult(bool forward) = 0;
  249. virtual void StopFind() = 0;
  250. virtual void ZoomUpdated(double new_zoom_level) = 0;
  251. virtual void RotateClockwise() = 0;
  252. virtual void RotateCounterclockwise() = 0;
  253. virtual bool IsReadOnly() const = 0;
  254. virtual void SetReadOnly(bool enable) = 0;
  255. virtual void SetDocumentLayout(DocumentLayout::PageSpread page_spread) = 0;
  256. virtual void DisplayAnnotations(bool display) = 0;
  257. // Applies the document layout options proposed by a call to
  258. // PDFEngine::Client::ProposeDocumentLayout(), returning the overall size of
  259. // the new effective layout.
  260. virtual gfx::Size ApplyDocumentLayout(
  261. const DocumentLayout::Options& options) = 0;
  262. virtual std::string GetSelectedText() = 0;
  263. // Returns true if focus is within an editable form text area.
  264. virtual bool CanEditText() const = 0;
  265. // Returns true if focus is within an editable form text area and the text
  266. // area has text.
  267. virtual bool HasEditableText() const = 0;
  268. // Replace selected text within an editable form text area with another
  269. // string. If there is no selected text, append the replacement text after the
  270. // current caret position.
  271. virtual void ReplaceSelection(const std::string& text) = 0;
  272. // Methods to check if undo/redo is possible, and to perform them.
  273. virtual bool CanUndo() const = 0;
  274. virtual bool CanRedo() const = 0;
  275. virtual void Undo() = 0;
  276. virtual void Redo() = 0;
  277. // Handles actions invoked by Accessibility clients.
  278. virtual void HandleAccessibilityAction(
  279. const AccessibilityActionData& action_data) = 0;
  280. virtual std::string GetLinkAtPosition(const gfx::Point& point) = 0;
  281. // Checks the permissions associated with this document.
  282. virtual bool HasPermission(DocumentPermission permission) const = 0;
  283. virtual void SelectAll() = 0;
  284. // Gets the list of DocumentAttachmentInfo from the document.
  285. virtual const std::vector<DocumentAttachmentInfo>&
  286. GetDocumentAttachmentInfoList() const = 0;
  287. // Gets the content of an attachment by the attachment's `index`. `index`
  288. // must be in the range of [0, attachment_count-1), where `attachment_count`
  289. // is the number of attachments embedded in the document.
  290. // The caller of this method is responsible for checking whether the
  291. // attachment is readable, attachment size is not 0 byte, and the return
  292. // value's size matches the corresponding DocumentAttachmentInfo's
  293. // `size_bytes`.
  294. virtual std::vector<uint8_t> GetAttachmentData(size_t index) = 0;
  295. // Gets metadata about the document.
  296. virtual const DocumentMetadata& GetDocumentMetadata() const = 0;
  297. // Gets the number of pages in the document.
  298. virtual int GetNumberOfPages() const = 0;
  299. // Gets the named destination by name.
  300. virtual absl::optional<PDFEngine::NamedDestination> GetNamedDestination(
  301. const std::string& destination) = 0;
  302. // Gets the index of the most visible page, or -1 if none are visible.
  303. virtual int GetMostVisiblePage() = 0;
  304. // Gets the rectangle of the page not including the shadow.
  305. virtual gfx::Rect GetPageBoundsRect(int index) = 0;
  306. // Gets the rectangle of the page excluding any additional areas.
  307. virtual gfx::Rect GetPageContentsRect(int index) = 0;
  308. // Returns a page's rect in screen coordinates, as well as its surrounding
  309. // border areas and bottom separator.
  310. virtual gfx::Rect GetPageScreenRect(int page_index) const = 0;
  311. // Set color / grayscale rendering modes.
  312. virtual void SetGrayscale(bool grayscale) = 0;
  313. // Get the number of characters on a given page.
  314. virtual int GetCharCount(int page_index) = 0;
  315. // Get the bounds in page pixels of a character on a given page.
  316. virtual gfx::RectF GetCharBounds(int page_index, int char_index) = 0;
  317. // Get a given unicode character on a given page.
  318. virtual uint32_t GetCharUnicode(int page_index, int char_index) = 0;
  319. // Given a start char index, find the longest continuous run of text that's
  320. // in a single direction and with the same text style. Return a filled out
  321. // AccessibilityTextRunInfo on success or absl::nullopt on failure. e.g. When
  322. // `start_char_index` is out of bounds.
  323. virtual absl::optional<AccessibilityTextRunInfo> GetTextRunInfo(
  324. int page_index,
  325. int start_char_index) = 0;
  326. // For all the links on page `page_index`, get their urls, underlying text
  327. // ranges and bounding boxes.
  328. virtual std::vector<AccessibilityLinkInfo> GetLinkInfo(
  329. int page_index,
  330. const std::vector<AccessibilityTextRunInfo>& text_runs) = 0;
  331. // For all the images in page `page_index`, get their alt texts and bounding
  332. // boxes. If the alt text is empty or unavailable, and if the user has
  333. // requested that the OCR service tag the PDF so that it is made accessible,
  334. // transfer the raw image pixels in the `image_data` field. Otherwise do not
  335. // populate the `image_data` field.
  336. virtual std::vector<AccessibilityImageInfo> GetImageInfo(
  337. int page_index,
  338. uint32_t text_run_count) = 0;
  339. // For all the highlights in page `page_index`, get their underlying text
  340. // ranges and bounding boxes.
  341. virtual std::vector<AccessibilityHighlightInfo> GetHighlightInfo(
  342. int page_index,
  343. const std::vector<AccessibilityTextRunInfo>& text_runs) = 0;
  344. // For all the text fields in page `page_index`, get their properties like
  345. // name, value, bounding boxes etc.
  346. virtual std::vector<AccessibilityTextFieldInfo> GetTextFieldInfo(
  347. int page_index,
  348. uint32_t text_run_count) = 0;
  349. // Gets the PDF document's print scaling preference. True if the document can
  350. // be scaled to fit.
  351. virtual bool GetPrintScaling() = 0;
  352. // Returns number of copies to be printed.
  353. virtual int GetCopiesToPrint() = 0;
  354. // Returns the duplex setting.
  355. virtual printing::mojom::DuplexMode GetDuplexMode() = 0;
  356. // Returns the uniform page size of the document in points. Returns
  357. // `absl::nullopt` if the document has more than one page size.
  358. virtual absl::optional<gfx::Size> GetUniformPageSizePoints() = 0;
  359. // Returns a list of Values of Bookmarks. Each Bookmark is a dictionary Value
  360. // which contains the following key/values:
  361. // - "title" - a string Value.
  362. // - "page" - an int Value.
  363. // - "children" - a list of Values, with each entry containing
  364. // a dictionary Value of the same structure.
  365. virtual base::Value::List GetBookmarks() = 0;
  366. // Append blank pages to make a 1-page document to a `num_pages` document.
  367. // Always retain the first page data.
  368. virtual void AppendBlankPages(size_t num_pages) = 0;
  369. // Append the first page of the document loaded with the `engine` to this
  370. // document at page `index`.
  371. virtual void AppendPage(PDFEngine* engine, int index) = 0;
  372. virtual std::vector<uint8_t> GetSaveData() = 0;
  373. virtual void SetCaretPosition(const gfx::Point& position) = 0;
  374. virtual void MoveRangeSelectionExtent(const gfx::Point& extent) = 0;
  375. virtual void SetSelectionBounds(const gfx::Point& base,
  376. const gfx::Point& extent) = 0;
  377. virtual void GetSelection(uint32_t* selection_start_page_index,
  378. uint32_t* selection_start_char_index,
  379. uint32_t* selection_end_page_index,
  380. uint32_t* selection_end_char_index) = 0;
  381. // Remove focus from form widgets, consolidating the user input.
  382. virtual void KillFormFocus() = 0;
  383. // Notify whether the PDF currently has the focus or not.
  384. virtual void UpdateFocus(bool has_focus) = 0;
  385. // Returns the focus info of current focus item.
  386. virtual AccessibilityFocusInfo GetFocusInfo() = 0;
  387. virtual uint32_t GetLoadedByteSize() = 0;
  388. virtual bool ReadLoadedBytes(uint32_t length, void* buffer) = 0;
  389. // Requests for a thumbnail to be sent using a callback when the page is ready
  390. // to be rendered. `send_callback` is run with the thumbnail data when ready.
  391. virtual void RequestThumbnail(int page_index,
  392. float device_pixel_ratio,
  393. SendThumbnailCallback send_callback) = 0;
  394. };
  395. // Interface for exports that wrap the PDF engine.
  396. class PDFEngineExports {
  397. public:
  398. struct RenderingSettings {
  399. RenderingSettings(const gfx::Size& dpi,
  400. const gfx::Rect& bounds,
  401. bool fit_to_bounds,
  402. bool stretch_to_bounds,
  403. bool keep_aspect_ratio,
  404. bool center_in_bounds,
  405. bool autorotate,
  406. bool use_color,
  407. bool render_for_printing);
  408. RenderingSettings(const RenderingSettings& that);
  409. gfx::Size dpi;
  410. gfx::Rect bounds;
  411. bool fit_to_bounds;
  412. bool stretch_to_bounds;
  413. bool keep_aspect_ratio;
  414. bool center_in_bounds;
  415. bool autorotate;
  416. bool use_color;
  417. bool render_for_printing;
  418. };
  419. PDFEngineExports() {}
  420. virtual ~PDFEngineExports() {}
  421. static PDFEngineExports* Get();
  422. #if BUILDFLAG(IS_CHROMEOS)
  423. // See the definition of CreateFlattenedPdf in pdf.cc for details.
  424. virtual std::vector<uint8_t> CreateFlattenedPdf(
  425. base::span<const uint8_t> input_buffer) = 0;
  426. #endif // BUILDFLAG(IS_CHROMEOS)
  427. #if BUILDFLAG(IS_WIN)
  428. // See the definition of RenderPDFPageToDC in pdf.cc for details.
  429. virtual bool RenderPDFPageToDC(base::span<const uint8_t> pdf_buffer,
  430. int page_number,
  431. const RenderingSettings& settings,
  432. HDC dc) = 0;
  433. virtual void SetPDFUsePrintMode(int mode) = 0;
  434. #endif // BUILDFLAG(IS_WIN)
  435. // See the definition of RenderPDFPageToBitmap in pdf.cc for details.
  436. virtual bool RenderPDFPageToBitmap(base::span<const uint8_t> pdf_buffer,
  437. int page_number,
  438. const RenderingSettings& settings,
  439. void* bitmap_buffer) = 0;
  440. // See the definition of ConvertPdfPagesToNupPdf in pdf.cc for details.
  441. virtual std::vector<uint8_t> ConvertPdfPagesToNupPdf(
  442. std::vector<base::span<const uint8_t>> input_buffers,
  443. size_t pages_per_sheet,
  444. const gfx::Size& page_size,
  445. const gfx::Rect& printable_area) = 0;
  446. // See the definition of ConvertPdfDocumentToNupPdf in pdf.cc for details.
  447. virtual std::vector<uint8_t> ConvertPdfDocumentToNupPdf(
  448. base::span<const uint8_t> input_buffer,
  449. size_t pages_per_sheet,
  450. const gfx::Size& page_size,
  451. const gfx::Rect& printable_area) = 0;
  452. virtual bool GetPDFDocInfo(base::span<const uint8_t> pdf_buffer,
  453. int* page_count,
  454. float* max_page_width) = 0;
  455. // Whether the PDF is Tagged (see 10.7 "Tagged PDF" in PDF Reference 1.7).
  456. // Returns true if it's a tagged (accessible) PDF, false if it's a valid
  457. // PDF but untagged, and nullopt if the PDF can't be parsed.
  458. virtual absl::optional<bool> IsPDFDocTagged(
  459. base::span<const uint8_t> pdf_buffer) = 0;
  460. // Given a tagged PDF (see IsPDFDocTagged, above), return the portion of
  461. // the structure tree for a given page as a hierarchical tree of base::Values.
  462. virtual base::Value GetPDFStructTreeForPage(
  463. base::span<const uint8_t> pdf_buffer,
  464. int page_index) = 0;
  465. // See the definition of GetPDFPageSizeByIndex in pdf.cc for details.
  466. virtual absl::optional<gfx::SizeF> GetPDFPageSizeByIndex(
  467. base::span<const uint8_t> pdf_buffer,
  468. int page_number) = 0;
  469. };
  470. } // namespace chrome_pdf
  471. #endif // PDF_PDF_ENGINE_H_