locked
iTextsharp Error RRS feed

  • Question

  • User444756084 posted

    I have an MVC application that creates a PDF. This works fine on my localhost but when I deploy the application to the webserver I get the following error. The code is the same:

    System.IO.IOException: The document has no pages.<o:p></o:p>

    Generated: Wed, 09 Mar 2016 17:57:49 GMT<o:p></o:p>

    <o:p> </o:p>
    System.IO.IOException: The document has no pages.<o:p></o:p>
       at iTextSharp.text.pdf.PdfPages.WritePageTree()<o:p></o:p>
       at iTextSharp.text.pdf.PdfWriter.Close()<o:p></o:p>
       at iTextSharp.text.Document.Close()<o:p></o:p>
       at NominationSystem.Models.CustomPdf.GenerateGSPdf(ControllerContext context, Object model, String viewName, Action`2 configureSettings)<o:p></o:p>
       at NominationSystem.Controllers.Fellowship_ResultsController.UFAwardLetterPDFPOST(Fellowship_Awardee_Offer_Information awardee)<o:p></o:p>
       at NominationSystem.Controllers.Fellowship_ResultsController.AwardLetterAdministration(List`1 models)<o:p></o:p>
       at lambda_method(Closure , ControllerBase , Object[] )<o:p></o:p>
       at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)<o:p></o:p>
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)<o:p></o:p>
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33()<o:p></o:p>
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49()<o:p></o:p>
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult)<o:p></o:p>
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<>c__DisplayClass2a.<BeginInvokeAction>b__20()<o:p></o:p>
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult)<o:p></o:p>
       at System.Web.Mvc.Controller.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult)<o:p></o:p>
       at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)<o:p></o:p>
       at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)<o:p></o:p>
       at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)<o:p></o:p>
       at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult)<o:p></o:p>
       at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)<o:p></o:p>
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()<o:p></o:p>
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)<o:p></o:p>
    Wednesday, March 9, 2016 6:00 PM

Answers

  • User444756084 posted

    The issue was a missing font directory. Thank you for your assistance.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 15, 2016 12:04 PM

All replies

  • User614698185 posted

    Hi gordon1221,

    System.IO.IOException: The document has no pages

    1) There can be a problem to generate pdf from a gridview. Make sure that some simple html is working, for example:

    htmlparser.Parse(new StringReader("hello world"));

    2) If it does work, try to save pdf file on the server and not directly send it with Response.Write (pdfDoc); See if it saved and can't be opened from server.

    Best Regards,

    Candice Zhou

    Thursday, March 10, 2016 2:23 AM
  • User444756084 posted

    Hello thanks for the info. I am not using a gridview. The pdf will create fine on my localhost but gives the error on the web server.

    Thursday, March 10, 2016 3:30 PM
  • User614698185 posted

    Hi gordon1221,

    I think you have permission issue in your application. You should make sure the application can be able to read embedded resources from the itextsharp assembly.

    Best Regards,

    Candice Zhou

    Tuesday, March 15, 2016 9:34 AM
  • User444756084 posted

    The issue was a missing font directory. Thank you for your assistance.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 15, 2016 12:04 PM