Skip to content

Ensuring file handles are closed properly

Sambit Kumar Dash edited this page Jul 23, 2017 · 7 revisions

PDF files are stream based. Most of the contents for documents reside in streams. Streams can be:

  1. Compressed
  2. Encrypted
  3. Can be externalized to the PDF files
  4. Can be used to store PDF objects

This creates the need for accessing them several times in the lifetime of a PDF file access. This means you cannot really parse the PDF files in one go and load all contents into memory. When you try to access a file on-demand multiple number of times you tend to risk possibility of leaving out open handles for files. This can be a problem for non-tolerant OS like Window that locks files before access. However, you may not have a Windows OS with you to test it effectively. Depending on AppVeyor, post every build is a bit of a pain considering you have to check-in before knowing if the file handles are released properly.

Welcome to debugIO

Clone this wiki locally