When I convert a TIFF image to a PDF (by adding it to a paragraph) it loses a lot of the quality. I would like to have the PDF retain the quality of the original TIFF image. Please find the TIFF attached.test.tiff.zip (117.2 KB)
We used the following code snippet with Aspose.PDF for .NET 20.3 and output PDF seemed fine in terms of quality.
Document pdf1 = new Document();
MemoryStream ms = new MemoryStream();
new FileStream(dataDir + "test.tiff", FileMode.Open).CopyTo(ms);
Bitmap myimage = new Bitmap(ms);
FrameDimension dimension = new FrameDimension(myimage.FrameDimensionsList[0]);
int frameCount = myimage.GetFrameCount(dimension);
for (int frameIdx = 0; frameIdx <= frameCount - 1; frameIdx++)
{
Page sec = pdf1.Pages.Add();
myimage.SelectActiveFrame(dimension, frameIdx);
MemoryStream currentImage = new MemoryStream();
myimage.Save(currentImage, ImageFormat.Tiff);
if (myimage.Width > myimage.Height)
{
sec.PageInfo.IsLandscape = true;
}
else
{
sec.PageInfo.IsLandscape = false;
}
sec.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
sec.PageInfo.Height = myimage.Height;
sec.PageInfo.Width = myimage.Width;
Aspose.Pdf.Image imageht = new Aspose.Pdf.Image();
imageht.ImageStream = currentImage;
sec.Paragraphs.Add(imageht);
}
pdf1.Save(dataDir + "TifftoPDF.pdf");
TifftoPDF.pdf (867.9 KB)
Would you kindly try using the latest version of the API and in case you still face any issue, please feel free to let us know.