I have a problem with this code (see attachment pdf) beetwen Acrobat and Spire :
- Code: Select all
Dim pdf As New PdfDocument()
pdf.LoadFromFile(pdfFile)
For i As Integer = 0 To pdf.Pages.Count - 1
'add Text WaterMark
Dim brush As PdfTilingBrush = New PdfTilingBrush(New SizeF(pdf.Pages(i).Canvas.ClientSize.Width / 2, pdf.Pages(i).Canvas.ClientSize.Height / 3))
brush.Graphics.SetTransparency(0.3F)
brush.Graphics.Save()
brush.Graphics.TranslateTransform(brush.Size.Width / 2, brush.Size.Height / 2)
brush.Graphics.RotateTransform(-45)
brush.Graphics.DrawString(TextFiligrane, New PdfFont(PdfFontFamily.Courier, 24), PdfBrushes.Red, 0, 0, New PdfStringFormat(PdfTextAlignment.Center))
pdf.Pages(i).Canvas.DrawRectangle(brush, New RectangleF(New PointF(0, 0), pdf.Pages(i).Canvas.ClientSize))
Next
pdf.SaveToFile(pdfFile)
With Acrobat:
- Code: Select all
Set AcroApp = CreateObject("AcroExch.PDDoc")
AcroApp.Open sDoc
iNbPages = AcroApp.GetNumPages
Set JSO = AcroApp.GetJSObject
Call JSO.addWatermarkFromText("WATERMARK", JSO.app.Constants.Align.center, "Arial", 24, JSO.Color.red, 0, JSO.numPages, True, True, True, JSO.app.Constants.Align.center, JSO.app.Constants.Align.center, 0.4, 0, False, 0.9, False, 45, 0.5)
AcroApp.Save 1, ThisWorkbook.Path & "\" & "acrobat_watermark.pdf"
AcroApp.Close
With SPIRE, I have 6 watermark on each page. With Acrobat only one at center.
Thank's