Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Nov 05, 2018 7:40 pm

Hi, I'm descovering your component to replace Acrobat library.

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

STEPH91
 
Posts: 6
Joined: Mon Nov 05, 2018 7:23 pm

Tue Nov 06, 2018 2:18 am

Hi,

Thanks for your inquiry.
With the code you provided, Spire creates 6 watermarks on each page because of following code.
Code: Select all
            Dim brush As PdfTilingBrush = New PdfTilingBrush(New SizeF(pdf.Pages(i).Canvas.ClientSize.Width / 2, pdf.Pages(i).Canvas.ClientSize.Height / 3))

In this code, the size is divided into six parts(2 X 3 = 6), so there will be 6 watermarks. If you only want one watermark, please change above code to below code:
Code: Select all
            Dim brush As PdfTilingBrush = New PdfTilingBrush(New SizeF(pdf.Pages(i).Canvas.ClientSize.Width, pdf.Pages(i).Canvas.ClientSize.Height))

If there is still the issue, welcome to get it back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Nov 06, 2018 12:16 pm

Thank you, run perfect!

STEPH91
 
Posts: 6
Joined: Mon Nov 05, 2018 7:23 pm

Wed Nov 07, 2018 1:22 am

Hi,

Thanks for your feedback.
Any question, welcome to get it back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF