将以db中的图像形式存储的签名添加到pdf中 [英] Add a signature which is stored as image in db to a pdf
问题描述
伙计们,
我有一个场景,我需要将存储在db中的签名(图像文件)添加到PDF中,该PDF也存在于同一个数据库中在另一张桌子上。
现在只需点击一下按钮即可完成多次。
喜欢,通过复选框将相同的签名图像添加到上面网格中选择的多个PDF文件。
我再次需要保存(更新)更新的PDF同一个数据库中同一个表中有签名的文件。
我需要 - 在特定位置(在最后一页)将签名保存到PDF中并保存回来到db。
请帮帮我们。
谢谢!!
Sam
Guys,
I have a scenario where in I need to add a signature (image file) stored in db to a PDF which is also present in same db in a different table.
Now this is to be done for multiple times on a single button click.
Like , adding the same signature image to multiple PDF files selected in the grid above via a check box.
I again need to save (update )that updated PDF file with signature in the same table in same db.
I need - Saving a signature into a PDF at a particular position (in the last page) and saving it back to db.
Please help guys.
Thanks!!
Sam
推荐答案
您可以使用iTextSharp。
这样的东西可能适合你:
You can use iTextSharp.
Something like this might work for you:
PdfReader pdfReader = null;
PdfStamper pdfStamper = null;
// Open the PDF file to be signed
pdfReader = new PdfReader(this.signFile.FullName);
// Output stream to write the stamped PDF to
using (FileStream outStream = new FileStream(targetFilename, FileMode.Create))
{
try
{
// Stamper to stamp the PDF with a signature
pdfStamper = new PdfStamper(pdfReader, outStream);
// Load signature image
iTextSharp.text.Image sigImg = iTextSharp.text.Image.GetInstance(SIGNATURE_IMAGE_PATH);
// Scale image to fit
sigImg.ScaleToFit(MAX_WIDTH, MAX_HEIGHT);
// Set signature position on page
sigImg.SetAbsolutePosition(POS_X, POS_X);
// Add signatures to desired page
PdfContentByte over = pdfStamper.GetOverContent(PAGE_NUM_TO_SIGN);
over.AddImage(sigImg);
}
finally
{
// Clean up
if (pdfStamper != null)
pdfStamper.Close();
if (pdfReader != null)
pdfReader.Close();
}
}
干杯,
Edo
Cheers,
Edo
这篇关于将以db中的图像形式存储的签名添加到pdf中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!