Hi Nigel. In one related post it was mention, that only the pdf, not the images are compressed. I think this has changed.
I now can prove 1 mb pdfs with grayscale and 2 pages.
is the code correct, or any ideas left? Resampling is not an option, we don't want to get the file worser if we save it again and again.
static void TestPDF2()
{
string sourceImage1 = @"C:\Laufwerk_d\Net\IEmagen_grayscaletiff_error\IEvolution gray_tif_fails\SourceFiles\For pdf grayscale.png";
string sourceImage2 = @"C:\Laufwerk_d\Net\IEmagen_grayscaletiff_error\IEvolution gray_tif_fails\SourceFiles\20220513152724.jpg";
string targetPDF = @"C:\Temp\capture\export\page.pdf";
List<string > sourceImages=new List<string>();
sourceImages.Add(sourceImage1);
sourceImages.Add(sourceImage2);
using (IEImage ieImage = new IEImage())
{
ieImage.CreatePDFFile(targetPDF);
foreach (string sourceImage in sourceImages)
{
ieImage.LoadImage(sourceImage);
// resample
//ieImage.Resample(1500, -1, IEResampleFilter.FastLinear);
ieImage.ConvertToGray();
ieImage.IOParams.TIFF_ZIPCompression = TIFFZIPCompression.Max;
ieImage.IOParams.TIFF_Compression = TIFFCompression.ZIP;
//reload as tiff:
using (MemoryStream memoryStream = new MemoryStream())
{
ieImage.SaveImage(memoryStream, IEFileFormats.TIFF);
ieImage.LoadImage(memoryStream);
}
ieImage.IOParams.PDF_Compression = PDFCompression.LZW;
ieImage.IOParams.BitsPerSample = 8;
ieImage.IOParams.SamplesPerPixel = 1;
ieImage.SaveToPDF();
}
ieImage.ClosePDFFile();
}
}