求助,asp.net中将office文件转成pdf,并加上水印,现在水印加不上
现在已经实现了,转成pdf。
我通过flashpaper实现了转成pdf。
但是加水印中,如下代码
public static bool PDFWatermark(string inputfilepath, string outputfilepath, string ModelPicName, float top, float left, ref string strMsg)
{
PdfReader pdfReader = null;
PdfStamper pdfStamper = null;
try
{
//pdf读取器
pdfReader = new PdfReader(inputfilepath);
//页数
int numberOfPages = pdfReader.NumberOfPages;
//页的大小
iTextSharp.text.Rectangle psize = pdfReader.GetPageSize(1);
float width = psize.Width;
float height = psize.Height;
//生成的pdf
pdfStamper = new PdfStamper(pdfReader, new FileStream(outputfilepath, FileMode.Create));
PdfContentByte waterMarkContent;
//用于水印的图片
iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(ModelPicName);
image.GrayFill = 60;//透明度,灰色填充
image.ImageMask.Transparency = new int[]{50,50};
image.InitialRotation = 2;
image.Interpolation = true;
image.MakeMask();
//image.Rotation//旋转
//image.RotationDegrees//旋转角度
//水印的位置
if (left < 0)
{
left = width - image.Width + left;
}
image.SetAbsolutePosition(left, (height - image.Height) - top);
//每一页加水印,也可以设置某一页加水印
&nb