PDF Mark
PDF Mark
PDF Mark
Corporate Headquarters 345 Park Avenue San Jose, CA 95110-2704 (408) 536-6000 http://partners.adobe.com
May 2003
Copyright 2003 Adobe Systems Incorporated. All rights reserved. NOTICE: All information contained herein is the property of Adobe Systems Incorporated. No part of this publication (whether in hardcopy or electronic form) may be reproduced or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written consent of the Adobe Systems Incorporated. PostScript is a registered trademark of Adobe Systems Incorporated. All instances of the name PostScript in the text are references to the PostScript language as defined by Adobe Systems Incorporated unless otherwise stated. The name PostScript also is used as a product trademark for Adobe Systems implementation of the PostScript language interpreter. Except as otherwise stated, any reference to a PostScript printing device,PostScript display device, or similar item refers to a printing device, display device or item (respectively) that contains PostScript technology created or licensed by Adobe Systems Incorporated and not to devices or items that purport to be merely compatible with the PostScript language. Adobe, the Adobe logo, Acrobat, the Acrobat logo, Acrobat Capture, Distiller, PostScript, the PostScript logo and Reader are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. Apple, Macintosh, and Power Macintosh are trademarks of Apple Computer, Inc., registered in the United States and other countries. PowerPC is a registered trademark of IBM Corporation in the United States. ActiveX, Microsoft, Windows, and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. UNIX is a registered trademark of The Open Group. All other trademarks are the property of their respective owners. This publication and the information herein is furnished AS IS, is subject to change without notice, and should not be construed as a commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or inaccuracies, makes no warranty of any kind (express, implied, or statutory) with respect to this publication, and expressly disclaims any and all warranties of merchantability, fitness for particular purposes, and noninfringement of third party rights.
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Other Useful Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Chapter 1
What is the pdfmark Operator? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Syntax of the pdfmark Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Using pdfmark with Standard PostScript Interpreters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Syntax for Private Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Named Objects . . . . . . . . . . . . . . . . Built-In Named Objects . . . . . . . . User-Defined Named Objects . . . . Namespaces . . . . . . . . . . . . . . . Adding Content to Named Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 13 14 15 16
Chapter 2
Bookmarks (OUT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Articles (ARTICLE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Page Cropping (PAGES, PAGE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Info Dictionary (DOCINFO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Document Open Options (DOCVIEW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Page Label and Plate Color (PAGELABEL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Marked Content (MP, DP, BMC, BDC, EMC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Marked-Content Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Marked-content sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Naming Graphics (BP, EP, SP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Contents
Naming Images (NI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Transparency (SetTransparency) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Transparency Group XObject and Soft Mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Add Metadata to the Catalog (Metadata) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Embedded File Content (EMBED) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Compatibility Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Old-style Links (LNK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Pass-through PostScript Commands (PS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Chapter 3
Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Chapter 4
Logical Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Elements and Parents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Structure Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Structure Tree Root. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 StRoleMap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 StClassMap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Elements . . . . . . . . StPNE . . . . . . . StBookmarkRoot StPush . . . . . . . StPop. . . . . . . . StPopAll . . . . . . StUpdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 51 53 53 54 54 54 54 54 55 55 55
Contents
Attribute Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 StAttr. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Storing and Retrieving the Implicit Parent Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 StStore. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 StRetrieve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 EPS Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Tagged PDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Chapter 5
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Ignore pdfmark if not defined in the PostScript interpreter . . . . . . . . . . . . . . . . . . . . . . . . . 59 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Simple note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Fancy note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Private Data in Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Simple Link (old style, compatible with all Distiller application versions) . Link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fancy link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Link that launches another file. . . . . . . . . . . . . . . . . . . . . . . . . . . . Custom link action (URI link for the Acrobat WebLink plug-in). . . . . . . . Custom link action (named action) . . . . . . . . . . . . . . . . . . . . . . . . . Custom annotation type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Movie annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 60 60 60 61 61 61 62 62
Bookmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Articles . . . . . . . . . . . . . . . . . . . . . . . . . . Article action. . . . . . . . . . . . . . . . . . . . Create text for the article Now is the Time Article containing two beads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 63 63 63
Page Cropping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Crop this page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Crop all pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Info Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 File Open Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Page Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Named Destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Definition of named destination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Link to a named destination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Named Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Contents
Creating user-defined named objects . . . . . . . . . . . . . . . . . . . . Adding values to named objects . . . . . . . . . . . . . . . . . . . . . . . Creating an annotation as a named object and adding content to it. Using a named object as a value . . . . . . . . . . . . . . . . . . . . . . . Putting a files contents into a text annotation. . . . . . . . . . . . . . . Using OBJ to add an open action to a PDF File . . . . . . . . . . . . . . Using OBJ to create a base URI. . . . . . . . . . . . . . . . . . . . . . . . . Using OBJ and PUT pdfmarks to create an alternate image. . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
66 66 66 66 67 67 67 67
Using the Graphics Encapsulation pdfmark Names (BP, EP, SP) . . . . . . . . . . . . . . . . . . . . . . . 68 Creating a picture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Using BP and EP pdfmarks to define button faces for forms . . . . . . . . . . . . . . . . . . . . . . 70 Forms Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Define the AcroForm dictionary at the document Catalog . . . . . . . . . . . . . . . . . . . . . . . 71 Define the Widget annotations, which are also field dictionaries for this form . . . . . . . . . . 73 Structure Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 A simple structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 PDF output resulting from code in previous section . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 A bookmark for a structural element. . . . . . . . . . . Interrupted structure. . . . . . . . . . . . . . . . . . . . . Independence of logical and physical structure. . . . Page break within logical structure. . . . . . . . . . . . Logical Structure Out-of-order in Physical Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 78 79 80 81
Tagged PDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Appendix A
Preface
The Acrobat Distiller application is a PostScript-language interpreter that converts PostScript language files into Portable Document Format (PDF) files. Because PDF has features (such as annotations, bookmarks, articles, and forms) that are not expressable using the standard PostScript operators, some PostScript language extension is necessary to describe features that are present in PDF, but not in standard PostScript. To satisfy this need, Acrobat Distiller provides the operator pdfmark that is not found in standard PostScript interpreters. The use of pdfmark allows an independent software vendor (ISV) already using the PostScript language to express, in PostScript syntax, idioms that are converted by Acrobat Distiller to PDF without having to write PDF files directly.
Purpose
This document describes the syntax and use of the pdfmark operator, and contains examples of many of the features that can be implemented using pdfmark.
Audience
This document is intended for those who use, are about to use, or wish to understand pdfmark constructs in PostScript code intended for conversion to PDF by Acrobat Distiller. Those using pdfmark typically do so in one of the following ways:
by manual creation or modification of PostScript code; by filtering or post-processing existing PostScript code; or, by an application that directly generates pdfmark constructs as part of its PostScript code generation.
Contents
Chapter 1, pdfmark Syntax and Use, describes the pdfmark operator, its syntax, and its use by Acrobat Distiller and other PostScript interpreters. It also discusses the use of named objects. Chapter 2, Basic pdfmark Features, describes the basic forms of the pdfmark operator. Chapter 3, Specifying Actions and Destinations, goes into detail about how to specify actions and destinations. Chapter 4, Logical Structure, describes how to implement logical structure in PDF.
Preface
Other Useful Documentation
Chapter 5, Examples, gives several examples of using pdfmark. Appendix A, pdfmark for JDF, describes the use of pdfmark with JDF files.
PostScript Language Reference, 3rd edition, ISBN 0201379228 http://partners.adobe.com/asn/developer/technotes/postscript.html PDF Reference, 3rd edition, version 1.4, ISBN 0201758393 http://partners.adobe.com/asn/developer/acrosdk/docs.html#filefmtspecs
In addition, a software development kit (the Acrobat SDK) consisting of documentation, headers, and sample code that enables software developers to access the functionality of the Acrobat product suite can be found at: http://partners.adobe.com/asn/developer/acrosdk/main.html
This chapter describes the pdfmark operator, its syntax, and its use by Acrobat Distiller and other PostScript interpreters. It also describes how built-in and user-defined PDF objects are referred to and defined.
While the pdfmark operator provides for greater extensibility, it is not intended to define every feature that is present in PDF but not in standard PostScript.
begins with a mark object (either mark or [); is followed by zero or more PostScript objects called the arguments of the pdfmark operator; and, concludes with a name object that indicates the particular feature that the pdfmark operator is to apply. Any instance of the pdfmark operator, the mark, its arguments, and the feature name in a PostScript program is referred to as a pdfmark in this document. Frequently, the arguments for a given feature are sequences of key-value pairs. Many of the pdfmark keys correspond directly to PDF dictionary keys. However, some keys may be new, entirely different, or abbreviated forms of keys as found in PDF dictionaries. For example, the PDF Subtype key may become the pdfmark key S, Dest may become D, and File may become F, and so forth. See the PDF Reference for more information on PDF keys.
NOTE:
NOTE:
The pdfmark operator does not change the operand nor the dictionary stacks, but may alter the execution, graphics state, or clipping stacks, depending on the particular pdfmark feature.
% Define pdfmark to remove all objects % up to and including the mark object.
This code example works on PostScript Level 1 and above interpreters. In the examples that follow, PostScript Level 2 or higher is assumed to simplify the presentation of the examples. Most pdfmark features are atomic. That is, the pdfmark construct stands alone and, if removed, does not affect surrounding PostScript. A few pdfmark features, on the other hand, are modal. A modal feature is one that, once completed, leaves the interpreter in a different state. Most modal features are paired: one feature shifts to a new state and a corresponding feature shifts back to the previous state. For example, consider: [ any1 ... anyn /BeginFeature pdfmark additional PostScript code [ any1 ... anym /EndFeature pdfmark
10
If it is desired to make the additional PostScript code conditional on the availability of the pdfmark operator, then the above definition of pdfmark needs to be improved.
%%BeginProlog /pdfmark where { pop globaldict /?pdfmark /exec load put } % pdfmark is built-in: exec code. { globaldict begin /?pdfmark /pop load def % pdfmark is absent: ignore code. /pdfmark /cleartomark load def end } ifelse %%EndProlog
11
While the above solution is sufficient in most circumstances, it might be desirable to define a pdfmark procedure to handle individual features. The following example demonstrates a simple framework for handling individual pdfmark features:
%%BeginProlog currentglobal currentpacking true setglobal true setpacking % Because the pdfmark definition below uses % composite objects, we need to make sure the % procedure is defined in global VM mode.
/pdfmark where { pop globaldict /?pdfmark /exec load put} { globaldict begin /?pdfmark /pop load def /pdfmark { { counttomark pop } % Check to see that a mark is on the stack. stopped { /pdfmark errordict /unmatchedmark get exec stop } if % Raise an error if no mark is found. dup type /nametype ne % The topmost argument must be the feature. { /pdfmark errordict /typecheck get exec stop } if % The feature must be a name object. { dup /FEATURE1 eq { (Interpreting FEATURE 1\n) print cleartomark exit } if % Replace the above code with actual code dup /FEATURE2 eq { (Interpreting FEATURE 2\n) print cleartomark exit } if % Replace the above code with actual code (Feature not supported: ) print == cleartomark exit % Replace the above code with actual code } loop } bind def end } ifelse setpacking setglobal % Restore to original modes. %%EndProlog
In the above code, the name objects FEATUREn would be replaced with actual pdfmark feature names and the code that follows the dup /FEATUREn eq would be replaced with code that consumes all of the arguments and the mark object. In the examples that follow in this document, the ?pdfmark definition is assumed to be as shown above. To work correctly with non-Distiller PostScript interpreters, any production implementation of these or additional definitions must take into account factors such as PostScript level, VM allocation modes, packing modes, and others.
12
The private key names in this technical note use Adobes prefix ADBE.
Named Objects
This section describes how built-in and user-defined PDF objects are referred to and defined.
{objname}
is used where objname is one of:
the PDF files Catalog dictionary the PDF files Info dictionary the dictionary for page N (where N is a positive integer) the dictionary for the current page being processed in the PostScript stream the dictionary for the page before the current page the dictionary for the page after the current page
NOTE:
The objname used here is not a standard PostScript name object; that is, it does not start with a slash / but instead is surrounded with braces {}; it otherwise follows the syntax of PostScript name objects. The objname serves as a reference name to identify particular PDF objects and has no relationship to any identifier created in the resultant PDF file.
13
NOTE:
The feature /OBJ is used only to declare a particular objname and its associated type. Other pdfmark features are required to associate this objname with actual content and to have some existing PDF object refer to it.
Here is an example in which the named object galaxy is declared to be a dictionary type: [ /_objdef {galaxy} /type /dict /OBJ pdfmark A few pdfmark features allow for the definition of a named object as part of the argument list. In these cases, the modified syntax is: [ /_objdef {objname} any1 ... anyn feature pdfmark In this case, the objname is not only created, but also refers to the PDF object created as a result of the pdfmark feature. The type entry is not used because the feature implicitly provides this information. The following features support this syntax:
Named objects created in any of the above ways can be used in the definition of other named objects. That is, an {objname} can be used as an argument in a pdfmark construct as the value of a keyvalue pair or as an element in an array. In these cases, Distiller places an indirect reference to the object that {objname} is associated with in the PDF file.
NOTE:
A pdfmark construct can make an object reference {objname} before defining the object {objname}. That is, the {objname} can be in the argument list of a pdfmark construct before it is defined. If {objname} is never defined, it is left as an unresolved reference in the cross-reference table. Hence, any consumer of such a PDF file must be able to handle unresolved references.
14
Namespaces
When using named objects in PostScript programs, it is possible that the same name might be used more than once. To help avoid conflicts in name object definitions, Acrobat Distiller provides a means for specifying the scope in which named objects have well-defined meaning. In addition to the standard 5 PostScript stacks (see PostScript Language Reference, third edition, Section 3.4, on page 45, Acrobat Distiller maintains a stack of namespaces. The namespace stack is similar to the PostScript dictionary stack, except that only the top-most namespace name objects are visible. The namespace stack is also similar to the graphics state stack, except that no currentgstate analog is provided. A namespace contains:
Names for user-defined named objects (see User-Defined Named Objects on page 14) Names for stored implicit parent stacks (see StStore on page 57) Names for images (see Naming Images (NI) on page 32)
The appropriate use of namespaces can help ensure that PostScript file construction containing code from various sources that use pdfmark constructs does not have namedobject conflicts. A common example is the handling of Encapsulated PostScript files (see EPS Considerations on page 57).
NOTE:
The built-in named objects are managed separately from the namespace stack and are always visible.
The following pdfmark features are available for manipulating namespaces: 1. NamespacePush causes a new, empty namespace to be pushed onto the namespace stack and causes all other namespaces to be hidden. The syntax for pushing a namespace is: [ /NamespacePush pdfmark 2. NamespacePop pops the topmost namespace from the stack. Once a namespace has been popped, it can not be accessed again. The next lower namespace on the stack becomes the current namespace. The syntax for popping a namespace is: [ /NamespacePop pdfmark A warning will be issued by Acrobat Distiller if NamespacePop is encountered when the namespace stack is empty.
%%[ Warning: /NamespacePop pdfmark ignored: No matching NamespacePush ]%% NOTE:
15
The above code creates an array object and populates it with objects of various types. Note, at this point, the named object cannot be reached because there are no entries in the PDF files cross-reference table or file trailer that lead to it. Adding array objects as above can become tedious. When adding objects to contiguous array index positions, the pdfmark feature PUTINTERVAL can simplify this task. The syntax for this feature is: [ {arrayname} index [value1 ... valuen] /PUTINTERVAL pdfmark The operation of this feature is the same as in PostScript: value1 is placed in arraynameindex, value2 is placed in arraynameindex+1, and so forth. The array is resized if necessary to hold the objects added. The previous example can be simplified to:
[ /_objdef {MoonInfo} /type /array /OBJ pdfmark [ {MoonInfo} 0 [(Earth to Moon) 238855 /miles] /PUTINTERVAL pdfmark
One additional convenience for adding objects to array is available: the APPEND feature. This feature adds one additional entry immediately after the end of the array. Its syntax is: [ {arrayname} value /APPEND pdfmark Dictionaries The PUT feature can also be used to add dictionary content. The named object can be either a built-in name, such as {Catalog} or {Page37}, or a user-defined object name. For dictionary named objects, the syntax of the PUT feature is: [ {dictname} <<key1 value1 ... keyn valuen >> /PUT pdfmark For dictionary named objects, PUT adds the keyvalue pairs provided as arguments. Continuing the previous example:
[ {Catalog} << /TheMoon {MoonInfo} >> /PUT pdfmark
16
This adds a keyvalue pair to the PDF Catalog dictionary. The inserted key is /TheMoon and the value is an indirect object. To illustrate this, the resultant PDF file might have the following content:
trailer << /Root 9 0 R >> 9 0 obj << /Type /Catalog /TheMoon 3 0 R >> endobj 3 0 obj [(Earth to Moon)238855/miles] endobj
Notice that the named object MoonInfo does not appear in the resultant PDF file, but the object it referred to, 3 0 obj in this case, does. Streams For stream named objects, the syntax can take several forms: [ {streamname} string /PUT pdfmark [ {streamname} file /PUT pdfmark [ {streamname} <<key1 value1 ... keyn valuen >> /PUT pdfmark A stream object consists of a sequence of bytes, its character data, and an associated dictionary. When the stream named object is created, the character data is empty. The source of stream data can come from an explicit string or can be read from a PostScript file object (a file or filter), in which case reading proceeds until the end of file is reached. In addition to the character data, a stream has an associated PDF dictionary. Some dictionary entries such as Length are created automatically. Keyvalue pairs that do not conflict with the keys common to PDF stream dictionaries can be added to this dictionary. The resultant PDF object associated with the stream named object is always compressed using a lossless method that can be specified in Acrobat Distillers Adobe PDF Settings dialog. The CLOSE feature closes a stream object created by pdfmark and has the syntax: [ {streamname} /CLOSE pdfmark The named stream object is closed and written to the PDF file. The {streamname} is still valid and may be referenced by other objects, but it can no longer be written to. When Distiller completes writing a PDF file, any open streams are closed and written automatically. For example:
[ /_objdef {MoonNotes} /type /stream /OBJ pdfmark [ {MoonNotes} (Hipparchus around 129 BC calculated the distance to the Moon.\n) /PUT pdfmark [ {MoonNotes} (The Moon was first touched by Armstrong on July 20, 1969.\n) /PUT pdfmark [ {MoonNotes} << /Author (Steve Amerige) /Company (Adobe) >> /PUT pdfmark [ {Catalog} << /MoonNotes {MoonNotes} >> /PUT pdfmark [ {MoonNotes} /CLOSE pdfmark
17
18
This chapter describes the basic pdfmark features. In general, the keyvalue pairs used as arguments for pdfmark follow closely the keyvalue pairs that appear in the PDF file. See the latest version of the PDF Reference for a description of the PDF file format. The following pdfmark features are described in this chapter: Annotations (ANN) Bookmarks (OUT) Articles (ARTICLE) Page Cropping (PAGES, PAGE) Info Dictionary (DOCINFO) Document Open Options (DOCVIEW) Page Label and Plate Color (PAGELABEL) Marked Content (MP, DP, BMC, BDC, EMC) Naming Graphics (BP, EP, SP) Naming Images (NI) Transparency (SetTransparency) Add Metadata to the Catalog (Metadata)
Annotations (ANN)
PDF supports several types of annotations. The properties of each annotation are specified in an annotation dictionary containing various keyvalue pairs. Section 8.4 of the PDF Reference describes all the types of annotations, and their required and optional dictionary entries. The pdfmark operator using the feature name ANN is used to specify an annotation in a PostScript file. The general syntax is: [ /Rect [xll yll xur yur] /Subtype name Optional keyvalue pairs /ANN pdfmark
19
Key Rect
Type array
Semantics An array of four numbers [xll, yll, xur, yur] specifying the lower-left x, lower-left y, upper-right x, and upper-right y coordinatesin user spaceof the rectangle defining the open note window or link button. The annotation s PDF subtype. If omitted, the value defaults to Text, indicating a note annotation. See Table 2.2 for the possible subtypes that can be used.
Subtype
name
Value of Subtype key Text Link FreeText Line Square Circle Highlight Underline StrikeOut Stamp Ink Popup FileAttachment Sound Movie Widget TrapNet
Description
Text annotation (note) Link annotation Free text annotation Line annotation Square annotation Circle annotation Highlight annotation Underline annotation Strikeout annotation Rubber stamp annotation Ink annotation Pop-up annotation File attachment annotation Sound annotation Movie annotation Widget annotation Trap network annotation
20
Each type has its own set of key-value pairs that may be specified, as described in the PDF Reference. Future versions of PDF may introduce new types. In addition to these types, annotations with unrecognized Subtype values, called custom annotations, are supported. Custom annotations may contain, in addition to the Rect and Subtype keys, arbitrary keyvalue pairs.
EXAMPLE 2.1 Custom Annotation
[/Rect [ 400 435 500 535 ] /Subtype /ADBETest_DummyType /ADBETest_F8Array [ 0 1 1 2 3 5 8 13 ] /ANN pdfmark
When viewed with Acrobat Viewer, this annotation appears with an unknown annotation icon. Table 2.3 lists optional keys that are common to all annotations. Specific annotation types have additional keys that they use. See section 8.4 of the PDF Reference (Version 1.4, 3rd Edition) for complete information.
TABLE 2.3 Optional annotation keys
Key SrcPg
Type integer
Semantics The sequence number of the page on which the annotation appears. (The first page in a document is always page 1.) If this key is present, the pdfmark may be placed anywhere in the PostScript language file. If omitted, the pdfmark must occur within the PostScript language description for the page on which the annotation is to appear. A color value used for the background of the annotations icon when closed; the title bar of the annotations pop-up window; and the border of a link annotation. The value is an array containing three numbers (red, green, and blue), each of which must be between 0 and 1, inclusive, specifying a color in the DeviceRGB color space. (See Section 4.5.3 in the PDF Reference for a description of this color space.) If omitted, a default color is used. The text label to be displayed in the title bar of the annotations pop-up window when open and active. The encoding and character set used is either PDFDocEncoding (as described in Appendix D in the PDF Reference) or Unicode. If Unicode, the string must begin with <FEFF>. For example, the string ABC is represented as (ABC) in PDFDocEncoding and <FEFF004100420043> in Unicode. Title has a maximum length of 255 PDFDocEncoding characters or 126 Unicode values, although a practical limit of 32 characters is advised so that it can be read easily in the Acrobat viewer.
array
string
21
TABLE 2.3
Type string
Semantics The date and time the note was last modified. It should be of the form: (D:YYYYMMDDHHmmSSOHH'mm') D: is an optional but strongly recommended prefix. YYYY is the year. All fields after the year are optional. MM is the month (01-12), DD is the day (01-31), HH is the hour (00-23), mm are the minutes (0059), and SS are the seconds (00-59). The remainder of the string defines the relation of local time to GMT. O is either + for a positive difference (local time is later than GMT) or - (minus) for a negative difference. HH' is the absolute value of the offset from GMT in hours, and mm' is the absolute value of the offset in minutes. If no GMT information is specified, the relation between the specified time and GMT is considered unknown. Regardless of whether or not GMT information is specified, the remainder of the string should specify the local time. The links border properties. Border is an array containing three numbers and, optionally, an array. All elements are specified in user space coordinates. If Border is of the form [bx by c], the numbers specify the horizontal corner radius (bx), the vertical corner radius (by), and the width (c) of the links border. The link has a solid border. If it is of the form [bx by c [d]], the fourth element (d) is a dash array that specifies the lengths of dashes and gaps in the links border. The default value for Border is [0 0 1]. A set of flags specifying various characteristics. See Section 8.4.2 of the PDF Reference. An appearance dictionary specifying how the annotation is presented visually. See Section 8.4.4 of the PDF Reference for details. The annotations appearance state. See Section 8.4.4 of the PDF Reference for details. An action to be performed when the annotation is activated. See Actions on page 41 for details.
NOTE:
Border
array
For links, this key is not permitted if the Dest key is present.
Notes on page 23 and Links on page 24 describe the syntax for two of the original and most commonly used annotation types in more detail.
22
Notes
Notes are known as text annotations in PDF. The syntax for creating a note is: [ /Contents string /Rect [xll yll xur yur] /SrcPg pagenum /Open boolean /Color array /Title string /ModDate datestring /Name name /Subtype /Text /ANN pdfmark In addition to the keys described in Table 2.1 and Table 2.3, the keys specific to text annotations are listed in Table 2.4. In addition to these keys, notes may also specify arbitrary keyvalue pairs.
TABLE 2.4 Keys specific to Text annotations
Key Contents
Type string
Semantics (Required) Contains the notes text string. The maximum length of the Contents string is 65,535 characters. The encoding and character set used is the PDFDocEncoding (described in Appendix D in the PDF Reference or Unicode. If Unicode, the string must begin with <FEFF>. (Optional) If true, the note is open (that is, the text is visible). If false (the default if omitted), the note is closed (that is, displayed as an icon). (Optional) The name of an icon to be used in displaying the note. The values are: Note (default), Comment, Help, Insert, Key, NewParagraph, Paragraph.
Open
boolean
Name
name
EXAMPLE 2.2
Text Annotation
[ /Contents (My unimaginative contents) /Rect [400 550 500 650] /Open false /Title (My Boring Title) % The following is private data. Keys within the private % dictionary do not need to use the organizations prefix % because the dictionary encapsulates them. /ADBETest_MyInfo << /Routing [(Me) (You)] /Test_Privileges << /Me /All /You /ReadOnly >> >> /ADBETest_PrivFlags 42 /ANN pdfmark
23
Links
A link annnotation represents either a hypertext link to a destination in the document, or an action to be performed. The usual syntax for creating a link is:
[/Rect [xll yll xur yur] /Border [bx by c [d]] /SrcPg pagenum /Color array /Subtype /Link Action-or-destination-specifying keyvalue pairs /ANN pdfmark
In addition to the keys described in Table 2.1 and Table 2.3, a link may also contain keys specifying destinations or actions, described in Chapter 3, Specifying Actions and Destinations.
EXAMPLE 2.3 Link Annotation
[ /Rect [70 550 210 575] /Border [0 0 2 [3]] /Color [0 1 0] /Page /Next /View [/XYZ -5 797 1.5] /Subtype /Link /ANN pdfmark
Other Annotations
Table 2.2 lists the other types of annotations that are available. For example, consider the following movie annotation.
EXAMPLE 2.4 Movie Annotation
[ /Subtype /Movie /Rect [ 216 503 361 612 ] /T (Title) /F 1 % The specified file may be a movie or sound file % Add your movie in place of "(/Disk/moviefile)" /Movie << /F (/Disk/moviefile) /Aspect [ 160 120 ] >> /A << /ShowControls true >> /Border [0 0 3] /C [0 0 1] /ANN pdfmark
One useful type of annotation is the widget annotation. Widgets are used by PDF interactive forms to represent the appearance of fields and to manage user interactions. See Section 8.6 of the PDF Reference for detailed information on using interactive forms. See Define the Widget annotations, which are also field dictionaries for this form on page 73 for examples of using widget annotations to create interactive forms.
24
Bookmarks (OUT)
Bookmarks are known as outline items in PDF. They are specified by using the pdfmark operator in conjunction with the feature name OUT. The syntax for a bookmark pdfmark is: [ /Title string /Count int /Color array /F integer Action-specifying keyvalue pairs /OUT pdfmark
TABLE 2.5
Bookmark Attributes
Key Title
Type string
Semantics (Required) The bookmarks text. The encoding and character set used is either PDFDocEncoding (as described in Appendix D in the PDF Reference) or Unicode. If Unicode, the string must begin with <FEFF>. For example, the Unicode string for (ABC) is <FEFF004100420043>. Title has a maximum length of 255 PDFDocEncoding characters or 126 Unicode values, although a practical limit of 32 characters is advised so that it can be read easily in the Acrobat viewer. (Required if the bookmark has subordinate bookmarks, omitted otherwise) This keys absolute value is the number of bookmarks immediately subordinatethat is, excluding subordinates of subordinates. If the value is positive, the bookmark is open, revealing its subordinates; if negative, the bookmark is closed, hiding its subordinates.
NOTE:
Count
integer
This differs from the PDFCount key, which represents the total number of open descendants at all lower levels of the outline hierarchy.
Color
array
(Optional, effective beginning with Acrobat 5.0) The bookmarks color. The value is an array containing three numbers (red, green, and blue), each of which must be between 0 and 1, inclusive, specifying a color in the DeviceRGB color space. (See Section 4.5.3 in the PDF Reference for a description of this color space.)
25
TABLE 2.5
Bookmark Attributes
Key F
Type integer
Semantics (Optional, effective beginning with Acrobat 5.0) The style of the bookmark. Four styles are implemented: 0: Plain (the default) 1: Italic 2: Bold 3: Bold and Italic
In addition to the keys listed in Table 2.5, a bookmark must contain keyvalue pairs that specify an action. See Chapter 3, Specifying Actions and Destinations, for more information. The bookmark pdfmarks may begin anywhere in the PostScript language file. However, they must appear in sequential order. See Bookmarks on page 62 for examples of bookmark pdfmarks.
Articles (ARTICLE)
Articles consist of a title and a list of rectangular areas called beads. Each bead is specified by using the pdfmark operator in conjunction with the feature name ARTICLE. Beads are added to the article in the order that they are encountered in the PostScript language file. The syntax for a bead pdfmark is: [ /Title string /Rect [xll yll xur yur] /Page pagenum /ARTICLE pdfmark
TABLE 2.6 Article Bead Attributes
Key Title
Type string
Semantics (Required) The title of the article to which a bead belongs. The encoding and character set used is either PDFDocEncoding (as described in Appendix D in the PDF Reference) or Unicode. If Unicode, the string must begin with <FEFF>. For example, the Unicode string for (ABC) is <FEFF004100420043>. Title has a maximum length of 255 PDFDocEncoding characters or 126 Unicode values, although a practical limit of 32 characters is advised so that it can be read easily in the Acrobat viewer. (Required) An array of four numbers [xll, yll, xur, yur] specifying the lower-left x, lower-left y, upper-right x, and upper-right y coordinatesin user spaceof the rectangle defining the bead.
Rect
array
26
TABLE 2.6
Key Page
Type integer
Semantics (Optional) The sequence number of the page on which the bead is located. A bead pdfmark that contains the optional Page key may be placed anywhere in the PostScript language file. A bead pdfmark that does not contain this key must occur within the PostScript language description for the page on which the article bead is to appear.
In addition to the keys listed in Table 2.6 the first bead in an article may also specify arbitrary keyvalue pairs. Suggested keys are Subject, Author, and Keywords.
NOTE:
27
affects only the first page of a document if it is placed before any marks are made on the first page. See Page Cropping on page 64 for examples of cropping.
Semantics (Optional) The documents author. (Optional) The date the document was created. See the description of the ModDate key for information on the strings format. (Optional) If the document was converted to PDF from another form, the name of the application that originally created the document. (Optional) The name of the application that converted the document from its native form to PDF. (Optional) The documents title. (Optional) The documents subject. (Optional) Keywords relevant for this document. These are used primarily in cross-document searches.
Creator
string
28
TABLE 2.7
Key ModDate
Type string
Semantics (Optional) The date and time the document was last modified. It should be of the form: (D:YYYYMMDDHHmmSSOHH'mm') D: is an optional prefix. YYYY is the year. All fields after the year are optional. MM is the month (01-12), DD is the day (01-31), HH is the hour (00-23), mm are the minutes (00-59), and SS are the seconds (00-59). The remainder of the string defines the relation of local time to GMT. O is either + for a positive difference (local time is later than GMT) or - (minus) for a negative difference. HH' is the absolute value of the offset from GMT in hours, and mm' is the absolute value of the offset in minutes. If no GMT information is specified, the relation between the specified time and GMT is considered unknown. Regardless of whether or not GMT information is specified, the remainder of the string should specify the local time.
Info dictionary pdfmarks may occur anywhere in the PostScript language file. See Info Dictionary on page 64 for examples.
The way the document is displayed. The options are: the document only, the document plus thumbnail images, the document plus bookmarks, or just the document in full screen mode. A location other than the first page that is to be displayed. An optional action that occurs.
The above information is contained in keyvalue pairs in the documents Catalog dictionary. It can be set using the pdfmark operator in conjunction with the name DOCVIEW. The syntax for specifying Catalog dictionary entries is: [ /PageMode name Action-specifying keyvalue pairs /DOCVIEW pdfmark The PageMode key specifies how the document is to be displayed when opened. It can take the following values:
UseNone Open the document, displaying neither bookmarks nor thumbnail images. UseOutlines Open the document and display bookmarks.
29
UseThumbs Open the document and display thumbnail images. FullScreen Open the document in full screen mode.
If PageMode is not specified, the value defaults to UseNone. The DOCVIEW pdfmark can also specify a destination (a page to which the document should be opened) or an action, by using additional keyvalue pairs. See Chapter 3, Specifying Actions and Destinations, for details about the keyvalue pairs that can be used. DOCVIEW pdfmarks may occur anywhere in the PostScript language file. See File Open Action on page 65 for an example.
30
BMC, BDC, and EMC bracket a marked-content sequence of objects in the content stream. Note that these are complete graphics objects, not just a sequence of bytes. Marked content can also be used in conjunction with PDFs logical structure facilities. See Chapter 4, Logical Structure, for information about pdfmark features that implement logical structure.
NOTE:
Marked-Content Points
MP creates a marked-content point in the PDF file. DP creates a marked-content point, with an associated property list. Their syntax is: [ tag /MP pdfmark [tag property-list /DP pdfmark tag is an optional name object indicating the role or significance of the point.property-list is a dictionary containing key-value pairs that are meaningful to the program creating the marked content.
Marked-content sequences
BMC and BDC begin a marked-content sequence, and EMC ends a sequence. Their syntax is: [ tag /BMC pdfmark [ tag property-list /BDC pdfmark [ /EMC pdfmark tag is an optional name for the sequence. property-list is a dictionary containing key-value pairs that are meaningful to the program creating the marked content.
31
[ /EP pdfmark [ {objname} /SP pdfmark The _objdef {objname} keyvalue pair in the BP pdfmark names the picture objname. Any subsequent pdfmark can refer to this object.
NOTE:
Graphics names are in the namespace governed by NamespacePush and NamespacePop, defined in Namespaces on page 15.
The BBox key is an array of four numbers [xll, yll, xur, yur] specifying the lower-left x, lower-left y, upper-right x, and upper-right y coordinatesin user spaceof the rectangle defining the graphics bounding box. When Distiller sees a BP pdfmark, it forks the distillation from the current context and distills subsequent graphics into a PDF Form object. When it encounters an EP pdfmark, Distiller finishes the Form object, and distillation continues in the original context. BP and EP pdfmark operators can be nested. The SP pdfmark tells Distiller to insert a use of a named picture in the current contextin the same manner as if it were a cached PostScript form painted with the execform PostScript language operator. It includes the picture in the current context (page, form, and so forth) using the current transformation matrix (CTM) to position the graphic. In addition to using SP to insert pictures, other pdfmark features that allow specifying named objects can add pictures built using BP and EP to a page. See Using the Graphics Encapsulation pdfmark Names (BP, EP, SP) on page 68 for an example. Even if you define the pdfmark operator so that a PostScript interpreter ignores any text between a mark and a pdfmark, any PostScript operators between the BP and EP pdfmarks will still be processed. To avoid printing anything between the BP and EP pdfmarks, use a conditional construct like the one shown in Using BP and EP pdfmarks to define button faces for forms on page 70.
32
The image named by an NI command is to be found subsequently in the PostScript source file, but it does not need to immediately follow the NI. An image is assigned the name given by the most recent NI not yet paired with an image. Another way of understanding this: Distiller maintains a stack of names pushed by NI and popped by the occurrence of an image. If an image is encountered when this stack is empty, it is not an error: the image simply does not receive a name.
Transparency (SetTransparency)
PDF 1.4 extends the Adobe imaging model to include the notion of transparency. See Chapter 7 in the PDF Reference for complete information on transparency. To produce PDF files with transparency from PostScript files, use the SetTransparency pdfmark feature. This feature provides a mechanism for specifying the following graphics state parameters:
TABLE 2.8 Graphics State Parameters for Transparency
Value
name or array of names dictionary or None number
Meaning
Current blend mode. Default is Normal.
Current soft mask, specifying the mask shape or mask opacity values. Default is None. Current stroking alpha constant, specifying the constant shape or constant opacity value to be used for stroking operations. Default is 1.0. Same as CA, but for nonstroking operation. Default is 1.0. The alpha source ag (alpha is shape), specifying whether the current soft mask and alpha constant are to be interpreted as shape values (true) or opacity values (false). Default is false. The text knockout ag, which determines the behavior of overlapping glyphs within a text object. Default is true.
number boolean
TK
boolean
The syntax of the SetTransparency feature is: [ keyvalue pairs /SetTransparency pdfmark where recognized key-value pairs are found in Table 2.8.
NOTE:
The keys used by this pdfmark feature are the same as are found in PDF documents.
The arguments to the SetTransparency feature are checked for correct types and values. Unrecognized keys are ignored and their values are not checked or written to the PDF document. If no recognized key-value pairs are presented, then this feature adds no transparency information to the PDF document.
33
The values set by this feature are subject to gsave/grestore. For example:
[ /ca .8 /SetTransparency pdfmark gsave [ /ca .7 /SetTransparency pdfmark grestore % Nonstroking alpha is now .8 % Nonstroking alpha is now .7 % Nonstroking alpha is now .8
The initgraphics operator resets all of the graphics state parameters for transparency to the defaults as shown in Table 2.8. The following PostScript demonstrates a use of the SetTransparency feature using Normal blend mode with differing opacities:
/DeviceCMYK setcolorspace 15 setlinewidth [ /ca .6 /CA .3 /BM /Normal /SetTransparency pdfmark 0 1 1 0 setcolor 220 330 150 0 360 arc fill 0 0 1 0 setcolor 320 503 150 0 360 arc fill 1 1 0 0 setcolor 420 330 150 0 360 arc fill % red % yellow % blue
1 0 0 0 setcolor 230 440 104 0 360 arc stroke % cyan 0 1 0 0 setcolor 410 440 104 0 360 arc stroke % magenta 0 0 1 0 setcolor 320 284 104 0 360 arc stroke % yellow
Compare this to the following in which the blend mode has been changed:
/DeviceCMYK setcolorspace 15 setlinewidth [ /ca .6 /CA .3 /BM /Difference /SetTransparency pdfmark 0 1 1 0 setcolor 220 330 150 0 360 arc fill 0 0 1 0 setcolor 320 503 150 0 360 arc fill 1 1 0 0 setcolor 420 330 150 0 360 arc fill % red % yellow % blue
1 0 0 0 setcolor 230 440 104 0 360 arc stroke % cyan 0 1 0 0 setcolor 410 440 104 0 360 arc stroke % magenta 0 0 1 0 setcolor 320 284 104 0 360 arc stroke % yellow
Note that filling and stroking the same path results in the use of the PDF f and S operators and not the B operator. This produces a double border effect and is not usually desirable.
/DeviceCMYK setcolorspace 15 setlinewidth [ /ca .6 /CA .3 /BM /Normal /SetTransparency pdfmark 0 1 1 0 setcolor 220 330 150 0 360 arc gsave fill grestore stroke 0 0 1 0 setcolor 320 503 150 0 360 arc gsave fill grestore stroke 1 1 0 0 setcolor 420 330 150 0 360 arc gsave fill grestore stroke % % % % % % red path fill, then stroke yellow path fill, then stroke blue path fill, then stroke
34
[ /_objdef {myForm} /BBox [xll yll xur yur] /Group group-dictionary ... /BP pdfmark
Soft Mask Dictionaries Because Distiller is configured to use execform (not /Form defineresource), there is no direct way for Distiller to access a PostScript form dictionary if it is not used by execform. But a form used by execform will always leave marks on the page. So the way to create a soft mask dictionary is to create a transparency group form XObject using the BP pdfmark feature, then refer to this form in the soft mask dictionary in the Graphics state. For example:
[ /_objdef {myForm} /BBox [xll yll xur yur] /Group dict /BP pdfmark ... define the shapes here /EP pdfmark % Name to be used by G in Soft Mask below
% Set the soft mask in Graphics state [ /SMask << /S /Alpha /G {myForm} >> /SetTransparency pdfmark
35
0.14 0.85 0.77 0.03 setcolor 72 600 50 0 360 arc fill 0.12 0.02 0.78 0 setcolor 110 650 50 0 360 arc fill 0.93 0.69 0.07 0.01 setcolor 147 600 50 0 360 arc fill [ /EP pdfmark % Draw the form... gsave [ /ca 0.5 /BM /Normal /SetTransparency pdfmark [ {aForm} /SP pdfmark grestore % Use the Form as Soft Mask... [ /SMask << /S /Alpha /G {aForm} >> /SetTransparency pdfmark ...
Soft Mask Images There are two ways to specify a soft mask in PDF: a soft-mask dictionary in the Graphics state as described above, and a soft-mask image associated with another image XObject (as an SMask entry). A soft-mask image XObject has the same entries as an ordinary image XObject, with some restrictions: 1. ColorSpace must be DeviceGray. 2. Matte is a array of component values in the color space of the parent image. 3. Width and Height must be the same as in the parent image if Matte is present. 4. ImageMask must be false or absent. 5. Mask and SMask must be absent. 6. BitsPerComponent is required. Distiller already has a mechanism for naming and identifying image objects using the NI pdfmark feature. To support softmasks, NI now recognizes three additional entries: IsSoftMask, Matte, and SMask.
TABLE 2.9 NI pdfmark
Value
{nameobject} boolean array {SoftMaskImageName}
Comments
A name object assigned to the next image. Default is false. Array of component values specifying matte color with which the parent image data has been pre-blended. {SoftMaskImageName} must be defined already by another NI
36
Using NI pdfmark, one must define the soft-mask image first and then use it as the SMask entry for the parent image. For example:
[ /_objdef {mySoftMask} % Name assigned to the next image. /SoftMask true % Next image {mySoftMask123} is a soft mask. /Matte [.1 .2 .3] /NI pdfmark ... define the soft mask image (ColorSpace must be /DeviceGray) [ /_objdef {myImage} /SMask {mySoftMask} /NI pdfmark ... define the image here % Name assigned to next image. % Associate soft mask {mySoftMask123}
In this example, the images ColorSpace must have three components and the image data must be pre-blended with [.1 .2 .3].
In future releases of Distiller, metadata may be attached to objects other than the Catalog object. If the target is not the Catalog object or if DSC processing is enabled and this feature is located within Encapsulated PostScript (EPS), then this feature is ignored. Otherwise, the metadata associated with the stream XMPStreamName is added to the Catalog object with the key Metadata. See the PDF Reference, Section 9.2.2, for more information. For example:
[ /_objdef {myMetadata} /type stream /OBJ pdfmark [ {myMetadata} currentfile 0 (% -- end --) /SubFileDecode filter /PUT pdfmark <?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?> <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' ... % -- end -[ {myMetadata} << /Type /Metadata /Subtype /XML>> /PUT pdfmark [ {Catalog} {myMetadata} /Metadata pdfmark
37
This use of this feature embeds file content into a name tree within the EmbeddedFiles dictionary of the name dictionary (Names, a collection of name trees). This corresponds to the following structure as found in PDF documents:
<< /Type /Catalog /Names << /EmbeddedFiles << /Names [ (Unicode Name) << /F (name) /EF << ... >> >> ] >> >> >> % % % % % % % % The The One The catalog dictionary name dictionary; see PDF 1.4, p. 92 particular name tree; see p. 93, 101-102 name tree node; p. 102
Unique Unicode string used for Acrobat access The file specification dictionary; p. 122 The file name for export Embedded file stream dictionary; p. 124
For example:
/NamespacePush pdfmark /_objdef {fstream} /type /stream /OBJ pdfmark {fstream} << /Type /EmbeddedFile >> /PUT pdfmark {fstream} (Simulating file content here) /PUT pdfmark /Name (Unicode Unique Name) % e.g., <feff 0041 0073> is Unicode for As /FS << /Type /Filespec /F (myfile.txt) /EF << /F {fstream} >> >> /EMBED pdfmark [ {fstream} /CLOSE pdfmark [ /NamespacePop pdfmark [ [ [ [ [
Compatibility Notes
The following pdfmark names are compatible with older versions of Distiller, but are not recommended to be used with the current version.
38
As of Acrobat version 5.0, this feature is no longer supported in any PDF files of version 1.4 and later.
Blocks of PostScript language code can be specified by using the pdfmark operator in conjunction with the name PS. Any PostScript language code specified in this manner is copied directly into the PDF file without being distilled, and is ignored when the PDF file is viewed using Acrobat or Adobe Reader . It is only used when the PDF file is printed to a PostScript printer.
NOTE:
Pass-through PostScript language code should be used only when PDF does not provide another way to achieve the same result.
The syntax for specifying a block of pass-through PostScript language code is: [ /DataSource string or file /Level1 string or file /PS pdfmark
TABLE 2.10
Key DataSource
Semantics (Required) The PostScript language commands to copy into the PDF file. See the discussion of the file operator in the PostScript Language Reference Manual, Third Edition for information on specifying files. (Optional) PostScript Level 1 language code that is used instead of the value of the DataSource key when printing to a printer that supports only PostScript Level 1.
Level1
string or file
This pdfmark must be placed in the PostScript language program at the point where the block of code is to be executed during printing.
39
40
File specifiers are indicate the target of an action when it is not the current file. See Table 3.2, File specifier keys.
Actions
PDF defines several types of actions that can be specified for bookmarks and annotations. The types defined as of PDF 1.3 are:
TABLE 3.1 Action types
Action type GoTo GoToR Launch Thread URI Sound Movie Hide
Description
Go to a destination in the current document Go to a destination in another document Launch an application, usually to open a file Begin reading an article thread Resolve a uniform resource identifier Play a sound Play a movie Set an annotations Hidden flag
41
TABLE 3.1
Action types
Description
Execute an action predefined by the viewer application Send data to a URL Set fields to their default values Import field values from a files Execute a JavaScript script.
When using pdfmark, the type of action for the annotation or bookmark is specified by the Action key. It takes one of the following values:
A predefined name corresponding to one of the first four items in Table 3.1: GoTo, GoToR, Launch, or Article (which corresponds to the Thread type in PDF). A dictionary specifying one of the other types, or a custom action. This dictionary must contain the keyvalue pairs that are to be placed into the action dictionary in the PDF file. See Section 8.5 in the PDF Reference for a detailed description of all the actions and their dictionaries. The syntax for this type of Action key is: /Action << / Subtype actiontype ...other action dictionary keyvalue pairs... >> Custom link action (URI link for the Acrobat WebLink plug-in) on page 61 shows a note pdfmark containing a URI action.
If the Action key is not present, the action is assumed to be the equivalent of GoTo; that is, jumping to a location in the current document. Actions other than GoTo may require a filespecifier key to specify an external document (see Table 3.2, File specifier keys).
GoTo Actions
GoTo actions jump to a specified page and zoom factor within the current document. They require the Dest key, or both the Page and View keys. See Destinations on page 44 for more information on these keys.
GotoR Actions
GoToR actions specify a location in another PDF file. They require the Dest key, or both the Page and View keys, plus one or more file-specifier keys (see Table 3.2). See Bookmarks on page 62 for an example of a GoToR action. The following table specifies keys that can be used with the GoToR, Launch, and Article actions to specify the target file.
42
TABLE 3.2
Semantics (Required) The device-independent pathname of the PDF file. (Optional) The MS-DOS pathname (in the PDF pathname format), of the PDF file. Acrobat viewer applications on Windows and DOS computers ignore the File key if the DOSFile key is present. (Optional) The Mac OS filename (in the PDF pathname format) of the PDF file. Acrobat viewer applications on Mac OS computers ignore the File key if the MacFile key is present. (Optional) The UNIX filename (in the PDF pathname format) of the PDF file. Acrobat viewer applications on UNIX computers ignore the File key if the UnixFile key is present. (Optional) The uniform resource identifier (URI) of a file on the internet. It can be an HTML file as well as a PDF file. Acrobat viewer applications ignore the File key if the URI key is present. Named destinations may be appended to URLs, following a # character, as in http://www.adobe.com/test.pdf#name. The Acrobat viewer displays the part of the PDF file specified by the named destination.
NOTE:
MacFile
string
UnixFile
string
URI
string
This key is used with the Launch action. URIs can also be specified with an action dictionary where the value of the Subtype key is /URI (see examples on page 61.)
ID
array
(Optional) An array of two strings specifying the PDF file ID. This key can be used to ensure the correct version of the destination file is found. If present, the destination PDF files ID is compared with ID, and the user is warned if they are different.
Section 3.10 of the PDF Reference provides more information about the above specifiers.
Launch Actions
Launch actions launch an arbitrary application or document, specified by the File key. If an application is specified, some platforms allow passing options or filenames to the application that is launched. See Link that launches another file on page 61 for an example of a launch action. See Table 3.2 for the file specifier keys that can be used by Launch actions. In addition, the following optional keys can be used:
43
TABLE 3.3
Key Dir Op
Semantics (Optional) The default directory of a Windows application. (Optional) The operation to perform; used only under Windows. The string must be open (the default) or print. If WinFile specifies an application, not a document, this key is ignored and the application is launched. (Optional) The MS-DOS filename of the document or application to launch. (Optional) The parameters passed to a Windows application started with the Launch action. If the WinFile key specifies an application, Params must not be present.
WinFile Params
string string
NOTE:
Acrobat viewer applications running under Windows use the Windows function ShellExecute() to launch an application specified using the Launch action. The keys WinFile, Dir, Op, and Params correspond to the parameters of ShellExecute.
Article Actions
Article actions set the Acrobat viewer to article-reading mode, at the beginning of a specified article in the current document or another PDF document. They require the Dest key, which takes one of the following values:
An integer that specifies the articles index in the document (the first article in a document has an index of 0) A string that matches the articles Title.
In addition, article actions require one or more file-specifier keys if the article is in a different PDF file (see Table 3.2). See Article action on page 63 for an example of an article action.
Destinations
There are two ways of specifying a location within a document that is the target of an action:
View destinations explicitly specify a page, a location on the page, and a fit type. See View Destinations on page 45. Named destinations specify the target as a name which has been defined. See Defining Named Destinations on page 46.
44
View Destinations
View destinations require the following two keys:
TABLE 3.4 Keys for view destinations
Key Page
Semantics The destination page. An integer value represents the sequence number of the page within the PDF file.
NOTE:
The name objects Next and Prev are valid destination page values for links and articles. If the destination of a link is on the same page, the Page key should be omitted. If the value of the Page key is 0, the bookmark or link has a NULL destination. View array Specifies a link or bookmarks destination on a page, and its fit type. The first array entry is one of the fit type names shown in Table 3.5. The remaining entries, if any, specify the location as either a rectangle, a point, or an x or ycoordinate, depending on the fit type.
All distances and coordinates specified in Table 3.5 are in default user space.
TABLE 3.5 Fit type names and parameters
Name Fit
Parameters and semantics No parameters. Fit the page to the window. This is a shortcut for specifying FitR with the rectangle being the crop box for the page. No parameters. Fit the bounding box of the page contents to the window. top Fit the width of the page to the window. top specifies the distance from the page origin to the top of the window. This is a shortcut for specifying FitR with the rectangle having the width of the page, and both y-coordinates equal to top. top Fit the width of the bounding box of the page contents to the window. top specifies the distance from the page origin to the top of the window. x1 y1 x2 y2 Fit the rectangle specified by the parameters to the window.
FitB FitH
FitBH
FitR
45
TABLE 3.5
Name FitV
Parameters and semantics left Fit the height of the page to the window. left specifies the distance in from the page origin to the left edge of the window. This is a shortcut for specifying FitR with the rectangle having the height of the page, and both x-coordinates equal to left. left Fit the height of the bounding box of the page contents to the window. left specifies the distance from the page origin to the left edge of the window. left top zoom left and top specify the distance from the origin of the page to the top-left corner of the window. zoom specifies the zoom factor, with 1 being 100% magnification. If left, top or zoom is NULL, the current value of that parameter is retained. For example, specifying a view destination of
/View [/XYZ NULL NULL NULL]
FitBV
XYZ
goes to the specified page and retain the same horizontal and vertical offset and zoom as the current page. A zoom of 0 has the same meaning as a zoom of NULL. The zoom factors for the horizontal and vertical directions are identical; there are not separate zoom factors for the two directions. As a result, more of the page may be shown than specified by the destination. For example, when using FitR, portions of the page outside the destination rectangle appear in the window, unless the window happens to have the same aspect ratio (height-to-width ratio) as the destination rectangle. A common destination is upper left corner of the specified page, with a zoom factor of 1. This can be obtained using the XYZ destination form, with a left of -4 and a top equal to the top of the CropBox (or the page size if no CropBox was specified) plus 4. The offset of 4 is used to slightly move the page corner from the corner of the window, to provide a visual cue that the corner of the page is being shown. The following examples illustrate destinations: Links on page 60, Bookmarks on page 62, File Open Action on page 65 and Named Destinations on page 65.
46
A named destination is specified by using the pdfmark operator in conjunction with the name DEST. The syntax for a named destination pdfmark is: [ /Dest /Page /View /DEST name pagenum destination pdfmark
TABLE 3.6
Semantics (Required) The destinations name. (Optional) The sequence number of the destination page. If present, the named destination pdfmark may be placed anywhere in the PostScript language file. If omitted, the pdfmark must occur within the PostScript language description for the destination page. (Optional) The view to display on the destination page. If omitted, defaults to a null destination (lower left corner of the page at a zoom of 100%). See Destinations on page 44 for information on specifying a view destination.
View
array
In addition to the keys listed in Table 3.6 named destinations may also specify arbitrary keyvalue pairs. Named destinations may be appended to URLs, following a # character, as in http://www.adobe.com/test.pdf#nameddest=name. The Acrobat viewer displays the part of the PDF file specified in the named destination. See Named Destinations on page 65 for examples of named destinations.
47
48
Logical Structure
PDF files (in Versions 1.3 and beyond) can contain structure trees giving a logical structure to the information in a document. The facilities for logical structure in PDF are described in Section 9.6 of the PDF Reference (Version 1.4, 3rd Edition). There is a structure suite of names used in conjunction with the pdfmark operator that can be used to specify logical structure within PDF files. Structure Examples on page 76 gives a variety of examples of using the structure suite.
EXAMPLE 4.1
Some operators that specify an element cannot accept the Structure Tree Root as the implicit argument; therefore these commands are in error if the implicit parent stack is empty when they are encountered or if the top item on the stack is the Structure Tree Root. These cases are noted in the command descriptions.
Structure Operators
This section lists the pdfmark names that make up the structure suite. Most of these are directly related to PDF logical structure features, but some only manipulate the state of the PDF creation process, without corresponding to any particular output.
Structure Tree Root StRoleMap adds entries to the role map. StClassMap adds entries to the class map. Elements StPNE creates a new structure element.
49
Logical Structure
Structure Tree Root
StBookmarkRoot creates a root bookmark for a structure bookmark tree. StPush pushes an existing element onto the implicit parent stack. StPop pops an element off the implicit parent stack. StPopAll completely empties the implicit parent stack.
Element Content StBMC indicates the beginning of marked content. StBDC indicates the beginning of marked content with a dictionary. EMC delimits the end of marked content. StOBJ adds an existing PDF object as part of an elements content. Attributes StAttr enables the attachment of attribute objects to elements. Saving and restoring the stack StStore saves the current state of the implicit parent stack. StRetrieve restores the implicit parent stack from a saved state.
StRoleMap
StRoleMap specifies key-value pairs to be added as dictionary entries to the Structure Tree Roots role map. If the Structure Tree Root doesnt already exist, it is created; if the Structure Tree Root doesnt have a role map dictionary, one is created. A given keyvalue pair always modifies the role map, even if the key is already in the dictionary. The syntax for adding entries to a role map is: [ /new-element-subtype-name /standard-structural-subtype-name ... /new-element-subtype-name /standard-structural-subtype-name /StRoleMap pdfmark
50
Logical Structure
Elements
StClassMap
StClassMap behaves like StRoleMap, except that it adds entries to the Structure Tree Roots class map, rather than the role map. The syntax for adding entries to a class map is: [ /class-name /attribute-object-name ... /class-name /attribute-object-name /StClassMap pdfmark
Elements
The structure suite provides several commands to create elements and link them into structure trees.
StPNE
StPNE (Push New Element) creates a new element whose parent is the element on the top of the implicit parent stack. Its syntax is: [ /Subtype name /_objdef {objname} /Title string /Alt string /ID string /Class name /At integer /Bookmark dictionary /StPNE pdfmark
EXAMPLE 4.3
Semantics (Required) The element type, such as Link or Section. (Optional) A human-readable name for the particular element. (Optional) An alternate representation of the elements contents as human-readable text. (Optional) A unique identifier for the element. The identifier must be unique within the document in which the element occurs. It is an error to specify an element with the same ID as an existing element in the same tree.
51
Logical Structure
Elements
TABLE 4.1
Key Class At
Semantics (Optional) The class name to be associated with the element. (Optional) Index at which to insert this item within its parent. If omitted, or greater than or equal to the parents current number of children, the item is added as the last child of its parent, retaining all existing items in their original positions. If less than or equal to zero, the new item becomes the first child of its parent. If the index is any other number, the item is inserted at that index within the container, and all items that had indices greater than or equal to the given index are shifted to the position with index one greater. An item may be an element, marked content, or a PDF object. (Optional) Specifies a bookmark that is generated for this structural element. Table 4.2 describes this dictionary.
Bookmark
dictionary
EXAMPLE 4.1
A new element is added to its parent at the index specified with the At key. The newlycreated element is pushed onto the implicit parent stack.
NOTE:
If the implicit parent stack is empty, the Structure Tree Root is pushed onto the stack and used as the new elements parent. If there is no Structure Tree Root, one is created, pushed onto the stack, and used as the new elements parent.
StPNE may also take the key _objdef to specify an object name for the element. Once an element is named, it can be referenced with the E key of the StPush pdfmark (see StPush on page 53). The Bookmark key allows a bookmark to be automatically generated for an element and added to the Structured Bookmark subtree. Its value is a bookmark dictionary, which may contain the Title and Open keys described in Table 4.2.
TABLE 4.2 Bookmark dictionary / bookmark tree root
Key Title
Type string
Semantics (Optional) Bookmark title. The encoding and character set used is either PDFDocEncoding (as described in Appendix D in the PDF Reference) or Unicode. If Unicode, the string must begin with <FEFF>. For example, the Unicode string for (ABC) is <FEFF004100420043>. Title has a maximum length of 255 PDFDocEncoding characters or 126 Unicode values, although a practical limit of 32 characters is advised so that it can be read easily in the Acrobat viewer.
52
Logical Structure
Elements
TABLE 4.2
Key Open
Type boolean
Semantics (Optional) If true, the bookmark is open, that is, its children are visible. If false, the bookmark is closed. If this key is absent, the bookmark is closed.
If the Title key is absent, the title is the title of the element or its subtype. The bookmark dictionary may also contain key-value pairs that specify an action to be taken when the bookmark is activated (see Chapter 3, Specifying Actions and Destinations). If none of the action keys are present, the bookmarks action is to go to either the first page where a marked content is a child of this element or a child in one of its descendant elements. A bookmark for a structural element on page 78 defines a bookmark for an element.
StBookmarkRoot
StBookmarkRoot creates the root bookmark for structure bookmarks added by a StPNE with a Bookmark key. Its syntax is: [ /Title string /Open boolean ... action-specifying-keys ... /StBookmarkRoot pdfmark It contains the Title and Open keys shown in Table 4.2. If the Title key is absent, the title is Untitled. It may also contain the action keys in Chapter 3, Specifying Actions and Destinations. if none of these keys are present, the bookmark root has no action associated with it. An operator with StBookmarkRoot must appear before any StPNE with a Bookmark key; otherwise the default (Untitled, closed, no action) is used for the structured bookmark subtree.
StPush
StPush pushes an existing element onto the implicit parent stack. The syntax for pushing an element is:
[/E {objname} /StPush pdfmark
The E key specifies an existing element, given as an object name of the special form {objname} used to refer to Cos objects. It must be a name that was created by a previous StPNE using the _objdef key (see StPNE on page 51).
NOTE:
If the E key is omitted, the Structure Tree Root of the document is specified. The Structure Tree Root is created if it does not already exist.
53
Logical Structure
Specifying Element Content
StPop
StPop removes the element at the top of the implicit parent stack. It is an error for StPop to be encountered when the implicit parent stack is empty. The syntax for popping an element is: [ /StPop pdfmark
StPopAll
StPopAll completely empties the implicit parent stack. The syntax for emptying the stack is: [ /StPopAll pdfmark
StUpdate
StUpdate updates the entries of the current structure element. The syntax is: [ << /S /Span... >> /StUpdate pdfmark
Marked content can be specified independently of the structure suite, using the operators described in Marked Content (MP, DP, BMC, BDC, EMC) on page 30.
It is possible to nest marked content by nesting the StBMC/BDC and EMC operators. This is different than the nesting maintained by the tree structure of elements, which is implemented using StPNE and StPop. Note that nested marked content may belong to elements in different branches of a Structure Tree. To specify references to PDF objects, use the StOBJ operator.
StBMC
StBMC marks the beginning of a sequence of marked content objects. Its syntax is: [ /T tag /At integer /StBMC pdfmark
54
Logical Structure
Specifying Element Content
The marked content is added to its containing element (the top element of the implicit parent stack) at the position optionally specified by the At key (see Table 4.1). The T key is described in Table 4.3. It is an error if the implicit parent stack is empty when StBMC is encountered.
TABLE 4.3 Specifying tags and property list entries for Marked Content
Key T (Tag)
Type name
Semantics (Optional) The tag to be given to the marked content being created. If this key is omitted, the subtype of the containing element is used. (Optional) Keyvalue pairs that are entered into the properties dictionary of the marked content being created. If this key is omitted, no properties other than those required by the implementation of logical structure in PDF are entered into the properties dictionary. This key is supported only with StBDC.
P (Properties)
dictionary
StBDC
StBDC marks the beginning of a sequence of page content objects with an associated property list, given by a dictionary. StBDC behaves just like StBMC, with the addition of a property list. Its syntax is: [ /T tag /P properties-dictionary /At integer /StBDC pdfmark The marked content is added to its containing element (the element on top of the implicit parent stack) at the position optionally specified by the At key (see Table 4.1). The P (Properties) and T (Tag) keys are described in Table 4.3. It is an error if the implicit parent stack is empty when StBDC is encountered.
EMC
EMC signals the end of a marked sequence of page content operators. Its syntax is: [ /EMC pdfmark
StOBJ
StOBJ adds an existing PDF object to the content of the top element of the implicit parent stack, using the Cos object reference mechanism. Its syntax is: [ /Obj {objname} /At integer /StOBJ pdfmark
55
Logical Structure
Attribute Objects
The Obj key specifies the object to be added as data to the specified element, given as an object name of the special form {objname} used to refer to Cos objects. This object must have been created previously and must be a dictionary or stream. The At key (see Table 4.1) specifies the position of the new content within the containing element. It is an error if the implicit parent stack is empty when StOBJ is encountered.
Attribute Objects
Elements can have additional information, or attributes, associated with them. Attributes are held in attribute objects, which can be associated with either a single element by using StAttr (see StAttr on page 56), or with a group of objects by storing it in the ClassMap of the Structure Tree Root, using StClassMap (see StClassMap on page 51).
StAttr
StAttr creates a new attribute object and adds it to the element on top of the implicit parent stack. The syntax to create a new attribute object is: [ /Obj {objname} /StAttr pdfmark The Obj key specifies the object to be added as an attribute object to the specified element, given as an object name of the special form {objname} used to refer to Cos objects. This object must have been created previously and must be a dictionary or stream.
NOTE:
In the PDF file, the attribute object is stored in the A key in the elements dictionary.
56
Logical Structure
EPS Considerations
NOTE:
The names under which implicit parent stacks are stored and retrieved are in the current namespace governed by the stack operators NamespacePush and NamespacePop, defined in Namespaces on page 15.
StStore
StStore saves the current state of the implicit parent stack (without changing it). Its syntax is: [ /StoreName name /StStore pdfmark The StoreName key specifies a name object to be associated with the saved implicit parent stack state. Storing an implicit parent stack state under a previously used name completely replaces the implicit parent stack state already stored under that name.
StRetrieve
StRetrieve restores the implicit parent stack from a saved state, whose name is specified by the StoreName key (as described in StStore on page 57). The syntax for a restoring the current state is: [ /StoreName name /StRetrieve pdfmark The previous state of the implicit parent stack is overwritten by the restored state. It is an error to try to retrieve a nonexistent state, that is, to use a name that was not associated with a stack state by a previous StStore.
EPS Considerations
Encapsulated PostScript (EPS) is a special form of PostScript used to embed graphics created in one application in a document created in another application. Applications can create EPS files containing structure elements without knowing anything about the environment into which the EPS file is to be embedded, which complicates the processing of a structure inside embedded EPS. The logical structure design here allows structure within an embedded EPS to be connected to the structure of the surrounding file by way of the implicit parent stack, while insulating the namespace of the containing file from accidents due to naming coincidences in embedded EPS files. It is strongly recommended that applications embedding EPS files wrap the embedded PostScript between NamespacePush and NamespacePop to insulate the overall PostScript document from the consequences of multiply-defined object names.
57
Logical Structure
Tagged PDF
Tagged PDF
PDF 1.4 introduces the concept of tagged PDF. Tagged PDF is a type of structured PDF that allows page content to be extracted and reused for various purposes, such as reflow of text and graphics, conversion to various file formats such as HTML and XML, and accessibility to the visually impaired. For detailed information on tagged PDF, see section 9.7 of the PDF Reference. In PDF 1.4, the Catalog dictionary contains a MarkInfo entry whose value is a dictionary. That dictionary has a single key called Marked whose value is a boolean; a value of true indicates that the document is a tagged PDF. The syntax for indicating tagged PDF using pdfmark is: [ {Catalog} <</MarkInfo <</Marked true >> >> /PUT pdfmark See Tagged PDF on page 82 for an example of using tagged PDF.
EXAMPLE 4.1
58
Examples
This section gives examples illustrating many uses of the pdfmark operator.
Notes
Simple note
[ /Rect [75 586 456 663] /Contents (This is an example of a note. You can type text directly into a note or copy text from the clipboard.) /ANN pdfmark
Fancy note
[ /Rect [75 425 350 563] /Open true /Title (John Doe) /Contents (This is an example of a note. \nHere is some text after a forced line break. This is another way to do line breaks.) /Color [1 0 0] /Border [0 0 1] /ANN pdfmark
59
Examples
Links
Links
Simple Link (old style, compatible with all Distiller application versions)
[ /Rect [70 650 210 675] /Page 3 /View [/XYZ -5 797 1.5] /LNK pdfmark
Link
[ /Rect [70 650 210 675] /Border [16 16 1] /Color [1 0 0] /Page 1 /View [/FitH 5] /Subtype /Link /ANN pdfmark
Fancy link
[ /Rect [70 550 210 575] /Border [0 0 2 [3]] /Color [0 1 0] /Page /Next /View [/XYZ -5 797 1.5] /Subtype /Link /ANN pdfmark
60
Examples
Links
Custom link action (URI link for the Acrobat WebLink plug-in)
[ /Rect [50 425 295 445] /Action << /Subtype /URI /URI (http://www.adobe.com) >> /Border [0 0 2] /Color [.7 0 0] /Subtype /Link /ANN pdfmark % Equivalent link using Launch action [ /Rect [50 425 295 445] /Action /Launch /Border [0 0 2] /Color [.7 0 0] /URI (http://www.adobe.com) /Subtype /Link /ANN pdfmark % URI link with a named destination [ /Rect [50 425 295 445] /Action << /Subtype /URI /URI (http://www.adobe.com#YourDestination) >> /Border [0 0 2] /Color [.7 0 0] /Subtype /Link /ANN pdfmark
61
Examples
Bookmarks
Movie annotation
[ /Subtype /Movie /Rect [ 216 503 361 612 ] /T (Title) /F 1 % The specified file may be a movie or sound file % Add your movie in place of "(/Disk/moviefile)" /Movie << /F (/Disk/moviefile) /Aspect [ 160 120 ] >> /A << /ShowControls true >> /Border [0 0 3] /C [0 0 1] /ANN pdfmark
Bookmarks
[ /Count 2 /Page 1 /View [/XYZ 44 730 1.0] /Title (Open Actions) /OUT pdfmark [ /Action /Launch /File (test.doc) /Title (Open test.doc) /OUT pdfmark [ /Action /GoToR /File (test.pdf) /Page 2 /View [/FitR 30 648 209 761] /Title (Open test.pdf on page 2) /OUT pdfmark [ /Count 2 /Page 2 /View [ /Page 2 /View [/XYZ 44 [ /Count 1 /Page 2 /View /OUT pdfmark [ /Page 2 /View [/XYZ 44 [/XYZ 44 730 1.0] /Title (Fixed Zoom) /OUT pdfmark 730 2.0] /Title (200% Magnification) /OUT pdfmark [/XYZ 44 730 4.0] /Title (400% Magnification) 730 5.23] /Title (523% Magnification) /OUT pdfmark
[ /Count 3 /Page 1 /View [/XYZ 44 730 1.0] /Title (Table of Contents #1) /OUT pdfmark [ /Page 1 /View [/XYZ 44 730 1.0] /Title (Page 1 - 100%) /OUT pdfmark [ /Page 2 /View [/XYZ 44 730 2.25] /Title (Page 2 - 225%) /OUT pdfmark [ /Page 3 /View [/Fit] /Title (Page 3 - Fit Page) /OUT pdfmark [ /Count -3 /Page 1 /View [/XYZ /OUT pdfmark [ /Page 1 /View [/XYZ null null [ /Page 2 /View [/XYZ null null [ /Page 3 /View [/XYZ null null 44 730 1.0] /Title (Table of Contents #2) 0] /Title (Page 1 - Inherit) /OUT pdfmark 0] /Title (Page 2 - Inherit) /OUT pdfmark 0] /Title (Page 3 - Inherit) /OUT pdfmark
[ /Count 1 /Page 0 /Title (Articles) /OUT pdfmark [ /Action /Article /Dest (Now is the Time) /Title (Now is the Time) /OUT pdfmark
62
Examples
Articles
% Bookmark with color and style (new in Acrobat 5.0) [ /Count 0 /Title (Adobes Home Page) /Action /Launch /URI (http://www.adobe.com) /C [1 0 0] /F 3 /OUT pdfmark % Bookmark with a URI as an action [ /Count 0 /Title (Adobes Home page) /Action << /Subtype /URI /URI (http://www.adobe.com)>> /OUT pdfmark
Articles
Article action
[ /Action /Article /Dest (Now is the Time) /Title (Now is the Time) /OUT pdfmark
63
Examples
Page Cropping
Page Cropping
Crop this page
% ... [ /CropBox [0 0 288 288] /PAGE pdfmark /Helvetica findfont 12 scalefont setfont /DrawBorder { 10 278 moveto 278 278 lineto 278 10 lineto 10 10 lineto closepath stroke } bind def %%EndSetup %%Page: 1 1 DrawBorder 75 250 moveto (This is Page 3) show 75 230 moveto (Click here to go to page 1.) show 75 200 moveto (Click here to open test.doc.) show
Info Dictionary
[ /Title (My Test Document) /Author (John Doe) /Subject (pdfmark 3.0) /Keywords (pdfmark, example, test) /Creator (Hand Programmed) /ModificationDate (D:19940912205731)
64
Examples
File Open Action
Page Label
%%Page: Sec1:2 1 %%PlateColor: Cyan [ /Label (Sec1:1) /PlateColor (Cyan) /PAGELABEL pdfmark %%Page: iii 3 [ /Label (iii) /PAGELABEL pdfmark
Named Destinations
Definition of named destination
[ /Dest /Page /View /DEST /MyNamedDest 1 [/FitH 5] pdfmark
65
Examples
Named Objects
Named Objects
Creating user-defined named objects
[ /_objdef {myarrayname} /type/ array /OBJ pdfmark [ /_objdef {mydictname} /type /dict /OBJ pdfmark [ /_objdef {mystreamname} /type /stream /OBJ pdfmark
66
Examples
Named Objects
/Rect [500 500 550 550] /Contents (Here is a text annotation) /ANN pdfmark
67
Examples
Using the Graphics Encapsulation pdfmark Names (BP, EP, SP)
% Create a stream for the Alternate Image [/_objdef {myPrintingImageStream} /type /stream /OBJ pdfmark % Add the necessary key-value pairs to the stream dictionary to make it a % valid image XObject. % This particular image XObject uses the external streams capability of PDF % to point to an image stored on an IIP server, retrieving it as a JPEG file. % Since all stream data is stored on a web server, we dont explicitly add % data to the stream. As a result, the stream ends up with a length of zero, % which is OK for external streams. [ {myPrintingImageStream} << /Type /XObject /Subtype /Image /Width 150 /Height 150 /FFilter /DCTDecode /ColorSpace /DeviceRGB /BitsPerComponent 8 /F << /FS /URL /F (http://www.mycompany.com/myfile.jpg) >> >> /PUT pdfmark % Add an Alternates array to the base image [ {myImage} << /Alternates [ <</Image {myPrintingImageStream} /DefaultForPrinting true >> ] >> /PUT pdfmark
Alternate image data is outside of PDF file Alternate image data inside PDF file
The above sample shows only how to construct the first type. Note also that if the Alternate uses a different color space than the base image, it is possible that the PDF file may not contain the appropriate ProcSet references in the Resources dictionary to print the page to PostScript. For example, if the base image is grayscale and the Alternate is DeviceRGB, it is likely that the pages Resources contains only the ImageB procset (for grayscale images) and not the ImageC procset (for color images).
68
Examples
Using the Graphics Encapsulation pdfmark Names (BP, EP, SP)
0 0 moveto 100 100 lineto stroke 100 0 moveto 0 100 lineto stroke [ /EP pdfmark % make the picture appear on the page [ {MyPicture} /SP pdfmark % make the picture appear in another place on the page gsave 200 200 translate [ {MyPicture} /SP pdfmark grestore % make the picture appear in another place on the page at a different size gsave 100 400 translate .5 .5 scale [{MyPicture} /SP pdfmark grestore % draw another gray rectangle 0.5 setgray 512 692 100 100 rectfill showpage
The resulting page stream in the PDF file contains the following:
0.5 g 0 0 100 q 1 0 0 q 1 0 0 q 0.5 0 512 692 100 re f 1 0 0 cm /Fm1 Do Q 1 200 200 cm /Fm1 Do Q 0 0.5 100 400 cm /Fm1 Do Q 100 100 re f
The graphics between the BP and the EP pdfmarks have been saved in a Form object, which has this stream:
0 g 0 0 m 100 100 l 100 0 m 0 100 l S
69
Examples
Using the Graphics Encapsulation pdfmark Names (BP, EP, SP)
70
Examples
Forms Examples
[ /BBox [0 0 200 100] /_objdef {Down} /BP pdfmark { 0.7 setgray 0 0 200 100 rectfill 1 setgray 2 2 moveto 2 98 lineto 198 98 lineto 196 96 lineto 4 96 lineto 4 4 lineto fill 0.34 setgray 198 98 moveto 198 2 lineto 2 2 lineto 4 4 lineto 196 4 lineto 196 96 lineto fill 0 setgray 8 22.5 moveto 0 0 1 setrgbcolor /Helvetica 72 selectfont (Down) show } ?pdfmark [ /EP pdfmark % Submit button appearances [ /BBox [0 0 250 100] /_objdef {Submit} /BP pdfmark { 0.6 setgray 0 0 250 100 rectfill 1 setgray 2 2 moveto 2 98 lineto 248 98 lineto 246 96 lineto 4 96 lineto 4 4 lineto fill 0.34 setgray 248 98 moveto 248 2 lineto 2 2 lineto 4 4 lineto 246 4 lineto 246 96 lineto fill /Helvetica 76 selectfont 0 setgray 8 22.5 moveto (Submit) show } ?pdfmark [ /EP pdfmark [ /BBox [0 0 250 100] /_objdef {SubmitP} /BP pdfmark { 0.6 setgray 0 0 250 100 rectfill 0.34 setgray 2 2 moveto 2 98 lineto 248 98 lineto 246 96 lineto 4 96 lineto 4 4 lineto fill 1 setgray 248 98 moveto 248 2 lineto 2 2 lineto 4 4 lineto 246 4 lineto 246 96 lineto fill /Helvetica 76 selectfont 0 setgray 10 20.5 moveto (Submit) show } ?pdfmark [ /EP pdfmark
Forms Examples
This examples in this section show how to use the Forms pdfmark suite.
Fields (the array from where all widgets in the form can be found) DA (Default Appearance) DR (Default Resources) NeedAppearances boolean, set to true to indicate that when the document is opened, traverse all widgets to generate their display and add them to the Fields array.
71
Examples
Forms Examples
Also includes definition of common objects that are used by the widgets such as fonts, encoding arrays, and Form XObjects for button faces.
[ /_objdef {pdfDocEncoding} /type /dict /OBJ pdfmark [ {pdfDocEncoding} << /Type /Encoding /Differences [ 24 /breve /caron /circumflex /dotaccent /hungarumlaut /ogonek /ring /tilde 39 /quotesingle 96 /grave 128 /bullet /dagger /daggerdbl /ellipsis /emdash /endash /florin /fraction /guilsinglleft /guilsinglright /minus /perthousand /quotedblbase /quotedblleft /quotedblright /quoteleft /quoteright /quotesinglbase /trademark /fi /fl /Lslash /OE /Scaron /Ydieresis /Zcaron /dotlessi /lslash /oe /scaron /zcaron 164 /currency 166 /brokenbar 168 /dieresis /copyright /ordfeminine 172 /logicalnot /.notdef /registered /macron /degree /plusminus /twosuperior /threesuperior /acute /mu 183 /periodcentered /cedilla /onesuperior /ordmasculine 188 /onequarter /onehalf /threequarters 192 /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis ] >> /PUT pdfmark [ /_objdef {ZaDb} /type /dict /OBJ pdfmark [ {ZaDb} << /Type /Font /Subtype /Type1 /Name /ZaDb /BaseFont /ZapfDingbats >> /PUT pdfmark [ /_objdef {Helv} /type /dict /OBJ pdfmark [ {Helv} << /Type /Font /Subtype /Type1 /Name /Helv /BaseFont /Helvetica
72
Examples
Forms Examples
/Encoding {pdfDocEncoding} >> /PUT pdfmark [ /_objdef {aform} /type /dict /OBJ pdfmark % % % % Define Fields array of Acroform dictionary. It will contain entries for each of the widgets defined below. NOTE: it is not necessary to explicitly assign the widget annotations to the Fields array; Acrobat does it automatically when the file is opened.
[ /_objdef {afields} /type /array /OBJ pdfmark [ {aform} << /Fields {afields} /DR << /Font << /ZaDb {ZaDb} /Helv {Helv} >> >> /DA (/Helv 0 Tf 0 g) /NeedAppearances true >> /PUT pdfmark % Put Acroform entry in catalog dictionary [ {Catalog} << /AcroForm {aform} >> /PUT pdfmark
Define the Widget annotations, which are also field dictionaries for this form
This is the collection of all individual widget annotations. It is possible to have multiple instances of these sections, maybe defining a single widget on each instance.
[ /Subtype /Widget /Rect [216 647 361 684] /F 4 /T (SL Text) /FT /Tx /DA (/Helv 14 Tf 0 0 1 rg) /V (5) /AA << /K << /S /JavaScript /JS (AFNumber_Keystroke\(2, 0, 0, 0, "$", true\);)>> /F << /S /JavaScript /JS (AFNumber_Format\(2, 0, 0, 0, "$", true\); >> >> /ANN pdfmark [ /Subtype /Widget /Rect [216 503 361 612] /F 4 /T (Ping Result) /FT /Tx /DA (/Helv 0 Tf 0 0 1 rg) /Ff 4096 /ANN pdfmark
[ /Subtype /Widget
73
Examples
Forms Examples
/Rect [216 432 252 468] /F 4 /T (Check Box) /FT /Btn /DA (/ZaDb 0 Tf 0 g) /AS /Off /MK << /CA (4)>> /AP << /N << /Oui /null >> >> /ANN pdfmark [ /Subtype /Widget /Rect [216 360 252 396] /F 4 /T (Radio) /FT /Btn /DA (/ZaDb 0 Tf 0 g) /Ff 49152 /AS /Off /MK << /CA (8)>> /AP << /N << /V1 /null >> >> /ANN pdfmark [ /Subtype /Widget /Rect [ 261 360 297 396 ] /F 4 /T (Radio) /FT /Btn /DA (/ZaDb 0 Tf 0 g) /Ff 49152 /AS /Off /MK << /CA (8)>> /AP << /N << /V2 /null >> >> /ANN pdfmark [ /Subtype /Widget /Rect [ 306 360 342 396 ] /F 4 /T (Radio) /FT /Btn /DA (/ZaDb 0 Tf 0 g) /Ff 49152 /AS /Off /MK << /CA (8)>> /AP << /N << /V3 /null >> >> /ANN pdfmark [ /Subtype /Widget /Rect [ 351 360 387 396 ] /F 4 /T (Radio) /FT /Btn /DA (/ZaDb 0 Tf 0 g) /Ff 49152 /AS /Off /MK << /CA (8)>>
74
Examples
Forms Examples
/AP << /N << /V4 /null >> >> /ANN pdfmark [ /Subtype /Widget /Rect [216 287 361 324] /F 4 /T (Pop Down) /FT /Ch /Ff 131072 /Opt [ [(1)(First)] [(2)(Second)] [(3)(Third)] [(4)(Fourth)] [(5)(Fifth)]] /DV (5) /V (5) /DA (/TiIt 18 Tf 0 0 1 rg) /ANN pdfmark [ /Subtype /Widget /Rect [216 215 361 252] /F 4 /T (Combo) /FT /Ch /Ff 917504 /Opt [ (Black)(Blue)(Green)(Pink)(Red)(White)] /DA (/TiRo 18 Tf 0 g ) /V (Black) /DV (Black) /ANN pdfmark [ /Subtype /Widget /Rect [216 107 253 180] /F 4 /T (ListBox) /FT /Ch /DA (/Helv 10 Tf 1 0 0 rg) /Opt [(1)(2)(3)(4)(5)] /DV (3) /V (3) /ANN pdfmark % Example of how the /MK dictionary is used. % Notice that the text will be shown upside-down (180 degree rotation). [ /Subtype /Widget /Rect [ 430 110 570 150 ] /F 4 /T (Clear) /FT /Btn /H /P /DA (/HeBo 18 Tf 0 0 1 rg) /Ff 65536 /MK << /BC [ 1 0 0 ] /BG [ 0.75 0.45 0.75 ] /CA (Clear) /AC (Done!) /R 180 >>
75
Examples
Structure Examples
Structure Examples
This section gives examples illustrating various uses of the structure pdfmark suite. Example shows an entire structure tree, consisting of one section containing two paragraphs. It illustrates both how to create the tree structure and how the structure is related to the page content of the PDF file. Example shows the parts of the output PDF file that result from the PostScript language code.
A simple structure
This example has one section with two paragraphs, all on one page.
% On the first page: % % % [ % % % [ % % % [ % % Start a section with the unnamed Structure Tree as parent. Push the Section element onto the implicit parent stack as current implicit parent. /Subtype /Section /StPNE pdfmark Start a paragraph with the Section as impicit parent. Push the Paragraph element on top of the implicit parent stack as the current implicit parent. /Subtype /P /StPNE pdfmark Begin the marked content holding the text of the first paragraph. It is implicitly added to the Paragraph element. /StBMC pdfmark [PostScript code for the contents of the first paragraph goes here.]
% End the marked content holding the text of the first % paragraph. [ /EMC pdfmark % Pop the Paragraph element off the implicit parent stack. % This exposes the Section element as implicit parent again. [ /StPop pdfmark % And now for the second paragraph: [ /Subtype /P /StPNE pdfmark [ /StBMC pdfmark % PostScript code for the contents of the second paragraph goes here.
76
Examples
Structure Examples
[ /EMC pdfmark % % % % We're being tidy by popping both the second Paragraph element and the Section element off the stack. We could have left everything hanging at the end of the document, or used [ /StPopAll pdfmark instead.
77
Examples
Structure Examples
/K [0] >> endobj % Object 6 0, the second Paragraph element 6 0 obj <</Type /StructElement /S /P /P 4 0 R % Page in whose content stream integer Marked Content IDs denote Kids /Pg 10 0 R /K [1] >> endobj % Object 10 0, the Page object for the page on which both % paragraphs are marked. Only the relevant entries in the % dictionary are shown. % The Resources dictionary of the Contents stream of the page. <</StructParents 0 >> % Inside the Contents stream of the page. /P <</MCID 0>> BDC % [Paragraph 1 content marking goes here.] EMC /P <</MCID 1>> BDC % [Paragraph 2 content marking goes here] EMC
Interrupted structure
This example shows a paragraph that is graphically interrupted by a table. The originating application has chosen to write out the PostScript in graphical order, but logically the paragraph is one element and the table is another. To further complicate matters, the document contains a special element that is a list of tables.
% Start a ListOfTables element directly under the Structure % Tree Root. Give it an object name for later reference. [ /_objdef {LOT} /Subtype /ListOfTables /StPNE pdfmark % Pop it off the stack so that the next element becomes a % child of the Structure Tree Root. [ /StPop pdfmark % Start the page with the section on it.
78
Examples
Structure Examples
% Start the section, also making it the default parent element. [ /Subtype /Section /StPNE pdfmark % Start the paragraph. [ /Subtype /P /StPNE pdfmark % Here comes the portion of the paragraph before the table [ /StBMC pdfmark % [code to write the first portion of the paragraph goes here] [ /EMC pdfmark % % % % [ Now were interrupted by a table that doesnt belong to the paragraph. Save the context as a conservative move because we dont want to worry about what the table code does to the implicit parent stack. /StoreName /S1 /StStore pdfmark
% The table is an element, and it contains cells as child elements. [ /E {LOT} /StPush pdfmark [ /Subtype /Table /StPNE pdfmark % ... code to draw the table and establish its logical substructure here ... % Pop the table and the List of Tables off the implicit parent stack. [ /StPop pdfmark [ /StPop pdfmark % % % [ Resume the paragraph. It turns out that the table code was tidy, but its probably a good thing that we didnt count on it. Get the implicit parent stack back into a known state. /StoreName /S1 /StRetrieve pdfmark
[ /StBMC pdfmark % ... code to write the second portion of the paragraph ... [ /EMC pdfmark % % [ [ [ Pop the Paragraph and Section elements and the Structure Tree Root off the stack. /StPop pdfmark /StPop pdfmark /StPop pdfmark
79
Examples
Structure Examples
content forming the contents of a paragraph, but the words become the content of elements in a separate branch of the structure tree from the Paragraph elements.
% Set up a List element to hold the Funny Word List. [ /_objdef {FWL}/Subtype /List /Title (Funny Words) /StPNE pdfmark [ /StPop pdfmark [/Subtype /Section /StPNE pdfmark [ /Subtype /P /StPNE pdfmark % Begin PostScript code for the paragraph [ /StBMC pdfmark (John was thrilled to find some ) show % Heres an occurrence of a funny word coming up. % Start an element for the funny word list... [ /E {FWL} /StPush pdfmark [ /Subtype /Word /StPNE pdfmark % Fill that element with the funny word from the % page content. This content is still in the % marked content within the paragraph element. [ /StBMC pdfmark (puccoon) show [ /EMC pdfmark % Pop the Word element off the implicit parent stack. [ /StPop pdfmark % Resume paragraph content thats not in the funny word % (, not knowing that it could also be called ) % ... another funny word ... [ /E {FWL} /StPush pdfmark [ /Subtype /Word /StPNE pdfmark [ /StBMC pdfmark (gromwell) show [ /EMC pdfmark [ /StPop pdfmark (.) show % Close off the marked content for the paragraph... [ /EMC pdfmark % ...and tidy up the stack [ /StPop pdfmark [ /StPop pdfmark [ /StPop pdfmark
80
Examples
Structure Examples
% ... write the portion of the paragraph thats on Page 1 ... [ /EMC pdfmark showpage %%Page: 2 2 % % [ % [ The Paragraph element is still on the top of the stack, so we can just add some more content to it implicitly. /StBMC pdfmark ... write the portion of the paragraph thats on Page 2 ... /EMC pdfmark
[ /StBMC pdfmark % ... draw the paragraph... [ /EMC pdfmark % ... the rest of the page ... showpage % Pop the Paragraph element off the stack [ /StPop pdfmark %%Page 6 6 [ /Subtype /P /At 0 /StPNE pdfmark % Insert as first child of parent. [ /StBMC pdfmark % ... draw the paragraph... [ /EMC pdfmark % Pop the Paragraph and Section elements off the stack [ /StPop pdfmark [ /StPop pdfmark
81
Examples
Tagged PDF
Tagged PDF
This is a sample PostScript file that illustrates the use of tagged PDF. It is included on the Acrobat SDK as the file Sample1.ps.
%!PS-Adobe-3.0 %%Title: Sample1 % % % % % There are three things that should be added to this example: 1. A small table (just 2 row, three column) 2. A figure (either standalone, or actually embedded in the text) 3. If possible, the encoding of a font so that the soft hyphen really works without the "actual text"
[ /Creator (Hand Created) /CreationDate (D:20010508130548) /ModDate (D:20010508145339) /Author (Adobe Developer) /Title (Sample Document 1 for tagged PDF creation) /Subject (A base document for the creation of some simple PostScript and PDFMarks to show tagged PDF) /Session (Tagged PDF Dev Tech Seminar) /Purpose (Demonstration) /DOCINFO pdfmark [ {Catalog} <</MarkInfo <</Marked true>>>> /PUT pdfmark %% Layout class for documenttitle below [ /_objdef {C1} /type /dict /OBJ pdfmark [ {C1} <</O /Layout /SpaceAfter 10 /SpaceBefore 10 /TextAlign /Center>> /PUT pdfmark [ /CM1 {C1} /StClassMap pdfmark %% Layout class for topichead [ /_objdef {C2} /type /dict /OBJ pdfmark [ {C2} <</O /Layout /SpaceAfter 5 /SpaceBefore 5 /TextAlign /Left>> /PUT pdfmark [ /CM2 {C2} /StClassMap pdfmark %% Layout class for topichead2 [ /_objdef {C3} /type /dict /OBJ pdfmark [ {C3} <</O /Layout /SpaceAfter 3 /SpaceBefore 3 /TextAlign /Left>> /PUT pdfmark [ /CM3 {C3} /StClassMap pdfmark %% Layout class for p [ /_objdef {C4} /type /dict /OBJ pdfmark [ {C4} <</O /Layout /SpaceAfter 1 /SpaceBefore 3 /TextAlign /Left>> /PUT pdfmark [ /CM4 {C4} /StClassMap pdfmark [ /Subtype /document /Lang (en-US) /StPNE pdfmark [ /_objdef {dta1} /type /dict /OBJ pdfmark
82
Examples
Tagged PDF
[ {dta1} <</O /XML-1.00 /Author (Joe)>> /PUT pdfmark [ /Subtype /documenttitle /Class /CM1 /StPNE pdfmark [ /Obj {dta1} /StAttr pdfmark [ /StBMC pdfmark /Helvetica-Bold findfont 24 scalefont setfont 216 720 moveto (Title of Document) show [ /EMC pdfmark [ /StPop pdfmark [ /Subtype /topic /StPNE pdfmark [ /Subtype /topichead /Class /CM2 /StPNE pdfmark [ /StBMC pdfmark /Helvetica-Bold findfont 18 scalefont setfont 72 690 moveto (First Topic) show [ /EMC pdfmark [ /StPop pdfmark [ /Subtype /p /Class /CM4 /StPNE pdfmark [ /StBMC pdfmark /Helvetica findfont 12 scalefont setfont 72 674 moveto (Some text in a paragraph in the first topic. These lines may not be justified, but are illustrative.) show [ /EMC pdfmark [ /StPop pdfmark [ /StPop pdfmark [ /Subtype /topic /StPNE pdfmark [ /Subtype /topichead /Class /CM2 /StPNE pdfmark [ /StBMC pdfmark /Helvetica-Bold findfont 18 scalefont setfont 72 648 moveto (Second Topic) show [ [ [ [ /EMC pdfmark /StPop pdfmark /Subtype /p /Class /CM4 /StPNE pdfmark /StBMC pdfmark
/Helvetica findfont 12 scalefont setfont 72 632 moveto (This is a paragraph of text in the second topic. ) show [ /EMC pdfmark [ /Subtype /emph /StPNE pdfmark
83
Examples
Tagged PDF
[ /StBMC pdfmark /Helvetica-Oblique findfont 12 scalefont setfont (Emphasized ) show [ /EMC pdfmark [ /StPop pdfmark [ /StBMC pdfmark /Helvetica findfont 12 scalefont setfont (words ) show 72 618 moveto (here.) show [ /EMC pdfmark [ /StPop pdfmark [ /Subtype /topic /StPNE pdfmark [ /Subtype /topichead2 /Class /CM3 /StPNE pdfmark [ /StBMC pdfmark /Helvetica-Bold findfont 14 scalefont setfont 72 596 moveto (Subtopic of second topic) show [ /EMC pdfmark [ /StPop pdfmark [ /Subtype /p /Class /CM4 /StPNE pdfmark [ /StBMC pdfmark /Helvetica findfont 12 scalefont setfont 72 580 moveto (This paragraph of text is the second topic, first subtopic. ) show 72 566 moveto (Hyphenated words make up this para) show [ /EMC pdfmark [ /Subtype /Span /ActualText <FEFF00AD> /StPNE pdfmark [ /StBMC pdfmark (-) show [ /EMC pdfmark [ /StPop pdfmark [ /StBMC pdfmark 72 552 moveto (graph also.) show [ [ [ [ /EMC pdfmark /StPop pdfmark /StPop pdfmark /StPop pdfmark
84
Examples
Tagged PDF
% And now we put in another topic with line numbers [ /Subtype /topic /StPNE pdfmark [ /Subtype /topichead /Class /CM2 /StPNE pdfmark [ /StBMC pdfmark /Helvetica-Bold findfont 18 scalefont setfont 72 510 moveto (Line Numbered Topic) show [ /EMC pdfmark [ /StPop pdfmark [ /Subtype /p /Class /CM4 /StPNE pdfmark /Helvetica findfont 12 scalefont setfont [/Artifact <</Type /Layout>> /BDC pdfmark 48 494 moveto (1) show [ /EMC pdfmark [ /StBMC pdfmark 72 494 moveto (This is some text such as would appear in a legal bill. ) show [ /EMC pdfmark [ /Artifact <</Type /Layout>> /BDC pdfmark 48 478 moveto (2) show [ /EMC pdfmark [ /StBMC pdfmark 72 478 moveto (Note that this text has line numbers, but that ) show [ /EMC pdfmark [ /Artifact <</Type /Layout>> /BDC pdfmark 48 464 moveto (3) show [ /EMC pdfmark [/StBMC pdfmark 72 464 moveto (the numbers disappear when you reflow ) show [ /EMC pdfmark [ /Artifact <</Type /Layout>> /BDC pdfmark 48 450 moveto (4) show [ /EMC pdfmark
85
Examples
Tagged PDF
[ /StBMC pdfmark 72 450 moveto (the text our save the text as XML.) show [ /EMC pdfmark [ /StPop pdfmark [ /StPop pdfmark [ /StPop pdfmark % % % [ [ [ [ [ Now that the text is done, let's make the outlines The first bookmark magnifies 400 percent, while the others go to their line in the text /Count 4 /Page 1 /View [/XYZ 216 744 4.0] /Title (Title of Document) /OUT pdfmark /Page 1 /View [/XYZ 0 704 1.0] /Title (First Topic) /OUT pdfmark /Count -1 /Page 1 /View [/XYZ 0 662 1.0] /Title (Second Topic) /OUT pdfmark /Page 1 /View [/XYZ 0 610 1.0] /Title (Subtopic of second Topic) /OUT pdfmark /Page 1 /View [/XYZ 0 530 1.0] /Title (Line Numbered Topic) /OUT pdfmark
[ /PageMode /UseOutlines /Page 1 /View [/XYZ null null null] /DOCVIEW pdfmark % And finally the rolemap, with every tag that I have used defined. [ /document /Document /documenttitle /H /p /P /emph /Span /topic /Div /topic2 /Div /topichead /H1 /topichead2 /H2 /StRoleMap pdfmark showpage (%%[Page: 1]%%) =
86
A
The use of pdfmark in PostScript has been expanded to include representations of JDF features. JDF is an extensible XML-based job ticketing format designed for use bythe printing industry. Information about JDF can be obtained from http://www.cip4.org. In particular, pdfmark for JDF (henceforth called JDF pdfmark) allows the PostScript file/stream to specify elements and attributes to be added to a JDF document being used for a job. Applications that support JDF pdfmark include Acrobat Distiller 6.0. See the document Acrobat Distiller Parameters (technical note 5151) for further information about Distiller. Syntax The syntax for the JDF pdfmark operator is as follows: [ /Attribute string /Value string /Subtype /CreateAttribute /JDF pdfmark Where the Attribute and Value keys are as described in Table A.1. Also, Table A.2 presents examples of XPath expressions.
TABLE A.1 Keys supported by JDF pdfmark
Key Attribute
Type string
Semantics An XPath expression that identifies the location of the attribute absolutely from the root of the JDF. If any portion of the hierarchy of elements containing the attribute is not present in the JDF, they are created. XPath is a language for addressing parts of an XML document, as defined in XML Path Language (XPath) Version1.0, which is available from http://www.w3.org/TR/xpath.
JDF pdfmark supports the following subset of XPath expressions:
Expression ::= JDFRoot/Attribute | JDFRoot/Children/Attribute JDFRoot ::=//JDF Children ::= Element | Element/Children Element ::= element | element[FilterExpression] FilterExpression ::= Filter | FilterandFilterExpression | FilterorFilterExpression Filter ::= Attribute=Value Attribute ::=@attribute Value string The value to be assigned to the attribute, using the XPath expression: Value ::= value
87
TABLE A.2
Interpretation Selects the JobID attribute in root JDF node Selects the rRef attribute of the ComponentLink found in the ResourcePool in the root JDF node Selects the Status attribute of the Trapping node that is a child of the root JDF node First identifies the ResourceLinkPool of the root JDF node. It then selects the rRef attribute of the ComponentLink with both a Usage attribute value Output and a ProcessUsage attribute with value Good
NOTE:
In actual use, all XPath expressions should end with @attribute because they must define the location of an attribute.
The JDF pdfmark commands shown in Example A.1 cause supporting applications to modify the current JDF document as illustrated in Example A.2.
EXAMPLE A.1 Using JDF pdfmark to set Trapping element and subelement attributes
[ /Attribute (//JDF/JDF[@Type="Trapping"]/@Type) /Value (Trapping) /Subtype /CreateAttribute /JDF pdfmark [ /Attribute (//JDF/JDF[@Type="Trapping"]/ResourceLinkPool/TrappingDetailsLink/@rRef) /Value (TD1) /Subtype /CreateAttribute /JDF pdfmark [ /Attribute (//JDF/JDF[@Type="Trapping"]/ResourceLinkPool/TrappingDetailsLink[@rRef="TD1"]/@Usage) /Value (Input) /Subtype /CreateAttribute /JDF pdfmark
88
EXAMPLE A.2
ResourceLinkPool
89