These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

COS document table full error when using addWatermarkfromFile in batch

Registered: Nov 21 2007
Posts: 10

I am trying to add images using the addWatermarkfromFile. These images
are variable and depend on certain text that has been placed in the PDF.
The PDF is about 2000 pages with 4 different images placed on every other page. When I run in batch, I get a COS document table error around the 264th page. Any ideas on how to fix this. Here is my code just in case you want to look:

/* Put script title here */
var ckWord, numWords, pgNum, vertPos, horzPos, pagePos;
for (var p = 0; p < this.numPages; p++)
vertPos = 0;
horzPos = 0;
pagePos = 0;

//while (ckWord != "IMAGE")
var numWords = this.getPageNumWords(p);
for (var i=0; i

My Product Information:
Acrobat Pro 7.0, Windows
Registered: Feb 15 2006
Posts: 4411
You've stretched Acrobat beyond it's limit. Is there a reason you need to use a batch sequence? Are you running this code on several very large documents?

The reason you are having this problem is because you are placing unique watermarks on all the pages, this eats up huge amounts of memory and bloats your PDF. Since you are using the same image on many, many pages. It's worthwhile to run through all the pages and collect information on what images are needed on what pages, then use the page range options in the watermark function. All images place in the "range" are the same image. This will reduce file bloat and hopefully reduce the overflow error.

A better solution is to use Page Templates. The template.spawn() function returns a CosObj object that can be reused many times to overlay an image on a PDF Page. This way all the same images are really the same image internally in the PDF, even if they are placed on non-sequential pages.

To use this strategy you will first have to place one image on a blank page of the correct size. There is a "doc.newPage()" function that will help. Then turn that page into a "Template". Then save the result from the first spawn to use with later image overlays. When the document is finished, delete the template page.

Thom Parker
The source for PDF Scripting Info
Very Important - How to Debug Your Script

Registered: Jul 3 2009
Posts: 76
i used to operate 800 pages file, and have the same problem. however when i use acrobat pro 9.0 instead of 7.0, this error disappeared.