|By Amyuni Tech||
|June 1, 2009 12:00 PM EDT||
PDF Layers are called Optional Content within the PDF specifications. This is a feature that was added as of PDF-1.5 (Acrobat 6.) A layer is identified by an identifier and a title. Only the layer title is visible to the end-user of the PDF document. Layers can be structured as a tree or as a hierarchy of layers. Here is a sample Optional Content object in a PDF:
9 0 obj <</Type/OCG/Name(Blue Layer) >> endobj
Each page using this layer should add the layer to its list of resources, for example:
6 0 obj <</Type /Page /Parent 3 0 R /MediaBox [0 0 612 792 ] /Contents [7 0 R ]
/Resources << /ProcSet [/PDF /Text] /Font <</F10 10 0 R >>
/Properties <</OC9 9 0 R >>
>> >> endobj
OC9 is the layer ID (Blue Layer) and is the layer title (strings in PDF are surrounded by parenthesis). To indicate that various objects within the page content belong to specific layers, the following syntax is used:
% start the Blue Layer that contains the text: Page 1
/OC /OC9 BDC
BT /F10 5.76 Tf 1 0 0 1 24 745.56 Tm 0.026 Tc -0.067 Tw (Page 1) Tj ET
% start a sub-layer that will contain a filled rectangle
/OC /OC11 BDC
n 1 g 96 326.96 35.76 -6.6 re f*
% end of sub-layer 1
% start another sub-layer that will contain another filled rectangle
/OC /OC13 BDC
n 1 g 96 526.96 35.76 -6.6 re f*
% end of sub-layer 2
%end of blue layer
Although the code shows one parent layer and two nested layers (contained within the parent layer), this is not enough to define the hierarchy of layers. The Order string is used to determine the hierarchy of layers. The Order string is part of the document Catalog. The Order string for the above PDF sample should look like this:
/Order [ 9 0 R [11 0 R 13 0 R] ]
The object IDs are needed to create a proper order string. The order string can also contain a parent node that is not a layer but only a container for other layers. In the example above we could have all the layers below to one parent layer called (Layered PDF) by using:
/Order [ (Layered PDF) 9 0 R [11 0 R 13 0 R] ]
It is important that the Order string matches the order of layers as they appear in the page content, otherwise the PDF viewer will not be able to properly “show and hide” layers with their sub-layers.
Note: There is an inconsistency in the PDF specifications related to defining nodes that are parents of other layers. To have a Layered PDF as the parent of layer 9, we do not use [(Layered PDF) [9 0 R] ] as one might expect but [(Layered PDF) 9 0 R] as if the 2 nodes were on the same level.
Creating Groups of Layers
The PDF format allows creating groups of mutually exclusive layers where showing one layer will automatically hide the other. These are called radio-button groups and defined using the RBGroups PDF keyword. One can also define which layers are visible by default and which are hidden, for example:
/RBGroups [[ 11 0 R 13 0 R]] /ON[ 11 0 R] /OFF [13 0 R] indicates that layers 11 and 13 are grouped and that layer 11 is visible by default whereas 13 is invisible.
Dynamically Creating Layers using the Amyuni PDF Converter
External developers need to be aware of layer titles only. The layers IDs and object numbers are not significant to the developer, so the implemented API will only use layer titles to insert layers and define the layer hierarchy.
Layers can be inserted within a PDF file while the document is being printed by calling Escape sequences. Escape sequences are GDI artifacts that enable developers to send custom data to a printer driver.
Checking that the Printer supports PDF Layers
The first step to start adding layers is to check that the printer has support for the escape sequences that are defined by Amyuni. The following calls are needed include:
// check if PDF printer supports layers
#define ESCAPE_SETLAYER 248
int escape = ESCAPE_SETLAYER;
ExtEscape( hDC, GETTECHNOLOGY, 0, NULL, sizeof(technology), (LPSTR)technology
// the technology should be PDF
if ( lstrcmp(technology, "PDF") )
MessageBox( 0, "Not an Amyuni PDF driver", "Error", MB_ICONERROR );
// and support the SETLAYER escape
if ( !ExtEscape( hDC, QUERYESCSUPPORT, sizeof(escape), (LPCSTR)&escape, 0,
NULL ) )
MessageBox( 0, "Not an Amyuni PDF driver", "Error", MB_ICONERROR );
GETTECHNOLOGY and QUERYESCSUPPORT are escape sequences that are predefined by Windows GDI. ESCAPE_SETLAYER is a custom escape that is processed by the Amyuni printer.
The SETLAYER escape takes one parameter which is a Unicode string, The escape can be wrapped into a helper function such as:
void SetLayer( HDC hDC, LPWSTR LayerInfo )
switch ( ExtEscape( hDC, ESCAPE_SETLAYER, (int)((wcslen(LayerInfo) + 1)
* sizeof(LayerInfo)), (LPCSTR)LayerInfo, 0, NULL ) )
// positive return indicates success
// no error
// error occured, closing a layer when none was open
// memory allocation error (low memory or invalid string)
The same escape call is used to start a layer or sub-layer, end a layer or define the hierarchy of layers.
Setting the Hierarchy of Layers
The order or hierarchy of layers is sent to the PDF printer using the SETLAYER escape before the call to StartDoc. It can actually be called anytime during the printing as long as the call is made outside of a StartPage/EndPage block but before the EndDoc is called. The advantage of setting the hierarchy before StartDoc is that it allows the PDF printer to expect layer support and switch the file header to PDF-1.5.
If the hierarchy of layers is not known before the call the StartDoc, the developer can call SetLayer( L"" ) with an empty string before the call to StartDoc simply to instruct the PDF printer to output PDF-1.5 header. The order string should contain the titles of all the layers and their hierarchy, all in Unicode format. E.g.:
// set the order and hierrachy of layers
SetLayer( hDC, L"/Order[(Blue Layer)[(Blue Layer - 1)(Blue Layer - 2)](Red
Layer)(Green Layer)]" );
This will produce a layer structure like this:
To group layers within radio-button groups, the /RBGroups, /ON and /OFF entries should be added to the call above. This code for e.g. will make the red and green layers as part of a group:
// set the order and radio/button groups of layers
SetLayer( hDC, L"/Order[(Blue Layer)[(Blue Layer - 1)(Blue Layer - 2)](Red
Layer)(Green Layer)]" \
L"/RBGroups[[(Red Layer)(Green Layer)]]/OFF[(Red Layer)]/ON[(Green Layer)]"
Drawing Objects within Layers
Within a StartPage/EndPage sequence of calls, calling SetLayer with a valid layer title will start a new layer and place all subsequent drawing instructions within that layer. Calling SetLayer with an empty string will end the last layer. If multiple layers are nested, multiple calls to SetLayer with an empty string are needed to close all layers.
If all layers are not closed at the call to EndPage, the PDF printer will automatically close all open layers, for example:
// start parent layer
SetLayer( hDC, L"Blue Layer" );
SetTextColor( hDC, RGB(0, 0, 255) );
TextOut( hDC, 200, yPos, buf, lstrlen(buf) );
yPos += 200;
// start blue sub-layer 1
SetLayer( hDC, L"Blue Layer - 1" );
SetTextColor( hDC, RGB(0, 0, 128) );
TextOut( hDC, 800, yPos, "Blue Layer - 1", lstrlen("Blue Layer - 1") );
yPos += 200;
SetLayer( hDC, L"" ); // close blue sub-layer 1
SetLayer( hDC, L"" ); // close blue parent layer
The sequence of opening and closing layers should be consistent with the order string for the PDF viewer to show or hide layers with their sub-layers in a consistent way.
The contents for this post were provided by Dany Amiouny using the Amyuni PDF Converter developer tool.
As more intelligent IoT applications shift into gear, they’re merging into the ever-increasing traffic flow of the Internet. It won’t be long before we experience bottlenecks, as IoT traffic peaks during rush hours. Organizations that are unprepared will find themselves by the side of the road unable to cross back into the fast lane. As billions of new devices begin to communicate and exchange data – will your infrastructure be scalable enough to handle this new interconnected world?
Oct. 13, 2015 02:00 PM EDT Reads: 104
This week, the team assembled in NYC for @Cloud Expo 2015 and @ThingsExpo 2015. For the past four years, this has been a must-attend event for MetraTech. We were happy to once again join industry visionaries, colleagues, customers and even competitors to share and explore the ways in which the Internet of Things (IoT) will impact our industry. Over the course of the show, we discussed the types of challenges we will collectively need to solve to capitalize on the opportunity IoT presents.
Oct. 13, 2015 02:00 PM EDT
SYS-CON Events announced today that Super Micro Computer, Inc., a global leader in high-performance, high-efficiency server, storage technology and green computing, will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Supermicro (NASDAQ: SMCI), the leading innovator in high-performance, high-efficiency server technology is a premier provider of advanced server Building Block Solutions® for Data Center, Cloud Computing, Enterprise IT, Hadoop/Big Data, HPC and Embedded Systems worldwide. Supermi...
Oct. 13, 2015 01:45 PM EDT Reads: 220
The IoT market is on track to hit $7.1 trillion in 2020. The reality is that only a handful of companies are ready for this massive demand. There are a lot of barriers, paint points, traps, and hidden roadblocks. How can we deal with these issues and challenges? The paradigm has changed. Old-style ad-hoc trial-and-error ways will certainly lead you to the dead end. What is mandatory is an overarching and adaptive approach to effectively handle the rapid changes and exponential growth.
Oct. 13, 2015 01:00 PM EDT Reads: 338
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo in Silicon Valley. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 17th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal an...
Oct. 13, 2015 01:00 PM EDT Reads: 211
The Internet of Things (IoT) is growing rapidly by extending current technologies, products and networks. By 2020, Cisco estimates there will be 50 billion connected devices. Gartner has forecast revenues of over $300 billion, just to IoT suppliers. Now is the time to figure out how you’ll make money – not just create innovative products. With hundreds of new products and companies jumping into the IoT fray every month, there’s no shortage of innovation. Despite this, McKinsey/VisionMobile data shows "less than 10 percent of IoT developers are making enough to support a reasonably sized team....
Oct. 13, 2015 01:00 PM EDT Reads: 342
There will be 20 billion IoT devices connected to the Internet soon. What if we could control these devices with our voice, mind, or gestures? What if we could teach these devices how to talk to each other? What if these devices could learn how to interact with us (and each other) to make our lives better? What if Jarvis was real? How can I gain these super powers? In his session at 17th Cloud Expo, Chris Matthieu, co-founder and CTO of Octoblu, will show you!
Oct. 13, 2015 12:00 PM EDT Reads: 299
Developing software for the Internet of Things (IoT) comes with its own set of challenges. Security, privacy, and unified standards are a few key issues. In addition, each IoT product is comprised of at least three separate application components: the software embedded in the device, the backend big-data service, and the mobile application for the end user's controls. Each component is developed by a different team, using different technologies and practices, and deployed to a different stack/target - this makes the integration of these separate pipelines and the coordination of software upd...
Oct. 13, 2015 12:00 PM EDT Reads: 411
As a company adopts a DevOps approach to software development, what are key things that both the Dev and Ops side of the business must keep in mind to ensure effective continuous delivery? In his session at DevOps Summit, Mark Hydar, Head of DevOps, Ericsson TV Platforms, will share best practices and provide helpful tips for Ops teams to adopt an open line of communication with the development side of the house to ensure success between the two sides.
Oct. 13, 2015 12:00 PM EDT Reads: 693
The IoT is upon us, but today’s databases, built on 30-year-old math, require multiple platforms to create a single solution. Data demands of the IoT require Big Data systems that can handle ingest, transactions and analytics concurrently adapting to varied situations as they occur, with speed at scale. In his session at @ThingsExpo, Chad Jones, chief strategy officer at Deep Information Sciences, will look differently at IoT data so enterprises can fully leverage their IoT potential. He’ll share tips on how to speed up business initiatives, harness Big Data and remain one step ahead by apply...
Oct. 13, 2015 12:00 PM EDT Reads: 746
Today air travel is a minefield of delays, hassles and customer disappointment. Airlines struggle to revitalize the experience. GE and M2Mi will demonstrate practical examples of how IoT solutions are helping airlines bring back personalization, reduce trip time and improve reliability. In their session at @ThingsExpo, Shyam Varan Nath, Principal Architect with GE, and Dr. Sarah Cooper, M2Mi's VP Business Development and Engineering, will explore the IoT cloud-based platform technologies driving this change including privacy controls, data transparency and integration of real time context w...
Oct. 13, 2015 11:00 AM EDT Reads: 305
The Internet of Everything is re-shaping technology trends–moving away from “request/response” architecture to an “always-on” Streaming Web where data is in constant motion and secure, reliable communication is an absolute necessity. As more and more THINGS go online, the challenges that developers will need to address will only increase exponentially. In his session at @ThingsExpo, Todd Greene, Founder & CEO of PubNub, will explore the current state of IoT connectivity and review key trends and technology requirements that will drive the Internet of Things from hype to reality.
Oct. 13, 2015 11:00 AM EDT Reads: 318
SYS-CON Events announced today that Sandy Carter, IBM General Manager Cloud Ecosystem and Developers, and a Social Business Evangelist, will keynote at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA.
Oct. 13, 2015 10:00 AM EDT Reads: 250
"Matrix is an ambitious open standard and implementation that's set up to break down the fragmentation problems that exist in IP messaging and VoIP communication," explained John Woolf, Technical Evangelist at Matrix, in this SYS-CON.tv interview at @ThingsExpo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
Oct. 13, 2015 07:00 AM EDT Reads: 6,011
Nowadays, a large number of sensors and devices are connected to the network. Leading-edge IoT technologies integrate various types of sensor data to create a new value for several business decision scenarios. The transparent cloud is a model of a new IoT emergence service platform. Many service providers store and access various types of sensor data in order to create and find out new business values by integrating such data.
Oct. 13, 2015 04:00 AM EDT Reads: 683
Too often with compelling new technologies market participants become overly enamored with that attractiveness of the technology and neglect underlying business drivers. This tendency, what some call the “newest shiny object syndrome,” is understandable given that virtually all of us are heavily engaged in technology. But it is also mistaken. Without concrete business cases driving its deployment, IoT, like many other technologies before it, will fade into obscurity.
Oct. 13, 2015 03:00 AM EDT Reads: 260
There are so many tools and techniques for data analytics that even for a data scientist the choices, possible systems, and even the types of data can be daunting. In his session at @ThingsExpo, Chris Harrold, Global CTO for Big Data Solutions for EMC Corporation, will show how to perform a simple, but meaningful analysis of social sentiment data using freely available tools that take only minutes to download and install. Participants will get the download information, scripts, and complete end-to-end walkthrough of the analysis from start to finish. Participants will also be given the pract...
Oct. 13, 2015 03:00 AM EDT Reads: 408
WebRTC services have already permeated corporate communications in the form of videoconferencing solutions. However, WebRTC has the potential of going beyond and catalyzing a new class of services providing more than calls with capabilities such as mass-scale real-time media broadcasting, enriched and augmented video, person-to-machine and machine-to-machine communications. In his session at @ThingsExpo, Luis Lopez, CEO of Kurento, will introduce the technologies required for implementing these ideas and some early experiments performed in the Kurento open source software community in areas ...
Oct. 13, 2015 12:45 AM EDT Reads: 853
Electric power utilities face relentless pressure on their financial performance, and reducing distribution grid losses is one of the last untapped opportunities to meet their business goals. Combining IoT-enabled sensors and cloud-based data analytics, utilities now are able to find, quantify and reduce losses faster – and with a smaller IT footprint. Solutions exist using Internet-enabled sensors deployed temporarily at strategic locations within the distribution grid to measure actual line loads.
Oct. 13, 2015 12:00 AM EDT Reads: 274
“In the past year we've seen a lot of stabilization of WebRTC. You can now use it in production with a far greater degree of certainty. A lot of the real developments in the past year have been in things like the data channel, which will enable a whole new type of application," explained Peter Dunkley, Technical Director at Acision, in this SYS-CON.tv interview at @ThingsExpo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
Oct. 12, 2015 11:15 PM EDT Reads: 7,129