I'm writing an ASP.NET (C#) application that uses iTextSharp to embed an image (a signature to be more specific) into an AcroForm . I achieved a decent result collecting the image from an external media (a USB Wacom tablet) and resizing it to fit in the acroform signature placeholder (that's half the size the picture taken from the tablet). I'm not fully satisfied of the result since the tablet collect the signature with a gross resolution (I think no more than 75 dpi) and thus resizing it (even with the most conservative algorithm) give a little fuzzy/rough image ... it's perfectly readable but not good looking in my opinion. I tough then that, maybe, chaging the DPI of the image instead changing it's size would retain all the original definition and thus give a better result when rendered inside the PDF. How can I achieve this result? I mean there's a simple way using iTextSharp to insert an image and setting it's DPI or I have to preprocess the image and changing the DPI prior embedding it? Is it possibile to define an AcroForm field that holds images instead text?
@BrunoLowagie of course I can, that's the code::
using (Stream _sInputPdfStream = new FileStream(_sTempNomeFile, FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream _sInputImageStream = new FileStream(sImagePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream _sOutputPdfStream = new FileStream(_sOutputNomeFile, FileMode.Create, FileAccess.Write, FileShare.None))
{
var _rReader = new PdfReader(_sInputPdfStream);
var _sStamper = new PdfStamper(_rReader, _sOutputPdfStream);
var _cContent = _sStamper.GetOverContent(1);
iTextSharp.text.Image _iImage = iTextSharp.text.Image.GetInstance(_sInputImageStream);
_iImage.SetAbsolutePosition(400, 0);
_cContent.AddImage(_iImage);
_sStamper.Close();
}
Of course the sImagePath value is the path of the image I just uploaded to be 'attached' to the PDF.
Best Regards, Weirdgyn