public static GetITextSharpImageFromImageFile ( this imageFilePath, bool cacheImages = true ) : |
||
imageFilePath | this | Image's file path |
cacheImages | bool | If true, the image bytes will be added to the PDF only once, not per each new instance. Therefore the result won't be a bloated PDF file. Choose this option if there are many similar images in your data source. |
리턴 |
public static iTextSharp.text.Image GetITextSharpImageFromImageFile(this string imageFilePath, bool cacheImages = true)
{
if (!cacheImages)
return iTextSharp.text.Image.GetInstance(imageFilePath).checkImage();
iTextSharp.text.Image image;
var pathHash = imageFilePath.ToLowerInvariant().MD5Hash();
if (_imageFilesCache.TryGetValue(pathHash, out image))
return image.checkImage();
image = iTextSharp.text.Image.GetInstance(imageFilePath);
_imageFilesCache.Add(pathHash, image);
return image.checkImage();
}