Tutorial - Using PDFtoolkit ActiveX DLL

Top  Previous  Next

Developers can use PDFtoolkit ActiveX DLL supplied with the setup as shown below. This will help in implementation of non-dialog applications. For Visual Studio.NET add the reference of the PDFtoolkitX.DLL into the project.

 

ASP.net

 

         PDFDoc = new gtPDFDocumentXClass();

          Response.Buffer = true;

          Response.Clear();

          Response.ContentType = "application/pdf";

          Response.AddHeader("Content-Type", "application/pdf");

          PDFDoc.ActivateLicense(TextBox1.Text);

          PDFDoc.LoadFromFile(Server.MapPath("")+"\\pdfform");

          // Make sure the following properties are set to false, else the web page will  hang.

          PDFDoc.OpenAfterSave = false;

          PDFDoc.ShowSetupDialog = false;

          Response.BinaryWrite((byte[]) PDFDoc.SaveToStream());

          Response.Flush();

          Response.End();

          PDFDoc.ResetDocument();

 

Command Line Applications

 

  gtPDFDocumentX PDFDoc;

          PDFDoc = new gtPDFDocumentXClass();

          Console.WriteLine("Enter the License Key for PDFtoolkit ActiveX Control");

          string LicKey = Console.ReadLine();

          PDFDoc.ActivateLicense(LicKey);

          PDFDoc.LoadFromFile(@".\InputFile");

 

          gtTextWatermarkTemplateX  Watermark;

 

          //Create and set watermark properties

          PDFDoc.MeasurementUnit = TxgtMeasurementUnit.muPoints;

          Watermark = PDFDoc.GetTextWatermark();

                   Watermark.Text = "Confidential";

          Watermark.Angle = 45;

          Watermark.Font.Name = "Arial";

          Watermark.Font.Size = 60;

          Watermark.Font.Bold = true;

          Watermark.TextColor = 255;

          Watermark.RenderMode = TxgtRenderMode.rmxFillStroke;

          Watermark.StrokeColor = 13434880;

          Watermark.Overlay = true;

          Watermark.HorizPos = TxgtHorizontalPosition.hpCenter;

          Watermark.VertPos = TxgtVerticalPosition.vpMiddle;

          Watermark.WritingMode = TxgtWrtMode.wmHorizontal;

                   //Insert the watermark

          PDFDoc.InsertTextWatermark(Watermark);

          PDFDoc.SaveToFile(@".\OutputFile");