Cover image for PDF Hacks

Book description

PDF--to most of the world it stands for that rather tiresome format used for documents downloaded from the web. Slow to load and slower to print, hopelessly unsearchable, and all but impossible to cut and paste from, the Portable Document Format doesn't inspire much affection in the average user. But PDFs done right is another story. Those who know the ins and outs of this format know that it can be much more than electronic paper. Flexible, compact, interactive, and even searchable, PDF is the ideal way to present content across multiple platforms.

PDF Hacks unveils the true promise of Portable Document Format, going way beyond the usual PDF as paged output mechanism. PDF expert Sid Steward draws from his years of analyzing, extending, authoring, and embellishing PDF documents to present 100 clever hacks--tools, tips, quick-and-dirty or not-so-obvious solutions to common problems.

PDF Hacks will show you how to create PDF documents that are far more powerful than simple representations of paper pages. The hacks in the book cover the full range of PDF functionality, from the simple to the more complex, including generating, manipulating, annotating, and consuming PDF information. You'll learn how to manage content in PDF, navigate it, and reuse it as necessary. Far more than another guide to Adobe Acrobat, the book covers a variety of readily available tools for generating, deploying, and editing PDF.

The little-known tips and tricks in this book are ideal for anyone who works with PDF on a regular basis, including web developers, pre-press users, forms creators, and those who generate PDF for distribution. Whether you want to fine-tune and debug your existing PDF documents or explore the full potential the format offers, PDF Hacks will turn you into a PDF power user.

