Hi, The current code allocates a maximized buffer to write the JPEG into but never resizes that buffer afterwards hence the PDF is large. The fix is to resize the buffer to the actual size of the compressed JPEG data (see attached patch).
> du -sh Scanned\ Document*.pdf 1.1M Scanned Document-fixed.pdf 26M Scanned Document.pdf
Hi, The current code allocates a maximized buffer to write the JPEG into but never resizes that buffer afterwards hence the PDF is large. The fix is to resize the buffer to the actual size of the compressed JPEG data (see attached patch).
> du -sh Scanned\ Document*.pdf
1.1M Scanned Document-fixed.pdf
26M Scanned Document.pdf