Changes to Memory Handling in Toolkit R2 and Later

This topic provides details regarding important changes to the way Toolkit 2011 R2 and later handle memory.

Probable Cause

Review both methods of handling memory, New and Alternative (Old), and determine which method is appropriate for your needs.

NOTE: Failure to use one of these methods when using CopyForm can conclude in an unpredictable result in the output PDF.

Due to an update implemented in Toolkit 2011 R2 to allow faster opening of files and to bypass reading fonts, calls that previously emulated a call to OpenInputFile (e.g. NumPages, GetBoundingBox, etc), should no longer be used in this capacity.

The affected calls are: GetBoundingBox, GetPDFInfo, and NumPages.


New Method of Memory Handling

Calling one of these functions now results in the currently open input file to be closed. Therefore, if you wish to use these calls and have a valid open input file, you must do the following in order:

1. Call OpenInputFile.

2. Call the appropriate function, passing a blank file name.


R = TK.OpenInputFile(“myfile.pdf”)

R = TK.NumPages(“”)

Alternative (Old) Method of Memory Handling

Alternatively, you can use a drop-in DLL replacement with memory handlers that support the "old operation" for NumPages and GetPDFInfo. (This method of memory handling does not affect GetBoundingBox.)

To configure alternative memory handling:

1. Create a file named APToolkit.config in one of the following directories, which follow typical search order:

  • EXE directory
  • \Windows\ActivePDF directory
  • \Windows\System32 directory
  • \Windows\SysWow64 directory (for 64-bit systems)
  • \Windows directory

2. Copy and paste the following contents into the file, and then save it.



<memoryAllocator whichAllocator="0" or "1" or "2" />

<alternateOpenInputFile useNewMethod="0" or "1" />