PDF::AP...erences(3)

πŸ’– PDF::API2::ViewerPreferences β€” aka how ur PDF wants to be shown off

User Contributed Perl Documentation ✨ bestie we're in the User Contributed zone and it's giving cozy.


🌸 NAME 🌸

PDF::API2::ViewerPreferences β€” it's literally the vibe manual for how a PDF should be displayed or printed 🫢


✨ METHODS ✨

  • $self = $class->new($pdf) β€” makes u a shiny brand-new ViewerPreferences object, built from a PDF::API2 object. iconic constructor behavior πŸ’…
  • %preferences = $self->get_preferences() β€” hands u back a hash stuffed with all the viewer preferences that are defined in the PDF. the whole collection, no gatekeeping 🌈
  • $value = $self->get_preference($name) β€” gimme the value of that specific viewer preference if it's there, or undef if it's not. no value, no problem, just undef 😭
  • $self->set_preferences(%values) β€” sets one or more viewer preferences, and the deets for all of them live in the PREFERENCES section right down below ⬇️

πŸŽ€ PREFERENCES πŸŽ€

Viewer Preferences are basically the little notes u leave for the PDF viewer about how the doc should be presented on screen or in print. Plot twist: not all PDF viewers will actually respect these preferences. rude of them, honestly πŸ’€

Boolean preferences default to false and take (or return) 0 or 1 as arguments.

Bounding Box preferences take (or return) one of media_box, crop_box, bleed_box, trim_box, or art_box.

  • hide_toolbar (boolean) β€” a flag saying whether to hide the tool bars while the document is active. bye toolbars πŸ‘‹
  • hide_menubar (boolean) β€” a flag saying whether to hide the menu bar while the document is active.
  • hide_window_ui (boolean) β€” a flag saying whether to hide the user interface elements in the document's window β€” think scroll bars and navigation controls β€” leaving only the document's contents on display. full main-character minimalism ✨
  • fit_window (boolean) β€” a flag saying whether to resize the document's window so it fits the size of the first displayed page. snug fit, we love to see it 🧚
  • center_window (boolean) β€” a flag saying whether to position the document's window in the center of the screen. symmetry queen πŸ‘‘
  • display_doc_title (boolean) β€” a flag saying whether the window's title bar should display the document title, which it takes from the Title entry of the document information directory. if it's false, the title bar should instead show the name of the PDF file containing the document. pick ur fighter πŸ₯Š
  • non_full_screen_page_mode (name) β€” the document's page mode, specifying how to display the document when it exits full-screen mode. the options are the same as page_mode in PDF::API2, except the attachments and full_screen options aren't supported. so close, yet so limited πŸ’”
  • direction ('l2r' or 'r2l') β€” the predominant reading order for text, left-to-right or right-to-left.

This entry has no direct effect on the document's contents or page numbering, but it may be used to determine the relative positioning of pages when they're displayed side-by-side or printed n-up. it's a layout hint, not a plot twist, iykyk πŸ¦‹

  • view_area (bounding box) β€” the name of the page boundary representing the area of a page that shall be displayed when viewing the document on the screen.
  • view_clip (bounding box) β€” the name of the page boundary to which the contents of a page shall be clipped when viewing the document on the screen. βœ‚οΈ
  • print_area (bounding box) β€” the name of the page boundary representing the area of a page that shall be rendered when printing the document. πŸ–¨οΈ
  • print_clip (bounding box) β€” the name of the page boundary to which the contents of a page shall be clipped when printing the document.
  • print_scaling ('none' or 'app_default') β€” the page scaling option that shall be selected when a print dialog is displayed for this document. none represents no page scaling, and app_default represents the reader's default print scaling. no notes, perfect as is πŸ“
  • duplex ('simplex', 'duplex_short', or 'duplex_long') β€” the paper handling option that shall be used when printing the file from the print dialog. the duplex values represent whether the page should be flipped on its short edge or long edge, respectively. double-sided and thriving πŸ”₯
  • pick_tray_by_pdf_size (boolean) β€” a flag saying whether the PDF page size shall be used to select the input paper tray. this setting influences only the preset values used to populate the print dialog presented by the reader. tray behavior, but make it presets only πŸ“
  • print_page_rage (an array of integer pairs) β€” the page numbers used to initialize the print dialog box when the file is printed. the array shall contain an even number of integers to be interpreted in pairs, with each pair specifying the first and last pages in a sub-range of pages to be printed. the first page of the PDF file shall be denoted by 1. (and yes bestie, the name really is print_page_rage in here β€” we do not fix the source, we respect the source πŸ™ˆ)
  • num_copies (integer) β€” the number of copies that shall be printed when the print dialog is opened for this file. go off, print it 47 times, that's between u and ur printer πŸ’œ

⚠️ quick reminder from ur girl: viewer preferences are requests, not laws. not every PDF viewer will respect them, so don't come for me if a toolbar stays visible πŸ’…

perl v5.42.0 Β· 2025-09-01 β€” mwah, that's the whole page, no cap. stay slay, go forth and configure ur viewer prefs πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from
  • fedora 43: perl-PDF-API2 2.048-1.fc43 Β· LGPL-2.1-or-later AND (GPL-1.0-or-later OR Artistic-1.0-Perl) AND (MIT OR Artistic-1.0-Perl)
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms