ABCpdf - Dynamic PDF Creation for ASP.Net

ABCpdf - Dynamic PDF Creation for ASP.Net


Note -If you are new in AbcPdf Click here for More Detail

Craete Demo.aspx page in your visual studio project

Demo.aspx

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
          <asp:button runat="server" text="Create PDF" ID="btn_createpdf"  Width="202px" OnClick="btn_createpdf_Click" />
    </div>
    </form>
</body>
</html>


Demo.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebSupergoo.ABCpdf10;

namespace ABCPDF_Demo
{
    public partial class CreatePdf : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_createpdf_Click(object sender, EventArgs e)
        {
            Doc theDoc = new Doc();
            theDoc.Rect.Inset(25, 20);
            int theID;
                    
            string htmlstr = "<div style='height:auto; position:relative; margin-top:10px;'>";

            htmlstr += "<div style='background-color:white; margin-left:100px; border-bottom-style:solid; border-bottom-width:2px; border-bottom-color:#F0F0F0; width:90%; padding-bottom:50px;'>";           
            htmlstr += " <table align='center' cellspacing='0' style='width:100%;'>";
            htmlstr += "<tr>";
            htmlstr += "<td>";
            htmlstr += "<div style='padding-top:5px;'>";
            htmlstr += "<span style='color:#5C5574; font-family:Arial; font-size:18px; font-weight:bold;'>Loan Application </span>";
            htmlstr += "<span style='color:#5C5574; font-family:Arial; font-size:16px;'>";
            htmlstr += "<img src='Image / Capture123.PNG' style='width:19px;'/>|</span>";  
            htmlstr += "<span style='color:#5C5574; font-family:Arial; font-size:18px; font-weight:bold;'>Jack and Jill Anderson </span>";
            htmlstr += "</div>";
            htmlstr += "</div>";
            htmlstr += "</td>";

            htmlstr += "<td style='text-align:right;'><div style='background-color:white; margin-left:100px;'>";           
            htmlstr += "<span style='color:#f44336; font-family:Arial; font-size:36px; font-weight:bold;'>X</span>";
            htmlstr += "<span style='color:#4CAF50; font-family:Arial; font-size:36px; font-weight:bold; margin-left:-5px;'>Y</span>";
            htmlstr += "<span style='color: #433a98; font-family: Arial; font-size: 36px;'>Mortgages</span>";
            htmlstr += "</div>";
            htmlstr += "</td>";
            htmlstr += "</tr>";
            htmlstr += "</table>";
            htmlstr += " </div>";      
          
            htmlstr += "<div style='background-color:white; margin-left:100px;'>";
            htmlstr += "<span style='color: #84738C; font-family: Arial; font-size: 36px; font-weight: bold;'>Checklist</span></div>";
            htmlstr += "<div style='margin-left:100px; padding-top:20px;'>";
            htmlstr += "<span style='color: #84738C; font-family: Arial; font-size: 16px; font-weight: bold;'>The following items are included with this application</span></div>";
            htmlstr += "<div style='width:90 %; margin-top:40px; padding:10px; margin-left:100px; border-radius:0px; '>";
            htmlstr += "<table align='center' cellspacing='0' style='width:100%; border: 1px solid #F0F0F0;'><tr>";
            htmlstr += "<td style='height:45px; background-color:#f5f4f4; width:40%; padding-left:20px;'>";
            htmlstr += "<span style='color:#84738C; font-family:Arial; font-size:16px; font-weight:bold;'>Items</span></td>";

            htmlstr += "<td style='background-color:#f5f4f4;'>";
            htmlstr += "<span style='color:#84738C; font-family: Arial; font-size:16px; font-weight:bold;'>Notes</span>";
            htmlstr += "</td>";
            htmlstr += "</tr>";
            htmlstr += "<tr>";      

            htmlstr += "<td style='height:142px; padding-left:20px; vertical-align:top; '>";
            htmlstr += "<table cellspacing='0' style='width:100 %; '><tr>";
            htmlstr += "<td style='width: 10 %;'>";
            htmlstr += "<img style='width:30px; height:30px; ' src='Image / checkimage.PNG' /></td>";
            htmlstr += " <td><span style='color:#84738C; font-family:Arial; font-size:14px; font-weight:bold;'>Payslip</span></td>";
            htmlstr += " </tr><tr><td>";
            htmlstr += "<img  style='width:30px; height:30px; ' src='Image / checkimage.PNG' /></td>";
            htmlstr += "<td><span style='color: #84738C; font-family:Arial; font-size:14px; font-weight:bold;'>Signed Declaration</span></td>";
            htmlstr += "</tr><tr><td><img  style='width:30px; height:30px; ' src='Image / checkimage.PNG' /></td>";
            htmlstr += "<td><span style='color: #84738C; font-family: Arial; font-size: 14px; font-weight: bold;'>Sales and Purchase</span></td>";

            htmlstr += "</tr>";
            htmlstr += "<tr>";
            htmlstr += "<td>";
            htmlstr += "<img  style='width: 30px; height: 30px; ' src='Image / checkimage.PNG' /></td>";
            htmlstr += "<td><span style='color: #84738C; font-family: Arial; font-size: 14px; font-weight: bold;'>Agreement</span></td>";
            htmlstr += "</tr>";

            htmlstr += "</table></td><td style='vertical - align: top;'><table style='width: 100 %; height: 127px;'><tr>";
            htmlstr += "<td style='width: 10 %;'><span style='color: #84738C; font-family: Arial; font-size: 14px; font-weight: bold;'>Only for three months</span></td>";
            htmlstr += "</tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr></table></td></tr></table></div>";
            htmlstr += "<div style='margin-left:100px; padding-top:20px;'>";
            htmlstr += " <span style='color: #84738C; font-family: Arial; font-size: 16px; font-weight: bold;'>The following items will be forthcoming</span>";
            htmlstr += "</div>";
            htmlstr += "<div style='width:90 %; margin-top:40px; padding:10px; margin-left: 100px; border-radius:0px;'>";
            htmlstr += " <table align='center' cellspacing='0' style='width:100%; border: 1px solid #F0F0F0;'>";
            htmlstr += " <tr><td style='height:45px; background-color:#f5f4f4; width:40%; padding-left:20px;'><span style='color:#84738C; font-family: Arial; font-size:16px; font-weight:bold;'>Items</span></td>";

            htmlstr += "<td style='background-color:#f5f4f4;'>";
            htmlstr += "<span style='color: #84738C; font-family: Arial; font-size: 16px; font-weight: bold;'>Notes</span> ";
            htmlstr += "</td> ";
            htmlstr += "</tr> ";
            htmlstr += "<tr>";
            htmlstr += "<td style='height: 142px; padding - left: 20px; vertical - align: top; '> ";
            htmlstr += "<table cellspacing='0' style='width: 100 %; '> ";
            htmlstr += "<tr>";
            htmlstr += "<td style='width: 10 %;'> ";
            htmlstr += "<img style='width: 30px; height: 30px;' src='Image / checkimage2.PNG' /></td>";
            htmlstr += "<td><span style='color: #84738C; font-family: Arial; font-size: 14px; font-weight: bold;'>Payslip</span></td> ";
            htmlstr += "</tr> ";
            htmlstr += "<tr> ";
            htmlstr += "<td> ";
            htmlstr += "<img  style='width: 30px; height: 30px; ' src='Image / checkimage2.PNG' /></td> ";
            htmlstr += "<td><span style='color: #84738C; font-family: Arial; font-size: 14px; font-weight: bold;'>Signed Declaration</span></td>";
            htmlstr += "</tr>";
            htmlstr += "<tr> ";
            htmlstr += "<td>&nbsp;</td>";
            htmlstr += "<td>&nbsp;</td> ";
            htmlstr += "</tr>";
            htmlstr += "<tr>";
            htmlstr += "<td>&nbsp;</td>";
            htmlstr += "<td>&nbsp;</td> ";
            htmlstr += "</tr>";
            htmlstr += "</table>";
            htmlstr += "</td>";
            htmlstr += "<td style='vertical - align: top; '>";
            htmlstr += "<table cellspacing='0' style='width: 100 %; '>";
            htmlstr += "<tr>";
            htmlstr += "<td style='height: 30px; '><span style='color: #84738C; font-family: Arial; font-size: 14px; font-weight: bold;'>Payslip</span></td>";
            htmlstr += "</tr>";
            htmlstr += "<tr>";
            htmlstr += "<td style='height: 30px;'><span style='color: #84738C; font-family: Arial; font-size: 14px; font-weight: bold;'>Signed Declaration</span></td>";
            htmlstr += "</tr>";
            htmlstr += "<tr>";
            htmlstr += "<td style='height: 30px; '>&nbsp;</td>";
            htmlstr += "</tr>";
            htmlstr += "<tr>";
            htmlstr += "<td style='height: 30px;'>&nbsp;</td>";
            htmlstr += "</tr>";
            htmlstr += " </table>";
            htmlstr += "</td>";
            htmlstr += "</tr>";
            htmlstr += "</table>";
            htmlstr += "</div>";
            htmlstr += "</div>";
            htmlstr += " <div style='page-break-before:always'>pagebreak</div>";        


            theID = theDoc.AddImageHtml(htmlstr);
            while (true)
            {
                theDoc.FrameRect();
                if (!theDoc.Chainable(theID))
                    break;
                theDoc.Page = theDoc.AddPage();
                theID = theDoc.AddImageToChain(theID);
            }
            for (int i = 1; i <= theDoc.PageCount; i++)
            {
                theDoc.PageNumber = i;
                theDoc.Flatten();
            }

            theDoc.Save(@"D:pdf\pdf.pdf");
            theDoc.Clear();
        }
    }
}









Create Multiple Pages in ABCpdf in .net

Create Multiple Pages in ABCpdf in .net


Note -If you are new in AbcPdf Click here for More Detail


Doc.aspx 

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>    
     <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Create Pdf" />    
    </div>
    </form>
</body>
</html>


Doc.aspx.cs 

Add namespace
using WebSupergoo.ABCpdf10;


Doc.aspx.cs

protected void Button1_Click(object sender, EventArgs e)
 {
   Doc theDoc = new Doc();
   theDoc.Rect.Inset(72, 80);
   int theID;
          
   theID = theDoc.AddImageUrl("http://www.websupergoo.com/abcpdf-download.htm");
   while (true)
   {
    theDoc.FrameRect();
    if (!theDoc.Chainable(theID))
    break;
    theDoc.Page = theDoc.AddPage();
    theID = theDoc.AddImageToChain(theID);
    }
    for (int i = 1; i <= theDoc.PageCount; i++)
    {
    theDoc.PageNumber = i;
    theDoc.Flatten();
    }             
    theDoc.Save(@"D:pdf\pdfnew.pdf");
    theDoc.Clear();
  }


How to Create Pdf Using ABCPdf in .Net

Step 1 Go to this Url  http://www.websupergoo.com/abcpdf-download.htm




Step 2 Click On Download Button
  

Step 3 Your Downloading is starting




Step  4 After downloading Install the Software and add the DLL file in Your .Net  Project 

Note >> Dll File Location in Your system after successful installation 

C:\Program Files\WebSupergoo\ABCpdf .NET 10.1 x64

File Name -- ABCpdf.dll











Example

Craete Demo.aspx page in your visual studio project

Demo.aspx


<html >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Create Pdf" />
    </div>
    </form>
</body>
</html>


Demo.aspx.cs

Add namespace
using WebSupergoo.ABCpdf10;

Add Code
 protected void Button1_Click(object sender, EventArgs e)
  {
     Doc theDoc = new Doc();           
     theDoc.AddImageUrl("http://www.websupergoo.com/abcpdf-download.htm");
     theDoc.Save(@"D:pdf\pdfnew.pdf");
     theDoc.Clear();
  }


How to use Captcha control in asp.net

What is the use of Captcha control 

The term CAPTCHA stands for Completely Automated Public Turing Test To Tell Computers and Humans Apart. The following are the 2 most compelling reason for using captcha control 

1. To prevent automated computer programs from submitting comments (SPAM). CAPTCHA control ensures only humans can enter comments.

2. To prevent bogus user registrations. For example, when you try to create a new gmail account, notice that there is a captcha control displayed on the registration page. This ensures only humans can register and not automated scripts.

It is very difficult for automated computer programs to read the distorted text displayed in a captcha control.

Example : The data entered in the webform below should only be saved to the database table when captcha control passes validation 

captcha in asp.net 

There are several free captcha controls available on the internet. I have tested reCAPTCHA control with ASP.NET and works very well. It is very easy to integrate as well. Here are the steps.

Step 1 : Sign up for API keys.
https://developers.google.com/recaptcha/intro

Step 2 : Download reCAPTCHA ASP.NET library
https://developers.google.com/recaptcha/docs/aspnet

Step 3 : Extract Recaptcha.dll from the downloaded ZIP folder

Step 4 : Create an empty asp.net web application. Name it Demo. Add a reference to Recaptcha.dll assembly.

Step 5 : Include the database connection string in web.config file

Step 6 : Create database table RegisteredUsers to store data
Create table RegisteredUsers
(
     Id int identity primary key,
     Name nvarchar(50),
     Email nvarchar(50),
     Password nvarchar(50)
)


Step 7 : Create spRegisterUser stored procedure to insert data
Create proc spRegisterUser
@Name nvarchar(50),
@Email nvarchar(50),
@Password nvarchar(50)
as
Begin
     Insert into RegisteredUsers 
     values (@Name, @Email, @Password)
End


Step 8 : Add a web form to the Demo project. 
a) Include the following Register directive on the page just below the Page directive
<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha"
                         Assembly="Recaptcha" %>
b) Copy and paste the following HTML inside the <form> tag
<div style="font-family: Arial">
    <h3>User Registration</h3>
    <table style="border: 1px solid black">
        <tr>
            <td>
                <b>Name </b>
            </td>
            <td>
                <asp:TextBox ID="txtName" runat="server" Width="230px">
                </asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                <b>Email </b>
            </td>
            <td>
                <asp:TextBox ID="txtEmail" runat="server" Width="230px">
                </asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                <b>Password </b>
            </td>
            <td>
                <asp:TextBox ID="txtPassword" runat="server" Width="230px"
                                TextMode="Password"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <recaptcha:RecaptchaControl ID="recaptcha" runat="server"
                    PublicKey="your_public_key"
                    PrivateKey="your_private_key" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Button ID="btnSubmit" runat="server" Text="Register"
                            OnClick="btnSubmit_Click" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Label ID="lblMessage" runat="server"></asp:Label>
            </td>
        </tr>
    </table>
</div>


Step 9 : Copy and paste the following code in the code-behind page
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;

namespace Demo
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string cs = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;
                using (SqlConnection con = new SqlConnection(cs))
                {
                    SqlCommand cmd = new SqlCommand("spRegisterUser", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlParameter paramName = new SqlParameter("@Name", txtName.Text);
                    SqlParameter paramEmail = new SqlParameter("@Email", txtEmail.Text);
                    SqlParameter paramPassword = new
                        SqlParameter("@Password", txtPassword.Text);

                    cmd.Parameters.Add(paramName);
                    cmd.Parameters.Add(paramEmail);
                    cmd.Parameters.Add(paramPassword);

                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                lblMessage.Text = "Registration Successful";
            }
            else
            {
                lblMessage.Text = "Word verification failed";
            }
        }
    }
}