我正在使用以下代码将多个图像合并为一个pdf。
此代码对除高分辨率图像以外的所有图像均适用。
if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
{
image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
}
else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25)
{
image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
}
else
{
image.ScaleToFit(doc.PageSize.Width - 10, doc.PageSize.Height - 10);
}
注意:当我在Google chrome中打开此文件时,它会显示实际图像。
当我尝试在Adobe Reader X中打开pdf时,显示以下错误。
对于缩放和背景色问题,我尝试使用以下代码,但仍然没有运气。
Image jpg = Image.GetInstance(imagepath + "/Sunset.jpg");
jpg.ScaleToFit(250f, 250f);
jpg.Border = Rectangle.BOX;
jpg.BorderColor = Color.YELLOW;
jpg.BorderWidth = 5f;
doc.Add(jpg);