Can we convert the record displayed on the web page to pdf doc ? if possible then how we can achieve this?

this is a software. I want to write code behind button to achieve my task...

i want to convert myrecord.aspx to myrecord.pdf .

ABCpdf - it's a PDF component for ASP.NET, suitable for use in multi-threaded environments.

One way you could convert your ASPX page would be to simply pass the URL to the AddImageUrl function. Something like...

Doc theDoc = new Doc();
theDoc.AddImageUrl("http://www.example.com/somepage.aspx");
theDoc.Save(Server.MapPath("htmlimport.pdf"));
theDoc.Clear();

There's a slightly more complex multi-page example to be found in the product documentation, written in C# and VB.NET

The component makes use of the Trident and Gecko rendering engines, so the PDF generated should match what you'd expect to see in Internet Explorer or FireFox. If you want to find out immediately how ABCpdf will render your web page, try out the online demonstration - no need to install anything.

Disclosures, past and present: see profile ;-)

I put your code behind the button ... The following error occurs when i run my project
"CS0246: The type or namespace name 'Doc' could not be found (are you missing a using directive or an assembly reference?)"

Did you add a reference to the component from your Visual Studio project? Right-click on your project in the solution explorer and select 'Add reference...', look for WebSupergoo.ABCpdf under the .NET tab.

It's useful to include some namespaces also, so add the following to the top of your C# code file...

using WebSupergoo.ABCpdf8;
using WebSupergoo.ABCpdf8.Objects;
using WebSupergoo.ABCpdf8.Atoms;
using WebSupergoo.ABCpdf8.Operations;

or for VB.NET...

Imports WebSupergoo.ABCpdf8
Imports WebSupergoo.ABCpdf8.Objects
Imports WebSupergoo.ABCpdf8.Atoms
Imports WebSupergoo.ABCpdf8.Operations

The 'Getting Started' section of the documentation provides some further help.

There is no component of name "WebSupergoo.ABCpdf" under the .NET tab.
I include the following name spaces :
using WebSupergoo.ABCpdf8;
using WebSupergoo.ABCpdf8.Objects;
using WebSupergoo.ABCpdf8.Atoms;
using WebSupergoo.ABCpdf8.Operations;

and when i run the project.. again i found error :
CS0246: The type or namespace name 'WebSupergoo' could not be found (are you missing a using directive or an assembly reference?)

Hi Sania

ABCpdf installs itself to the global assembly cache (GAC) by default. Open up the Add Reference dialog, select the browse tab and navigate to...
C:\Windows\assembly\GAC_MSIL\ABCpdf\
There you should find a subfolder, named '8.1.1.6__a7a0b3f5184f2169' or similar, inside which is the ABCpdf DLL. Add it as a reference to your project.

Which version of Visual Studio are you using?

i m using Visual Studio 2008

ABCpdf is commecial product. Use wkhtmltopdf tool or download the iTextSharp library. (Tutorials link)

Thanks... My problem is solved...

Disclaimer: I'm working for this company.

Hi :) alternatively, you could use PDF Metamorphosis .Net for this. The component transform Images and HTML to PDF. PDF Vision .Net is absolutely standalone and independent C# component. It doesn't require anything else.
Here you can find more code samples.

Sample code for the converting:

   SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
        //get content of the ASPX page in HTML format
        string htmlString = GetHtmlFromAspx(Path.Combine(Server.MapPath(""), @"Default.aspx"));

        p.HtmlOptions.BaseUrl = Server.MapPath("");

        byte[] pdfBytes = p.HtmlToPdfConvertStringToByte(htmlString);
        //show PDF
        if (pdfBytes != null)
        {
            Response.Buffer = true;
            Response.Clear();
            Response.ContentType = "application/PDF";
            Response.BinaryWrite(pdfBytes);
            Response.Flush();
            Response.End();
        }

Cheer! :)
/Jane/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.