How to manipulate size and position of image inside a digital signature rectangle? Itextsharp

随声附和 提交于 2020-05-16 20:38:33

问题


I need to simultaneously stamp both a string (details of the user) and an image containing an actual signature in a pdfDocument. The string and image are successfully stamped on the document, however, the image of the actual signature is being stretched to fit the rectangle of the whole signature. how do i fix this and manipulate the size and position of the image?

I used both Layer2Text and Image function in one stamper declaration. Can anyone help me? Thanks in advance


回答1:


Instead of merely setting the Layer2Text and Image and letting iTextSharp arrange everything, you can create the signature appearance all by yourself on the PdfTemplate returned by GetLayer(2).

If you need some inspiration on how to fill that layer, you can look at the PdfSignatureAppearance.cs method GetAppearance(), more exactly the section between

if (app[2] == null) {

and

}
if (app[3] == null && !acro6Layers) {

This is where iTextSharp creates the default appearance on the PdfTemplate t. Your code may vary only slightly.



来源:https://stackoverflow.com/questions/29842699/how-to-manipulate-size-and-position-of-image-inside-a-digital-signature-rectangl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!