Sunday, April 12, 2015

How to create large PDF file in MACos for testing

Recently I needed to create a set of large PDF files to be used for testing. The files had to be very large, and have to be processed by a search engine for indexing. It was important to have a custom content in them, as well as make sure they do not have many images, but a lot of text. That had to be processed later and be available for searching. With the code snippet below you can create a set of such PDF files, and use them for whatever purpose you need to.

Here is how I did it. Step 1. I wrote a simple script, which prepares a text file to be converted to PDF:


echo "" > testContent.txt
for i in {1..5000}
echo "Test content to fill into large pdf." >> testContent.txt
cupsfilter testContent.txt > large0.pdf 2>/dev/null

Note that you should be able to adjust amount of text you would like to see in the file, and the text itself, so the content looks exactly how you want to see it. The final large0.pdf if the test PDF file, which you need. cupsfilter command ( actually converts text file into another format, by default into PDF.
You can read more about cupsfilter by reading cupsfilter connmmand syntax description on

I will show in next article, how from a single PDF file you can create a set of files of multiple sizes.

No comments:

Post a Comment