我使用以下代码在 mvc 中使用带有 razorpdf 生产者的 itext 生成 pdf
@model myModel.Models.Examform
@{
Layout = null;
}
<itext creationdate="@DateTime.Now.ToString()" producer="RazorPDF">
Hello
</text>
这段代码工作正常。我想在生成的 pdf 中添加水印。我知道如何添加图像。我需要在背景中显示的水印。
最佳答案
这几乎是完全相同的问题
ItextSharp - RazorPdf put image on Pdf
所以使用那里的答案应该对你有用:
<image url="@Context.Server.MapPath("~/Images/sampleImage.png")" />
编辑:要在图像上叠加文本,您需要修改 CSS 和 HTML。
How to position text over an image in css
Add "Watermark" effect with CSS?
http://www.the-art-of-web.com/css/textoverimage/
您可能需要将 CSS 内联。
关于c# - 为razorpdf mvc添加水印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25749627/