Hello,
i'm converting .tiff into pdf, for document i have, for example 1300 pages and i do a single document with them.
all is going well, it makes the job in 10 mins, but i would like to reduce the size of it, the total size of the 1300 .tiff is 140mo, at the end the pdf size is 240mo.
I use the version 1.50.4000.0
i have tried all the options below but there's no change.
Code:
s_document.Options.UseFlateDecoderForJpegImages = PdfUseFlateDecoderForJpegImages.Automatic;
s_document.Options.FlateEncodeMode = PdfFlateEncodeMode.BestCompression;
s_document.Options.EnableCcittCompressionForBilevelImages = true;
s_document.Options.CompressContentStreams = true;
s_document.Options.NoCompression = false;
i have also tried to compress the .tiff first in jpeg and than send the stream to the pdf but the final size is even bigger and it consumes enormous quantity of ram.
Code:
ImageCodecInfo codecInfo = ImageCodecInfo.GetImageEncoders()
.Where(r => r.CodecName.ToUpperInvariant().Contains("JPEG"))
.Select(r => r).FirstOrDefault();
var encoder = System.Drawing.Imaging.Encoder.Quality;
var parameters = new EncoderParameters(1);
var parameter = new EncoderParameter(encoder, 50L);
parameters.Param[0] = parameter;
foreach (var file in filePaths)
{
PdfPage page = s_document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
System.Drawing.Image imageSys = System.Drawing.Image.FromFile(file);
MemoryStream streamJPG = new MemoryStream();
imageSys.Save(streamJPG, codecInfo, parameters);
XImage image = XImage.FromStream(streamJPG);
page.Width = image.PointWidth;
page.Height = image.PointHeight;
gfx.DrawImage(image, 0, 0);
image.Dispose();
}
s_document.Save(@"c:\DEV\docNoTiff.pdf");
do you have ideas about how i could reduce the size.
I have also tried the DevExpress plugin conversion, with no compression the size is 245 mo and take 20 mins to convert.
With the Jpeg compression set to high quality, the size is 160mo and it takes 35 mins to convert, there's nearly no visible loss of quality.
I Have millions of documents to convert so time is important.
Kind regards
Geoffrey