How to check for layers, comments and forms in PDF files using Acrobat 7

Learn how to check for layers, comments/markup, or form fields in a collection of PDF files.

By January 23, 2006

 

For a quick way to check if there are any layers, or comments/markup, or form fields within a collection of PDF files, you can do a visual inspection of your file from within Acrobat.

To check for Layers (which are named Optional Content Groups in the PDF format) – open the Layers tab or look for a “layered cake” in the Document Status bar (see Figure 1).

Figure 1: Example of file with layers (or OCGs) – the “layer cake” is present in the document status bar and layers are visible in the Layers tab.

Comments, form fields, multimedia objects, and links are all considered annotation types and are placed on top of the PDF – in the “annotation layer”, which is different than OCG layers described above. A quick way to determine if there are any annotations on a page is to select the “Select Object” tool. If there is any content on the annotation layer it will be highlighted. (See Figure 2)

Figure 2: Choose the Select Object Tool (in the advanced editing toolbar) and select “Edit > Select All” to see any content on the annotation layer in a PDF document.

Instead of opening each PDF by hand, you can create a small JavaScript to check for OCGs or Annotations and create a report which includes the name of the file and whether any content was found. This could be run as a batch process using the following JavaScript:

var rep = new Report();
rep.size = 1.2;
rep.color = color.blue;
rep.writeText ("Testing for Content");
rep.writeText("FileName : " + this.documentFileName);
for (var i = 0; i < this.numPages; i++ ){
	// loop thru all pages
	var a= this.getAnnots();
	var c = this.getOCGs();
	var b = this.getPageBox("Crop", i);
	var l = this.getLinks(i, b);
	rep.indent(20);
	rep.writeText("Number of Links on page " + (i+1) +" is " + l.length);
	if (a != null ){
		rep.writeText("There are annotations on page " + (i+1));
		if (c != null ){
			rep.writeText("There are layers in this document.")
		}
	}
}
var docRep = rep.open("myreport.pdf");


Related topics:

Review and Comment, PDF Forms, JavaScript

Top Searches:


0 comments

Comments for this tutorial are now closed.

Comments for this tutorial are now closed.