2
Winnovative HTMLtoPDF 변환기를 사용하여 HTML 콘텐츠에서 PDF를 생성 한 사람이 있습니까? 그렇다면 누구나 성공적으로 결과 PDF의 일부 또는 모든 페이지에 워터 마크를 넣었습니까?Winnovative HTMLtoPDF 변환기, 워터 마크 추가
Winnovative HTMLtoPDF 변환기를 사용하여 HTML 콘텐츠에서 PDF를 생성 한 사람이 있습니까? 그렇다면 누구나 성공적으로 결과 PDF의 일부 또는 모든 페이지에 워터 마크를 넣었습니까?Winnovative HTMLtoPDF 변환기, 워터 마크 추가
재미있어졌습니다. Winnovative 사이트의 this page에서 유용한 코드 스 니펫을 발견했습니다. 6.4.2.2를 찾아 해당 절의 코드를 읽으십시오.
내가 제공 한 링크는 내가 제공 한 링크입니다. 이것은 PDF를 PDFDocument 객체로 생성 한 후에 호출됩니다.
public void PostDocProcessing(Winnovative.WnvHtmlConvert.PdfDocument.Document document, string sBackgroundImagePath)
{
// get the first page the PDF document
PdfPage firstPage = document.Pages[0];
System.Drawing.Image logoImg = System.Drawing.Image.FromFile(sBackgroundImagePath);
// calculate the watermark location
System.Drawing.SizeF imageSizePx = logoImg.PhysicalDimension;
// transform from pixels to points
float imageWidthPoints = UnitsConverter.PixelsToPoints(imageSizePx.Width);
float imageHeightPoints = UnitsConverter.PixelsToPoints(imageSizePx.Height);
float watermarkXLocation = (firstPage.ClientRectangle.Width - imageWidthPoints);
float watermarkYLocation = -50;
// add a template watermark to the document repeated on each document page
// the watermark size is equal to image size in points
Template watermarkTemplate = document.AddTemplate(new System.Drawing.RectangleF(watermarkXLocation, watermarkYLocation, imageWidthPoints, imageHeightPoints));
// add an image to the watermak
ImageElement watermarkImageElement = new ImageElement(0, -300, logoImg);
watermarkImageElement.Transparency = 100;
watermarkTemplate.AddElement(watermarkImageElement);
// dispose the image
logoImg.Dispose();
}