Question about ElementWriter.e_replacement

The most likely problem is that the file is really badly constructed. For example, it is possible that identical resources (e.g. images, fonts, etc) are being created over and over again instead of being referenced only once, but it is hard to guess without looking at a sample input document.

ElementWriter.e_replacement replaces/discards the old Resources dictionary, so it is possible that the original file contains refereferences to redundand/unecessary data in the Resources dictionary.

You can use PDFTron CosEdit ( to inspect the original file and track down the problem.