APFill Coverage Calculator: automatic mode with parallel processing of PDF files

APFill Ink Coverage Calculator is intended for calculating toner/ink coverage in PDF or PS files. APFill separately measures CMYK, as well as up to 8 spot colors in a PDF file.

In addition to the usual mode of operation, where user independently selects a file and calculates its filling with the program, APFill has an automatic mode of operation and can be launched from the command line with parameters.

In this case, after processing a PDF/PS file with the specified parameters, APFill presents the results as a text file with values separated by a semicolon – CSV. This file can be opened in MS Excel in order to continue working with the results.

In detail this mode is described in the article: Using APFill for automatic calculation of ink/toner coverage of PDF/PS files.

This article shows an example of using APFill to automatically calculate color coverage of all PDF files in a given directory. To process all files in the “C:\PDFFolder\” directory, the following Windows command file (CMD) is used:

FOR %%I IN ("C:\PDFFolder\*.pdf") DO "%ProgramFiles%\apfill\apfill.exe" –r600 -noprogress "%%I"

Here is a script that for each PDF file in the “C:\PDFFolder\” directory runs the APFill program with the specified parameters for calculating filling with the toner and the file name as an input parameter. The program will also process this file and generate a “<Input file name PDF>.COVERAGE.txt” file with the results.

Here is an example of the result obtained for one input file:

The file can be opened in MS Excel for further processing of the results of the calculation of toner/ink coverage:

In some cases, the automatic mode and the above script are used to process a large number of files, for example, 1,000 – 2,000 PDF files at a time – and it takes a long time.

The script for running APFill can be optimized to reduce the processing time of such a large number of files in the directory. The first thing you can do is decrease the “-r600” parameter. This parameter specifies the resolution (in this case, 600 DPI), with which the PDF file will be converted to a raster format for further calculation of ink coverage. As a rule, already with a resolution of 300 dpi, the results of coverage calculation will be of sufficient accuracy, and at the same time, processing of the results will require considerably less time. More information about this parameter can be found in the article: “APFill: “resolution” and “default page size” parameters”.

The next step to speed up the processing of a large number of PDF files in a directory is a parallel launch of the APFill program. The latest versions of APFil 5.9 (5.8) support running several apfill.exe processes at the same time to calculate parameters for different PDF files. Let’s use this and change the original script to run the program automatically at the same time.

To do this, let’s create two Windows CMD command files.

The first script is apfillRun.cmd:

"%ProgramFiles%\apfill\apfill.exe" -r300 -noprogress %1

This script takes the name of the PDF file as a [%1] parameter and runs the APFill program in the automatic mode with the specified calculation parameters (the parameters here can be different).

The second main script apfillMain.cmd processes all files in the directory by running the apfillRun.cmd script for each of them:

FOR %%I IN ("C:\PDFFolder\*.pdf") DO (
CALL :check
START apfillRun.cmd "%%I"
FOR /F "tokens=* USEBACKQ" %%F IN (`tasklist ^| find /i "apfill.exe" ^| find /C /V ""`) DO (SET count=%%F)
GOTO check

Here in the cycle for each PDF file from the “C:\PDFFolder\” directory, the apfillRun.cmd script runs without waiting in parallel mode. But before each startup, the script checks how many apfill.exe processes are already running and if their number is fewer than “MAX_PROCESS_COUNT” (in this example, 4), it starts another program instance to calculate the next file that is queued up. If the number of processes already started is greater than the value specified by the “MAX_PROCESS_COUNT” parameter, the script waits until one of the launched processes is completed and only then starts a new process to process the next file.

Thus, this script allows you to speed up the processing of a large number of PDF files, running the calculation of files in parallel mode and adjusting the load on the system by limiting the number of simultaneously running processes.

Related Links:

Download the latest APFill Ink Coverage Calculator version

Using APFill for automatic calculation of ink/toner coverage of PDF/PS files

APFill: “resolution” and “default page size” parameters