PDF Viewer SDK ActiveX

PDF Viewer SDK ActiveX

Platform : Windows 11, Windows 10, Windows 8, Vista, XP

It is PDF Viewer SDK, fast open PDF, support print a PDF, searching the text with C , C#, VB.Net , VB6, Delphi, Vfp, MS Access.

Popular Solution Go   Back

VB.NET - How to add PDF Stamp to a PDF

Step 1: To install the PDF Viewer SDK ActiveX Control, begin by launching the setup file (https://www.viscomsoft.com/demo/pdfviewersetup.exe). Select the desired installation folder for the PDF Viewer SDK ActiveX and continue with the installation on your development computer.

Step 2: Create New Visual Basic Project, select Windows Form Application.

Step 3: The next step is to install PDF Viewer SDK ActiveX Control in ToolBox. Select Toolbox, select Components item, right click mouse button, select Choose Items.



Step 4:  In COM Components tab, select PDF Viewer ActiveX Control, click OK.



Step 4:  Drag the PDF Viewer SDK ActiveX from ToolBox to form. 

Step 5: Create the UI as the following and add OpenFileDialog and SaveFileDialog on form

Step 6: Add the following code on Form load event.

 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        cbostampicon.Items.Add("Approved")

        cbostampicon.Items.Add("Asls")

        cbostampicon.Items.Add("Confidential")

        cbostampicon.Items.Add("Departmental")

        cbostampicon.Items.Add("Draft")

        cbostampicon.Items.Add("Experimental")

        cbostampicon.Items.Add("Expired")

        cbostampicon.Items.Add("Final")

        cbostampicon.Items.Add("ForComment")

        cbostampicon.Items.Add("ForPublicRelease")

        cbostampicon.Items.Add("NotApproved")

        cbostampicon.Items.Add("NotForPublicRelease")

        cbostampicon.Items.Add("Sold")

        cbostampicon.Items.Add("TopSecret")

        cbostampicon.SelectedIndex = 0


        cbostampcolor.Items.Add("transparent")

        cbostampcolor.Items.Add("aqua")

        cbostampcolor.Items.Add("black")

        cbostampcolor.Items.Add("blue")

        cbostampcolor.Items.Add("fuchsia")

        cbostampcolor.Items.Add("gray")

        cbostampcolor.Items.Add("green")

        cbostampcolor.Items.Add("lime")

        cbostampcolor.Items.Add("maroon")

        cbostampcolor.Items.Add("navy")

        cbostampcolor.Items.Add("olive")

        cbostampcolor.Items.Add("orange")

        cbostampcolor.Items.Add("purple")

        cbostampcolor.Items.Add("red")

        cbostampcolor.Items.Add("silver")

        cbostampcolor.Items.Add("teal")

        cbostampcolor.Items.Add("white")

        cbostampcolor.Items.Add("yellow")

        cbostampcolor.SelectedIndex = 3

        AxPDFViewer1.PDFClearStamp()

    End Sub

Step 7: Add the following code in Load PDF click event

  Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        Dim iResult As Integer

        If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then


            iResult = Me.AxPDFViewer1.LoadPDFFile(Me.OpenFileDialog1.FileName)

            If iResult = -1 Then

                MessageBox.Show("Load Failed")

                Exit Sub

            End If

 

            If iResult = -2 Then

                MessageBox.Show("Password is not correct")

                Exit Sub

            End If

 

        End If

 

    End Sub

Step 8: add the following code in Add PDF Stamp click event

 Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

        AxPDFViewer1.PDFAddStamp(1, cbostampicon.SelectedIndex, txtleft.Text, txttop.Text, txtwidth.Text, txtheight.Text, cbostampcolor.SelectedIndex, txtstamptext.Text)

 End Sub

Step 9: add the following code in Save click event

    Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        Dim bResult As Boolean
        SaveFileDialog1.Filter = "PDF file (*.pdf)|*.pdf||"
        SaveFileDialog1.DefaultExt = "pdf"
        If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            bResult = AxPDFViewer1.SavePDF(SaveFileDialog1.FileName)
            If bResult = True Then
                MessageBox.Show("Save " SaveFileDialog1.FileName " Completed")
            End If
        End If
    End Sub

After added the PDF stamps, the output PDF like this


Download this sample source code