VB.NET PDF SEARCH PDFImports Spire.Pdf Imports System.Drawing Namespace AddImageWatermark Class Program Shared Sub Main(ByVal args() As String) 'Create a PdfDocument object Dim document As PdfDocument = New PdfDocument() 'Load a sample PDF document document.LoadFromFile("C:\Users\Administrator\Desktop\Terms of Service.pdf") 'Load an image Dim image As Image = Image.FromFile("C:\Users\Administrator\Desktop\logo.jpg") 'Get the image width and height Dim imgWidth As Integer = image.Width Dim imgHeight As Integer = image.Height 'Loop through the pages Dim i As Integer For i = 0 To - 1 Step i 1 'Get the page width and height Dim pageWidth As single = document.Pages(i).ActualSize.Width Dim pageHeight As single = document.Pages(i).ActualSize.Height 'Set the background opacity document.Pages(i).BackgroudOpacity = 0.3f 'Set the background image of current page document.Pages(i).BackgroundImage = image 'Position the background image at the center of the page Dim rect As Rectangle = New Rectangle(CType((pageWidth - imgWidth) / 2,(Integer)(pageHeight - imgHeight) / 2,imgWidth,imgHeight, Integer)) document.Pages(i).BackgroundRegion = rect Next 'Save the document to file document.SaveToFile("AddImageWatermark.pdf") document. The syntax of the function is given below. using Spire.Pdf using using System.Drawing namespace AddTextWatermarkToPdf Let us have a closer look at the FindText function now. Save the document to another PDF file using PdfDocument.SaveToFile() method.Draw watermark text on the specific page using () method.Rotate the coordinate system 45 degrees counterclockwise using () method.Translate the coordinate system using () method, so that that the text watermark will be placed at the center of the page.Set the canvas transparency of a specific page using () method.Traverse all the pages in the document.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |