tags:

views:

5109

answers:

3

Hi,

i wanna convert any Excel or Doc file to PDF with C# (ASP.NET) .. Is there any component or any other solution for this ?

Thanx

+1  A: 

By using the Interop library of Microsoft Office 2007 (included when you have installed Office on your computer), you can use ExportAsFixedFormat function of the Word.Document and Excel.Sheet classes, to convert your files to PDF.

You also may need this add-in: http://www.microsoft.com/downloads/details.aspx?FamilyId=4D951911-3E7E-4AE6-B059-A2E79ED87041&displaylang=en

See the official documentation on: http://msdn.microsoft.com/en-us/library/bb256835.aspx

Zurb
A: 

Hi,

We are using SautinSoft's Excel to PDF .Net library to export our Excel workbooks to PDF in ASP.Net.

The main point is that Excel to PDF .Net can work in memory and doesn't require MS Office installed.

This is a piece of C# code:

    SautinSoft.XlsToPdf xtop = new SautinSoft.XlsToPdf();

    byte[] pdfBytes = null;

    int i = xtop.ConvertBytes(FileUpload1.FileBytes, ref pdfBytes);        

    //show PDF
    if (pdfBytes != null)
    {
        Response.Buffer = true;
        Response.Clear();
        Response.ContentType = "application/PDF";
        Response.BinaryWrite(pdfBytes);
        Response.Flush();
        Response.End();
    }
Yaroslav Sedakov
In my case this library had BIG problem with table converting.
Sasha
A: 

You can use SharpPDF, this is a open source libarry for creating PDF files. YOu can get more details about it in the following link --> http://sharppdf.sourceforge.net/

Bhaskar