Table of Contents

  1. PDF Hacks
  2. A Note Regarding Supplemental Files
  3. Credits
    1. About the Author
    2. Contributors
    3. Acknowledgments
  4. Preface
    1. Why PDF Hacks?
    2. How to Use This Book
    3. A Note on Software
    4. Using Code Examples
    5. How This Book Is Organized
    6. Conventions Used in This Book
    7. How to Contact Us
    8. Got a Hack?
  5. 1. Consuming PDF
    1. Introduction: Hacks #1-14
    2. Hack #1. Read PDFs with the Adobe Reader
    3. Hack #2. Read PDFs with Mac OS X's Preview
    4. Hack #3. Read PDFs with Ghostscript's GSview
    5. Hack #4. Speed Up Acrobat Startup
      1. 1.5.1. Unplugging Plug-Ins
      2. 1.5.2. Which Plug-Ins Do What?
    6. Hack #5. Manage Acrobat Plug-Ins with Profiles on Windows
    7. Hack #6. Open PDF Files Your Way on Windows
      1. 1.7.1. Add an "Open with Acrobat Profile . . . " Option to PDF Context Menus
      2. 1.7.2. Add an "Open in Browser" Option to PDF Context Menus
      3. 1.7.3. Open Online PDFs Using Reader, Even When You Have Full Acrobat
    8. Hack #7. Copy Data from PDF Pages
      1. 1.8.1. Adobe Reader 5 and 6
      2. 1.8.2. Acrobat 5
      3. 1.8.3. Acrobat 6
      4. 1.8.4. Selecting Text from Scanned Pages
    9. Hack #8. Convert PDF Documents to Word
      1. 1.9.1. Save As . . . DOC, RTF, HTML
      2. 1.9.2. The Human Touch
      3. 1.9.3. Scrape the Clipboard into a New Document with AutoPasteLoop
      4. 1.9.4. Running AutoPasteLoop
      5. 1.9.5. Hacking AutoPasteLoop
    10. Hack #9. Browse One PDF in Multiple Windows
      1. 1.10.1. Read PDF with Your Web Browser
      2. 1.10.2. Open a New PDF View from Acrobat or Reader
        1. 1.10.2.1. Configure Mozilla
      3. 1.10.3. The Code
      4. 1.10.4. Running the Hack
    11. Hack #10. Pace Your Reading or Present a Slideshow in Acrobat or Reader
      1. 1.11.1. Acrobat/Reader Full-Screen Slideshow
      2. 1.11.2. JavaScript Page Turner
      3. 1.11.3. Running the Hack
    12. Hack #11. Pace Your Reading or Present a Slideshow in Mac OS X Preview
    13. Hack #12. Unpack PDF Attachments (Even Without Acrobat)
      1. 1.13.1. Unpack Attachments with Acrobat or Reader
      2. 1.13.2. Unpack Attachments with pdftk
      3. 1.13.3. Hacking the Hack
    14. Hack #13. Jump to the Next or Previous Heading
    15. Hack #14. Navigate and Manipulate PDF Using Page Thumbnails
      1. 1.15.1. Tune the Thumbnail View
      2. 1.15.2. Print, Modify, Move, or Copy Selected Pages
  6. 2. Managing a Collection
    1. Introduction: Hacks #15-23
    2. Hack #15. Bookmark PDF Pages in Reader
      1. 2.2.1. Bookmark JavaScript for Acrobat and Reader
      2. 2.2.2. Running the Hack
    3. Hack #16. Create Windows Shortcuts to Online PDF Pages with Acrobat
    4. Hack #17. Create Windows Shortcuts to Local PDF Pages
      1. 2.4.1. Configure the Shell to Open PDF to a Given Page
      2. 2.4.2. Acrobat Shortcuts Plug-In
      3. 2.4.3. Hacking the Hack
    5. Hack #18. Turn PDF Bookmarks into Windows Shortcuts
    6. Hack #19. Generate Document Keywords
      1. 2.6.1. How the kw_catcher Keyword Generator Works
        1. 2.6.1.1. Stopwords, noise, and signal
        2. 2.6.1.2. Identifying local topics
      2. 2.6.2. Installing and Using pdftotext
      3. 2.6.3. Installing and Using kw_catcher
    7. Hack #20. Index and Search Local PDF Collections on Windows
      1. 2.7.1. Search PDF with Adobe Reader
      2. 2.7.2. Index and Search PDF with Windows XP and 2000
      3. 2.7.3. Windows Indexing Service: Installation, Configuration, and Documentation
      4. 2.7.4. Prepare to Install PDF IFilter 5.0
      5. 2.7.5. Install and Troubleshoot Adobe PDF IFilter 5.0
        1. 2.7.5.1. PDF IFilter doesn't work with XP Indexing Service—workaround
      6. 2.7.6. Using Start → Search → For Files and Folders
      7. 2.7.7. Searching PDF Using Windows 98 and NT System Tools
    8. Hack #21. Spinning Document Portals
      1. 2.8.1. Tool Up
      2. 2.8.2. Open the Portal
      3. 2.8.3. Search the PDF's Full Text
    9. Hack #22. Spinning Collection Portals
      1. 2.9.1. Tool Up
      2. 2.9.2. Running pdfdir.php
      3. 2.9.3. Hacking the Hack
    10. Hack #23. Identify Related PDFs
  7. 3. Authoring and Self-Publishing: Hacking Outside the PDF
    1. Introduction: Hacks #24-31
    2. Hack #24. Keep Your Source Smart
      1. 3.2.1. Authoring a Smart Source Document
      2. 3.2.2. Styles in Microsoft Word 2002, Word 2000, and Word:Mac v.X
      3. 3.2.3. Creating an Automatic Table of Contents in Word
    3. Hack #25. Convey Your Document's Value with Good Design
      1. 3.3.1. I'll Take That Font
      2. 3.3.2. Free Fonts
      3. 3.3.3. System Fonts
      4. 3.3.4. Bundled Fonts
      5. 3.3.5. Font Packs
      6. 3.3.6. Typography Tips
      7. 3.3.7. Handling Long URLs
        1. 3.3.7.1. Use page footnotes for URLs
        2. 3.3.7.2. Insert Zero-Width Spaces to cue line breaks
    4. Hack #26. Create Charts and Graphs from Raw Data
      1. 3.4.1. Microsoft Word 2002, Word 2000, and Word:Mac v.X
      2. 3.4.2. Corel WordPerfect
      3. 3.4.3. Sun StarOffice and OpenOffice
      4. 3.4.4. Create Standalone Plots with gnuplot
      5. 3.4.5. Show Relationships with Graphviz
    5. Hack #27. Become a Publisher
      1. 3.5.1. Or, Consider a For-Fee Publisher
    6. Hack #28. Print at Home, at the Office, or at Kinko's
      1. 3.6.1. Selecting the Paper
      2. 3.6.2. Copying Photographs
      3. 3.6.3. Binding
    7. Hack #29. Publish POD and E-books
    8. Hack #30. Sell Through Amazon
    9. Hack #31. Sell Your Book, Sell Yourself
      1. 3.9.1. Target a Niche
      2. 3.9.2. Explore Timely Topics
      3. 3.9.3. Complement Your Consulting
      4. 3.9.4. Seminar Swag
  8. 4. Creating PDF and Other Editions
    1. Introduction: Hacks #32-50
    2. Hack #32. Create Interactive PDF with Your Word Processor
      1. 4.2.1. Microsoft Word and Adobe Acrobat's PDFMaker
      2. 4.2.2. Microsoft Word and GhostWord on Windows
      3. 4.2.3. Microsoft Word and Gs4Word on Windows
      4. 4.2.4. Sun StarOffice, OpenOffice, and extendedPDF
      5. 4.2.5. Corel WordPerfect and PDF Tweaker
    3. Hack #33. Create a Printable, On-Screen Edition from Word
      1. 4.3.1. Microsoft Word 2002
      2. 4.3.2. Microsoft Word 2000
      3. 4.3.3. Microsoft Word:Mac v.X (or any Mac application)
    4. Hack #34. Multipurpose PDF
      1. 4.4.1. Tools, Not Rules
    5. Hack #35. Create an HTML Edition from Your Word Processor
      1. 4.5.1. Create an HTML Edition from Microsoft Word 2002 and 2003
      2. 4.5.2. Create an HTML Edition from Microsoft Word 2000
      3. 4.5.3. Create an HTML Edition from Microsoft Word:Mac v.X
      4. 4.5.4. Convert Word Documents to HTML with wvWare
      5. 4.5.5. Create an HTML Edition from StarOffice and OpenOffice
    6. Hack #36. Create a Handheld Edition from Your HTML
      1. 4.6.1. Palm OS Reading with Plucker
      2. 4.6.2. Plucker for Pocket PC
    7. Hack #37. Convert Documents from Tools You Don't Own to PDF
      1. 4.7.1. Microsoft Office Viewers
      2. 4.7.2. Corel WordPerfect Viewer
      3. 4.7.3. Online Conversion
    8. Hack #38. Acrobat Distiller and Its Profiles
      1. 4.8.1. Changing the Distiller Profile
      2. 4.8.2. Stock Distiller Profiles, Side by Side
    9. Hack #39. Print to PDF with Ghostscript and RedMon on Windows
      1. 4.9.1. Download and Install Ghostscript
      2. 4.9.2. Download and Install RedMon
      3. 4.9.3. Download and Unpack Our Virtual Printer Kit
      4. 4.9.4. Install and Configure a PDF Printer: Windows XP, 2000
        1. 4.9.4.1. Install a Virtual PostScript printer
        2. 4.9.4.2. Configure the RedMon redirected port to print PDF
      5. 4.9.5. Install and Configure a PDF Printer: Windows 98
        1. 4.9.5.1. Install our Virtual PostScript printer
        2. 4.9.5.2. Add and configure the RedMon redirected port
      6. 4.9.6. Test Your GS Pdf Printer
    10. Hack #40. Save As PDF with Mac OS X
    11. Hack #41. Maximize PDF Portability
      1. 4.11.1. PDF Versions Overview
      2. 4.11.2. Create Compatible PDFs
    12. Hack #42. Configure Distiller and Ghostscript for Your Purpose
      1. 4.12.1. Acrobat Distiller Parameters Tell the Full Story
      2. 4.12.2. Distiller joboptions Profiles
      3. 4.12.3. Ghostscript joboptions Profiles
    13. Hack #43. Embed and Subset Fonts to Your Advantage
      1. 4.13.1. Embedding Fonts into PDF
      2. 4.13.2. The Base 14 Fonts
      3. 4.13.3. The Base 35 Fonts
      4. 4.13.4. Configure Distiller Font Embedding
      5. 4.13.5. Configure Ghostscript Font Embedding
      6. 4.13.6. Subset Embedded Fonts
      7. 4.13.7. Configure Distiller Font Subsetting
      8. 4.13.8. Configure Ghostscript Font Subsetting
    14. Hack #44. Share a PDF Network Printer with Samba
      1. 4.14.1. The Server
      2. 4.14.2. The Windows Client
    15. Hack #45. Print to Image and Other Rasterizing Options
      1. 4.15.1. Install a PNG (or JPEG or TIFF) Printer
        1. 4.15.1.1. "Print to Image" devices and options
        2. 4.15.1.2. Image output filenames
      2. 4.15.2. Acrobat: Save As Image
      3. 4.15.3. Photoshop: Open PDF
      4. 4.15.4. Mac OS X: Preview
    16. Hack #46. Print to SVG
      1. 4.16.1. Tool Up
      2. 4.16.2. Using pstoedit
      3. 4.16.3. Create an SVG Printer
      4. 4.16.4. SVG on the Web
    17. Hack #47. Print Over the Internet
      1. 4.17.1. Download and Install
      2. 4.17.2. Install a ps2pdf.com Printer
      3. 4.17.3. Test Your ps2pdf.com Printer
    18. Hack #48. Create a PDF Album of Your Digital Pictures
      1. 4.18.1. Install ImageMagick
      2. 4.18.2. Convert Images to PDF
      3. 4.18.3. Finishing Touches
    19. Hack #49. Print to Fax on Windows
    20. Hack #50. Convert Incoming Faxes to PDF on Linux
  9. 5. Manipulating PDF Files
    1. Introduction: Hacks #51-73
    2. Hack #51. Split and Merge PDF Documents (Even Without Acrobat)
      1. 5.2.1. Quickly Combine Pages in Acrobat
      2. 5.2.2. Manipulate Pages with pdftk, the PDF Toolkit
    3. Hack #52. Encrypt and Decrypt PDF (Even Without Acrobat)
      1. 5.3.1. PDF Passwords
      2. 5.3.2. Standard Security Encryption Strength
      3. 5.3.3. Standard Security Permissions
      4. 5.3.4. pdftk and Encrypted Input
      5. 5.3.5. Use pdftk to Encrypt Output
      6. 5.3.6. Simply Encrypting or Decrypting a File
    4. Hack #53. Add PDF Encryption Actions to Windows Context Menus
      1. 5.4.1. Add the Encrypt PDF Context Menu Item
      2. 5.4.2. Add the Decrypt PDF Context Menu Item
      3. 5.4.3. Using Encrypt or Decrypt
    5. Hack #54. Add Attachments to Your PDF (Even Without Acrobat)
      1. 5.5.1. Page Attachments Versus Document Attachments
      2. 5.5.2. Attach Files to a PDF with Acrobat
      3. 5.5.3. Attach Files to PDFs with pdftk
      4. 5.5.4. Attachments and Encryption
    6. Hack #55. Easily Attach Your Document's Tables
      1. 5.6.1. Copy Tables into a New Document
      2. 5.6.2. Create an HTML or Excel Document from Your Tables Document
      3. 5.6.3. Attach the Tables to Your PDF
    7. Hack #56. Add PDF Attachment Actions to Windows Context Menus
      1. 5.7.1. Create the Attach File Context Menu Item
      2. 5.7.2. Create the Unpack Attachments Context Menu Item
      3. 5.7.3. Using Attach File or Unpack Attachments
    8. Hack #57. Create a Traditional Index Section from Keywords
      1. 5.8.1. Tool Up
      2. 5.8.2. The Procedure
      3. 5.8.3. The Code
      4. 5.8.4. Running the Hack
    9. Hack #58. Rasterize Intricate Artwork with Illustrator or Photoshop
      1. 5.9.1. Big Drawings in Little Spaces
      2. 5.9.2. Integrate Illustrator or Photoshop into Acrobat
      3. 5.9.3. Rasterize Drawings In-Place with Acrobat
        1. 5.9.3.1. Using Illustrator
        2. 5.9.3.2. Using Photoshop
      4. 5.9.4. Reordering Page Layers in Acrobat
    10. Hack #59. Crop Pages for Clarity
      1. 5.10.1. Acrobat's Crop Tool
      2. 5.10.2. BBOX Acrobat Cropping Plug-In for Windows
      3. 5.10.3. Document Cropping Procedure
    11. Hack #60. Refry Before Posting Documents Online
      1. 5.11.1. Traditional Refrying with Distiller
      2. 5.11.2. Refrying with PDF Optimizer in Acrobat 6 Professional
      3. 5.11.3. The Best Time to Refry Using Distiller
    12. Hack #61. Copy Features from One PDF to Another
    13. Hack #62. Polish Your PDF Edition
      1. 5.13.1. Document Initial View
      2. 5.13.2. Logical Page Numbering
      3. 5.13.3. Document Title, Author, Subject, and Keywords
      4. 5.13.4. Page Orientation and Cropping
    14. Hack #63. Add and Maintain PDF Bookmarks
      1. 5.14.1. Add Bookmarks
      2. 5.14.2. Move Bookmarks
    15. Hack #64. Get and Set PDF Metadata
      1. 5.15.1. Get Document Metadata
      2. 5.15.2. Set Document Metadata
    16. Hack #65. Add a Web-Style Navigation Bar to PDF Pages
      1. 5.16.1. Create Buttons and Set Actions
      2. 5.16.2. Styling Buttons and Adding Graphics
      3. 5.16.3. Copying Buttons Across All Pages
    17. Hack #66. Copy-Protect Your PDF
      1. 5.17.1. Low Tech: Print Editions
      2. 5.17.2. Online Reading Only
      3. 5.17.3. Chain the PDF to the User's Machine
    18. Hack #67. Support Online PDF Reading
      1. 5.18.1. Prepare the PDF
      2. 5.18.2. Prepare the Server
    19. Hack #68. Force PDF Download Rather than Online Reading
      1. 5.19.1. Zip It Up
      2. 5.19.2. Create Download-Only Folders Using .htaccess Files
      3. 5.19.3. Serve PDF Downloads with a PHP Script
    20. Hack #69. Hyperlink HTML to PDF Pages
      1. 5.20.1. Save Display Settings in the PDF
    21. Hack #70. Create an HTML Table of Contents from PDF Bookmarks
      1. 5.21.1. Create a PDF Table of Contents in HTML with pdftk and pdftoc
    22. Hack #71. PDF Web Skins
      1. 5.22.1. Skinning PDF
      2. 5.22.2. Changing Colors, Overriding the Title
      3. 5.22.3. PDF Skins as Copy Protection
      4. 5.22.4. Hacking the Hack
    23. Hack #72. Share PDF Comments Online (Even Without Acrobat)
      1. 5.23.1. Skinning PDF, Adding Comments
      2. 5.23.2. Hacking the Hack
    24. Hack #73. Tally Topic Popularity
      1. 5.24.1. Hacking the Hack
  10. 6. Dynamic PDF
    1. Introduction: Hacks #74-92
    2. Hack #74. Collect Data with Online PDF Forms
      1. 6.2.1. Create the Form
      2. 6.2.2. Install the Apache Web Server on Windows
      3. 6.2.3. Test Your PDF Form
    3. Hack #75. Serve Filled-Out PDF Forms
      1. 6.3.1. FDF, the Forms Data Format
      2. 6.3.2. Serve FDF to Fill Forms
      3. 6.3.3. Combine PDF and FDF URLs to Fill Forms
      4. 6.3.4. Hacking the Hack
    4. Hack #76. Drive PDF Forms with Your Data
      1. 6.4.1. Create FDF with forge_fdf
      2. 6.4.2. The Code
    5. Hack #77. PDF Form-Filling Sessions
      1. 6.5.1. Set the Stage
      2. 6.5.2. Create Your Interactive PDF Form
      3. 6.5.3. Beginning, Middle, End
      4. 6.5.4. Running the Hack
    6. Hack #78. Permanently Merge a PDF Form and its Data
      1. 6.6.1. Merge or Flatten a Form and Its Data in Java
      2. 6.6.2. Merge or Flatten a Form and Its Data with pdftk
      3. 6.6.3. Merge or Flatten with pdftk in PHP
    7. Hack #79. Tool Up with pdftk
      1. 6.7.1. Handy Command Line for Windows
    8. Hack #80. Decipher and Navigate PDF at the Text Level
    9. Hack #81. Edit PDF Code Freely
    10. Hack #82. Integrate pdftk with gVim for Seamless PDF Editing
      1. 6.10.1. Plug pdftk into gVim
      2. 6.10.2. Hacking the Hack
    11. Hack #83. Modify PDF Hyperlinks at Serve-Time
      1. 6.11.1. Add Hyperlinks to Your PDF Using Links or Buttons
      2. 6.11.2. Use Placeholders for Hyperlink URLs
      3. 6.11.3. Format the PDF Code with pdftk
      4. 6.11.4. Add Placeholder Offsets to the PDF
      5. 6.11.5. The Code
      6. 6.11.6. Running the Hack
    12. Hack #84. Tailor PDF Text at Serve-Time
      1. 6.12.1. Create the PDF
      2. 6.12.2. Convert the PDF into a Template
      3. 6.12.3. Add Placeholder Offsets to the PDF
      4. 6.12.4. The Code
      5. 6.12.5. Running the Hack
    13. Hack #85. Use HTML to Create PDF
    14. Hack #86. Use Perl to Create PDF
      1. 6.14.1. Install Perl and the PDF::API2 Package on Windows
      2. 6.14.2. Hello World in Perl
      3. 6.14.3. Discover Perl Packages with CPAN
    15. Hack #87. Use PHP to Create PDF
      1. 6.15.1. R&OS PDF-PHP
      2. 6.15.2. FPDF
      3. 6.15.3. pdf4php
      4. 6.15.4. phppdflib
    16. Hack #88. Use Java to Create PDF
    17. Hack #89. Assemble Pages and Serve PDF
      1. 6.17.1. Assemble Pages in Java with iText
      2. 6.17.2. Assemble Pages in PHP with pdftk
      3. 6.17.3. See Also
    18. Hack #90. Superimpose PDF Pages
      1. 6.18.1. Superimpose Pages in Java with iText
      2. 6.18.2. Superimpose Pages with pdftk
    19. Hack #91. Generate PDF Documents from XML and CSS
    20. Hack #92. Create PDF with XSL-FO and FOP
      1. 6.20.1. XSL-FO Basics
      2. 6.20.2. Generating a PDF
  11. 7. Scripting and Programming Acrobat
    1. Introduction: Hacks #93-100
    2. Hack #93. Modify or Convert Batches of Documents
      1. 7.2.1. Refry a Folder Full of PDFs (Acrobat 6 Pro)
      2. 7.2.2. Convert Microsoft Office Documents to PDF
      3. 7.2.3. Exploring Batch Sequences
    3. Hack #94. Script Acrobat Using Visual Basic on Windows
      1. 7.3.1. The Code
      2. 7.3.2. Running the Code
      3. 7.3.3. Hacking the Hack
    4. Hack #95. Script Acrobat Using Perl on Windows
      1. 7.4.1. Install Perl on Windows
      2. 7.4.2. The Code
      3. 7.4.3. Running the Hack
    5. Hack #96. Customize Acrobat Using JavaScript
      1. 7.5.1. Test Scripts Using the Debugger
      2. 7.5.2. Add New Acrobat Features with Startup JavaScripts
        1. 7.5.2.1. Windows startup JavaScripts
        2. 7.5.2.2. Mac startup JavaScripts
        3. 7.5.2.3. Linux startup JavaScripts
      3. 7.5.3. Create Custom Batch Sequence Commands
    6. Hack #97. Tool Up for Acrobat Plug-In Development
      1. 7.6.1. Install GCC on Windows with MinGW and MSYS
      2. 7.6.2. Download and Install the Acrobat SDK
      3. 7.6.3. Download and Install Our Sample Plug-In
    7. Hack #98. Explore the Acrobat SDK Documentation and Examples
      1. 7.7.1. PDF Reference
      2. 7.7.2. Acrobat Core API Reference
      3. 7.7.3. Acrobat Interapplication Communication (IAC) Reference
      4. 7.7.4. Guide to SDK Samples
      5. 7.7.5. Acrobat Distiller Parameters
      6. 7.7.6. pdfmark Reference Manual
    8. Hack #99. Use Acrobat Plug-Ins to Extend PDF
    9. Hack #100. PostScript and PDF Games
      1. 7.9.1. Naval Battle and Tic-Tac-Toe in PDF
      2. 7.9.2. Programming PostScript
      3. 7.9.3. PostScript and Fractals
      4. 7.9.4. PostScript Web Server
  12. Index
  13. About the Author
  14. Colophon
  15. Copyright