![]() ![]() If you use the watermark function a second time, a new watermark is added to the document, but a new OCG is not created. ![]() The watermark functions always give the newly created OCG the name Watermark. The result of this operation (Figure 2) shows the document contains only a single OCG named Watermark, which is from the previous doc.addWatermarkFromText() operation. The doc.getOCGs() function returns an array of OCG Objects. The layer we just created with the watermark function is hidden from the user, but it isn’t hidden from JavaScript. The first thing to notice is that the panel is empty. Now activate the Layers Panel in Acrobat (Menu item: View>Navigation Tabs>Layers). Adding a Watermark, Background, Header, or Footer to the document from the Acrobat menus will also create an OCG. These functions also create an OCG layer to which the watermark is attached. There is also a related function, doc.addWatermarkFromFile(), that uses a PDF file to create the watermark. This function has a large number of options for placing the text, controlling color, font, text size, and other parameters. This single line script will add the words “Draft Copy” to the center of all the document pages. Enter and run the following line of code in the JavaScript Console. If you’re unfamiliar with the JavaScript Console, read this tutorial. We’ll use this document as a scratch pad for trying out the OCG operations so make sure it’s a document you don’t mind altering, and has only a few pages. For the following example you’ll need Acrobat Professional 7.0. The two most important features added were the ability to create an OCG layer with the W atermark functions, and the ability to rename an OCG. It was in Acrobat 7 that OCGs became really useful from JavaScript. At the same time some basic JavaScript control over the OCGs was also added i.e., the ability to list the existing OCGs and change OCG state. OCGs were first added to the PDF specification in Acrobat 6. However, layers created in other ways can be manipulated with the same techniques discussed here. They are the Watermark and Backgrounds and Headers and Footers menu items. It’s these Acrobat operations we’ll be using in this article since they give us a way to create OCGs without relying on external tools. ![]() OCGs are only available through third party tools, file conversions, and a couple operations built into Acrobat Professional. Unfortunately, there isn’t yet a tool in Acrobat that can arbitrarily attach OCGs to drawn objects on the page. Adobe InDesign ®, Microsoft PowerPoint ®, and Autodesk AutoCAD ® files can all be converted to a layered PDF when appropriately set up. However, OCG layers are added when some file formats are converted to PDF. This is very different from the concept of layers in other programs like Adobe Photoshop ®. If the state of the OCG is true the object is drawn, and if the state is false the object is not drawn, so the Show/Hide buttons in the Layers panel really control the state of the OCG. Any drawn object can be attached to an OCG. They are a logical construction inside the PDF file that has either a true or false state. OCGs are not visible objects on the document or even real layers. It’s easy to get the impression that the drawn page content and the OCG layer are the same thing, or that the page contents associated with the OCG are on some kind of physical layer, but this is not true. The first one ( MyLayer) is hidden and the other two are visible as indicated by their Show/Hide buttons.įigure 1 OCG Layers Panel and Menu Options Clicking the mouse on one of the Show/Hide buttons toggles the visibility of the page content associated with that layer. Each entry in this panel represents an OCG in the document. Figure 1 shows the Layers Panel (Menu: View>Navigation Tabs>Layers). To the user, an OCG appears as a physical layer of content on a PDF page. OCGs are used to create multilayer pages (like a stack of transparencies), for everything from multi-language documents, layered views for architectural plans, to animated displays. This is not another kind of form field or annotation, but true page content. In Acrobat 7 (Professional and Standard) it is possible to both create and control these content layers through Acrobat JavaScript, giving the document developer a totally new ability to use dynamic content purely through scripting tools already available in Acrobat Professional. OCGs are a mechanism for selectively controlling the visibility of page content. ![]() In Acrobat, the term “Layers” refers to Optional Content Groups (OCGs). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |