have a web service created in a .net environment that examines existing pdf files in a staging directory prior to sending them over the wire using FTP.
Part of that process requires that I rename individual files in order to associate them with a particular batch.
I also have a requirement to reduce the size of individual files as much as possible in order to reduce the traffic going over the line.
So far I have managed about a 30% compression rate by using an open source library (iTextSharp).
I am hoping that I can get a better compression rate using the Acrobat SDK, but I need someone to show me how, hopefully with an example that I can follow.
The following code snippet is a model I wrote that accomplishes the rename and file compression...
const string filePrefix = "19512-";
string[] fileArray = Directory.GetFiles(@"c:\temp");
foreach (var pdffile in fileArray) {
string[] filePath = pdffile.Split('\\');
var newFile = filePath[0] + '\\' + filePath[1] + '\\' + filePrefix + filePath[2];
var reader = new PdfReader(pdffile);
var stamper = new PdfStamper(reader, new FileStream(newFile, FileMode.Create), PdfWriter.VERSION_1_5);
int pageNum = 1;
for (int i = 1; i <= pageNum; i++) {
reader.SetPageContent(i, reader.GetPageContent(i), PdfStream.BEST_COMPRESSION);
}
stamper.Writer.CompressionLevel = PdfStream.BEST_COMPRESSION;
stamper.FormFlattening = true;
stamper.SetFullCompression();
stamper.Close();
}
Any assistance is appreciated.