Click here to Skip to main content
15,891,930 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Friends,

how to convert the Word document to pdf ,excel to pdf,ppt to pdf using ABC PDFin dot net.i tried but its threws some exception.please any one can help me.

the Error is
Application threw an exception: Failed to invoke member "ExportAsFixedFormat"--The export failed due to an unexpected error.
Posted
Updated 26-Aug-13 0:14am
v2

Hi...
Am have bind the retrieved data to lables in form load. That form having one button, name is print(for pdf).
In that print_click event:
C#
Response.ContentType = "application/pdf";
           Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
           Response.Cache.SetCacheability(HttpCacheability.NoCache);
           StringWriter sw = new StringWriter();
           HtmlTextWriter hw = new HtmlTextWriter(sw);
           pnlPerson.RenderControl(hw);
           StringReader sr = new StringReader(sw.ToString());
           //Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
           Document pdfDoc = new Document(PageSize.A3, 100f, 10f, 10f, 10f);
           HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
           PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
           pdfDoc.Open();
           htmlparser.Parse(sr);
           pdfDoc.Close();
           Response.Write(pdfDoc);
           Response.End();

It wil opened pdf format only.
Thank u.
 
Share this answer
 
C#
public void ConvertWordtoPdf()
    {
        Doc objDoc = new Doc();
        XReadOptions xr = new XReadOptions();
        xr.ReadModule = ReadModuleType.MSOffice;
        objDoc.Read("D:\\User\\Keerthana\\test.doc", xr);
        //objDoc.Read(Server.MapPath("D:\\User\\Keerthana\\test.doc"),xr);
        objDoc.Save("D:\\User\\Keerthana\\Projects\\PDF\\WordDocumentToPdftest.pdf");
        objDoc.Clear();
        xr.Dispose();
        objDoc.Dispose()
}

C#
public void ConvertPPTtoPdf()
   {
       Doc theDoc=new Doc();
       //string pathPPT = "D:/User/Keerthana/DSSI_PPT.pptx";
       //theDoc.Read(pathPPT);
       theDoc.Read("D:\\User\\Keerthana\\DSSI_PPT.pptx");
       theDoc.Save("D:\\User\\Keerthana\\Projects\\PDF\\PPTToPdfDocument.pdf");
       theDoc.Clear();
       theDoc.Dispose();
   }

C#
public void ConvertExceltoPdf()
   {

       Doc theDoc = new Doc();
       theDoc.Read("D:\\User\\Keerthana\\Exceldoc.xls");
       theDoc.Save("D:\\User\\Keerthana\\Projects\\PDF\\ExcelToPdfDocument.pdf");
       theDoc.Clear();
       theDoc.Dispose();
   }
 
Share this answer
 
v2
Comments
Ravi Kumar Mishra 26-Aug-13 8:38am    
I have not getting XReadOptions and Read function in Microsoft.Office.Interop.Word namespace, please tell me the namespace names
keerthana.k 26-Aug-13 23:36pm    
using WebSupergoo.ABCpdf8;
using WebSupergoo.ABCpdf8.Atoms;
using WebSupergoo.ABCpdf8.Internal;
using WebSupergoo.ABCpdf8.Objects;
using WebSupergoo.ABCpdf8.Operations;

I am using abc pdf in dot net

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900