SQL Server PDF Compression Script

Job ID: 39952062

Budget: $250 – $750 USD

I have a SQL Server table that stores PDF files in a varbinary(MAX) BLOB column. I need a repeat-ready script or small utility that will:

• Select PDFs based on a simple filter (ideally the date the row was inserted or updated).
• Extract each file to disk or memory, compress it—lossless or lossy is fine as long as the final document looks identical to the user—and then push the smaller file back into the very same row, preserving all existing metadata.
• Update any size fields or checksums we already track and log a before/after byte count so I can verify the savings.

Automation isn’t required; I’ll run the routine myself whenever needed, so the code just has to accept parameters (e.g., start/end date) and run cleanly from SSMS or a command line. T-SQL alone is welcome, but a hybrid (T-SQL to fetch, C#, PowerShell, or Python with Ghostscript/iTextSharp/PyPDF2 for compression) is equally acceptable if it keeps the workflow simple. Must run on a Windows Server environment.

Deliverables
1. Source code and/or SQL scripts.
2. Clear setup and usage instructions.
3. A quick README outlining any third-party libraries or command-line calls involved.

The solution should be fully repeatable, leave every non-PDF field untouched, and finish with a concise success report so I can archive it for auditing.