Excel to Pdf in C# using Pdftron

607 views Asked by At

I am trying to convert an Excel document into PDF in a ASP.Net Web application using Pdftron (Pdfnet) library. Following is my code for the above purpose.

    pdf.PDF.PDFDoc newSalaryFitmentPdf = new pdf.PDF.PDFDoc();
    pdftron.PDF.Convert.ToPdf(newSalaryFitmentPdf, newSalaryFitmentExcel.FullName);
salaryFitment = newSalaryFitmentPdf.Save(pdf.SDF.SDFDoc.SaveOptions.e_linearized);

But I am getting the following exception when the program is trying to execute the second line.

Exception: 
     Message: An error occurred while converting the file.
Detailed error:
    Error creating a new Excel application instance.
Code: PDFTRON_UNKNOWN (-2147024891)
      File: "Excel.cpp":51
    Log:
      Start check system account.
      Session ID is: 0.
      Failed to create Desktop folder in SystemProfile. boost::filesystem::create_directory: Access is denied: "C:\Windows\system32\config\systemprofile\Desktop"
      Failed to create Desktop folder in SystemProfile. boost::filesystem::create_directory: Access is denied: "C:\Windows\SysWOW64\config\systemprofile\Desktop"
      Done checking system account.
      Creating an Excel application instance.

     Conditional expression: false
     Version    : 6.7.1.61823N
     Filename   : Convert.cpp
     Function   : trn::PDF::Convert::ToPdf
     Linenumber : 1692

Any help would be highly appreciated.

1

There are 1 answers

2
Shakthi Wijeratne On
Failed to create Desktop folder in SystemProfile. boost::filesystem::create_directory: Access is denied: "C:\Windows\system32\config\systemprofile\Desktop"
Failed to create Desktop folder in SystemProfile. boost::filesystem::create_directory: Access is denied: "C:\Windows\SysWOW64\config\systemprofile\Desktop"

You must set your application to have read/write access to these directories. Please see this article for further information.