I am trying to save jpeg files to a PDF file.
The commented code works, but the images are unscaled. I would like to use a different way of saving, but it results in a blank PDF file with a message. ERROR: Infinite table loop.
My code:
using (var img = webp.Decode(array))
{
img.Save(streamJpeg, ImageFormat.Jpeg);
streamJpeg.Position = 0;
iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(streamJpeg);
//if (pdfImage.Height > pdfImage.Width)
//{
// //Maximum height is 800 pixels.
// float percentage = 0.0f;
// percentage = 700 / pdfImage.Height;
// pdfImage.ScalePercent(percentage * 100);
//}
//else
//{
// //Maximum width is 600 pixels.
// float percentage = 0.0f;
// percentage = 540 / pdfImage.Width;
// pdfImage.ScalePercent(percentage * 100);
//}
PdfPTable table = new PdfPTable(1);
table.AddCell(new PdfPCell(pdfImage));
doc.Add(table);
//doc.Add(pdfImage);
//doc.NewPage();
}
Thanks, regards.