PDF Viewer SDK ActiveX

PDF Viewer SDK ActiveX 12.0

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.

C# - How to add PDF Stamp to a PDF

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


Step 2: Create New Visual C# Project, select Windows Forms Application.

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



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



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

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


Step 7: add the following code in Form load event

private void Form1_Load(object sender, EventArgs e)
{
       
        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();
   }

Step 9: add the following code in Load PDF click event

private void Button1_Click(object sender, EventArgs e) {
int iResult;
if( OpenFileDialog1.ShowDialog() ==DialogResult.OK)
{
iResult= axPDFViewer1.LoadPDFFile(OpenFileDialog1.FileName);
if(iResult==-1)
{
MessageBox.Show("Load Failed");
return;
}
if (iResult==-2)
{
MessageBox.Show("Password is not correct");
}
}
}
Step 10: add the following code in Add PDF Stamp click event           

  private void Button2_Click(object sender, EventArgs e)
   {
            axPDFViewer1.PDFAddStamp(1, cbostampicon.SelectedIndex,Int32.Parse(txtleft.Text), Int32.Parse(txttop.Text), Int32.Parse(txtwidth.Text), Int32.Parse(txtheight.Text), cbostampcolor.SelectedIndex, txtstamptext.Text);
     
   }

Step 11: add the following code in Save click event

 private void Button3_Click(object sender, EventArgs e)
 {
            bool bResult;
            SaveFileDialog1.Filter = "PDF file (*.pdf)|*.pdf||";
            SaveFileDialog1.DefaultExt = "pdf";
              if (SaveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
              {
                bResult = axPDFViewer1.SavePDF(SaveFileDialog1.FileName);
                if (bResult)
                 MessageBox.Show("Save " SaveFileDialog1.FileName " Completed");
              }   
 }

After added the PDF stamps, the output PDF like this



Download this sample source code