Closed DafyddNZ closed 10 years ago
I've not seen this error before, what does the standard html output look like?
You can tag html=true onto the url to see this.
Can you post your view and controller all on with the file name of the view.
This occurs when the view can't be found or when the view has another rendering issue. On Oct 16, 2014 6:23 PM, "DafyddNZ" notifications@github.com wrote:
Hi I am trying to use the MvcRazorToPdf for the first time, but I get an Exception when using PdfActionResult.
[IOException: The document has no pages.] iTextSharp.text.pdf.PdfPages.WritePageTree() +1112 iTextSharp.text.pdf.PdfWriter.Close() +378 iTextSharp.text.Document.Close() +152 MvcRazorToPdf.MvcRazorToPdf.GeneratePdfOutput(ControllerContext context, Object model, String viewName, Action2 configureSettings) +837 MvcRazorToPdf.PdfActionResult.ExecuteResult(ControllerContext context) +555
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +97 System.Web.Mvc.Async.<>cDisplayClass21.b1e(IAsyncResult asyncResult) +241 System.Web.Mvc.Controller.b1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +111 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +19 System.Web.Mvc.MvcHandler.b5(IAsyncResult asyncResult, ProcessRequestState innerState) +51 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Any ideas?
— Reply to this email directly or view it on GitHub https://github.com/andyhutch77/MvcRazorToPdf/issues/20.
I have tried html=true and the html generated is fine. The views name is ProgressExport.cshtml
I have tried to simplify to plain html just to get it to work:
@@model IEnumerable
@{ Layout = "~/Views/Shared/_LayoutExport.cshtml"; //Layout = null; ViewBag.Title = "Progress Report"; }
@the rest of the file is commented out@
The controller action is as follows: public ActionResult ProgressExport(DateTime? startDate, DateTime? endDate) { var documentFilename = String.Format("Programme Progress {0:MMMM yyyy}.pdf", DateTime.Now); var tecData = _reposit.GetTECComplianceData(startDate, endDate) .Where(x => x.OrgCode != "Youth Guarantee") .OrderBy(x => x.OrgCode) .ThenBy(x => x.PGVersionDesc) .ToList();
return new PdfActionResult(documentFilename, (writer, document) =>
{
document.SetPageSize(new iTextSharp.text.Rectangle(500f, 500f, 90));
document.NewPage();
})
{
FileDownloadName = documentFilename
};
}
I would usually pass in the generated list, but to simplify I used the documentFileName string as the model.
Regards David
i have the same error and i did nothing special. Created new mvc app and use about page to generate pdf public ActionResult About() { ViewBag.Message = "Your application description page.";
return new MvcRazorToPdf.PdfActionResult("Asp");
}
i put a breakpoint in about page and it is successfully hit but finished with error
The document has no pages.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.IOException: The document has no pages.
This occurs when there is a problem with the view. Even when there is a breakpoint that is hit.
Can you post your view please. On Oct 27, 2014 4:08 AM, "Muhammad Zubair" notifications@github.com wrote:
i have the same error and i did nothing special. Created new mvc app and use about page to generate pdf public ActionResult About() { ViewBag.Message = "Your application description page.";
return new MvcRazorToPdf.PdfActionResult("Asp"); }
i put a breakpoint in about page and it is successfully hit but finished with error
The document has no pages.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.IOException: The document has no pages.
— Reply to this email directly or view it on GitHub https://github.com/andyhutch77/MvcRazorToPdf/issues/20#issuecomment-60560108 .
@model string @{ ViewBag.Title = Model; }
Use this area to provide additional information.
i have this simple view
I'll attempt to reproduce. On Oct 27, 2014 6:35 AM, "Muhammad Zubair" notifications@github.com wrote:
@model https://github.com/model string @{ ViewBag.Title = Model; } @ViewBag.Title.
@@ViewBag.Message@
Use this area to provide additional information.
i have this simple view
— Reply to this email directly or view it on GitHub https://github.com/andyhutch77/MvcRazorToPdf/issues/20#issuecomment-60574036 .
I see the latest mvc5 with razor 3.2 is having problem. Can you upgrade all libraries and try. Thanks
@ElanHasson @DafyddNZ @zubair1599 Sorry I am really short on time at the moment and I can't help with this but I will include/update the package if you guys get to the bottom of it before I get a chance to.
This happens when there is a compilation error in the view.
The bug is that we are swallowing the view compilation error, and passing a null view to the PDF renderer.
@andyhutch77 please mark this as bug and assign to me.
Lets run simple case. Create a simple mvc 5 project and include mvcrazor and itextsharp 5.5.3 and itextsharp-xml- worker 5.5.3. Convert home/ndex.cshtml into pdf. Please confirm its working.thanks
-----Original Message----- From: "Elan Hasson" notifications@github.com Sent: 29/10/2014 19:45 To: "andyhutch77/MvcRazorToPdf" MvcRazorToPdf@noreply.github.com Cc: "Muhammad Zubair" zubair1599@gmail.com Subject: Re: [MvcRazorToPdf] The document has no pages. (#20)
This happens when there is a compilation error in the view. The bug is that we are swallowing the view compilation error, and passing a null view to the PDF renderer. @andyhutch77 please mark this as bug and assign to me. — Reply to this email directly or view it on GitHub.=
@zubair1599 I'm using this exact version in production, just spent all day building a large PDF document.
It would be appreciated if you would build that simple project and zip up the code and post the URL here for me to download and debug. Thanks
I have attached one simple mvc5 app. I used home controller Contact method to generate PDF
public ActionResult Contact() { ViewBag.Message = "Your contact page."; var contact = new Contact() { Name = "John Doe", Phone = "118220202020" }; return new PdfActionResult(contact); }
kindly remove 1 from filename before unzip. Thanks
On Thu, Oct 30, 2014 at 1:07 AM, Mail Delivery Subsystem < mailer-daemon@googlemail.com> wrote:
Delivery to the following recipient failed permanently:
reply@reply.github.com
Technical details of permanent failure: Google tried to deliver your message, but it was rejected by the server for the recipient domain reply.github.com by github-smtp2-ext7.iad.github.net. [192.30.252.198].
The error that the other server returned was: 552 5.3.4 Message size exceeds fixed limit
----- Original message -----
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=tjJNTtc9E9XImP0qiYd2VE7Kdxg969yfgr8QhNVe4fk=;
b=x88s84GgtuS8uPpKuTLab/NUzcEx3XTpzN7A6N9L0yBifg5af2TELpiK686G3gKxgN
8LMBQnem03w/MUcYGUsErCAb1xJi92hRAhCHvgisKf2AoPHIG/ch7ZUNuvHDdTEDL64s
jyKkzcnM15R6faUeC274IpEkUfDgcmgKFC6MbZEKC4NswvRjEVF1OhbYQ6Z76GI03Og1
//jjCRNDJa7/l/+VXnS0nmMy9DnpIPrHi0lslmxUZp4e1K+UkKEYaSHqo+nJAVGT/eO7
vBZfpC/uhACch8v4Cv5sqFcnj5a16KUrR2rjgni+0rUU2I2MxqwMC/AtuWSmnqqYu9Y4 cOVQ== MIME-Version: 1.0 X-Received: by 10.180.101.200 with SMTP id fi8mr38654212wib.77.1414613217176; Wed, 29 Oct 2014 13:06:57 -0700 (PDT) Received: by 10.217.14.6 with HTTP; Wed, 29 Oct 2014 13:06:56 -0700 (PDT) In-Reply-To: andyhutch77/MvcRazorToPdf/issues/20/60986862@github.com References: andyhutch77/MvcRazorToPdf/issues/20@github.com andyhutch77/MvcRazorToPdf/issues/20/60986862@github.com Date: Thu, 30 Oct 2014 01:06:56 +0500 Message-ID:
Subject: Re: [MvcRazorToPdf] The document has no pages. (#20) From: zubair zubair1599@gmail.com To: "andyhutch77/MvcRazorToPdf" < reply@reply.github.com Cc: "andyhutch77/MvcRazorToPdf" MvcRazorToPdf@noreply.github.com Content-Type: multipart/mixed; boundary=f46d044280b6579c570506954ed1
I have attached one simple mvc5 app. I used home controller Contact method to generate PDF
public ActionResult Contact() { ViewBag.Message = "Your contact page."; var contact = new Contact() { Name = "John Doe", Phone = "118220202020" }; return new PdfActionResult(contact); }
you have to rename the attached file. Trim 1 in the the end of files.Thanks
On Thu, Oct 30, 2014 at 12:15 AM, Elan Hasson notifications@github.com wrote:
@zubair1599 https://github.com/zubair1599 I'm using this exact version in production, just spent all day building a large PDF document.
It would be appreciated if you would build that simple project and zip up the code and post the URL here for me to download and debug. Thanks
— Reply to this email directly or view it on GitHub < https://github.com/andyhutch77/MvcRazorToPdf/issues/20#issuecomment-60986862
.
File attachment didn't come through.. try using this site and posting the URL: http://www.filedropper.com/
http://www.filedropper.com/pdfgenerator
Here is the link Thanks
On Thu, Oct 30, 2014 at 1:45 AM, Elan Hasson notifications@github.com wrote:
File attachment didn't come through.. try using this site and posting the URL: http://www.filedropper.com/
— Reply to this email directly or view it on GitHub https://github.com/andyhutch77/MvcRazorToPdf/issues/20#issuecomment-61001693 .
@DafyddNZ you aren't passing in the model in tecData, you're passing documentFilename as the model `
@zubair1599 The problem is your _Layout.cshtml is incompatible with iTextWriter. Step 1 in the readme is to make a compatible layout: See https://github.com/andyhutch77/MvcRazorToPdf/blob/master/MvcRazorToPdfExample/Views/Shared/_PdfLayout.cshtml
Corrected project is here: http://www.filedropper.com/pdfgenerator_1
@andyhutch77 please close this issue.
@ElanHasson I was attempting to simplify the page to just get it to work, so I commented out all references to TECData in the view and used @model string
See the project I attached. Also sample project t works.
Most likely layout was incompatible with itextwriter On Oct 30, 2014 4:08 PM, "DafyddNZ" notifications@github.com wrote:
@ElanHasson https://github.com/ElanHasson I was attempting to simplify the page to just get it to work, so I commented out all references to TECData in the view and used @model https://github.com/model string
— Reply to this email directly or view it on GitHub https://github.com/andyhutch77/MvcRazorToPdf/issues/20#issuecomment-61160987 .
@ElanHasson Thanks.
I understand this is closed, but I am having the same problem and I am using the same layout that is available from the sample. I have pasted my entire html as it is displays without calling PdfActionResult(). As you can see this is very basic html. Is the problem the images? I don't expect the images to work in this post, but I would think they would work through my webpage and not throw this generic error.
Please look at your layout template.
Make sure you have the same structure and CSS classes applied. On Dec 2, 2014 5:51 PM, "lkeel75" notifications@github.com wrote:
I understand this is closed, but I am having the same problem and I am using the same layout that is available from the sample. I have pasted my entire html as it is displays without calling PdfActionResult(). As you can see this is very basic html. Is the problem the images?
MvcRazorToPdf
html
{
font-family: Arial;
}
h1
{
color: blue;
}
table {
border: 1px solid black;
border-spacing:0px;
}
table tr th {
background-color: gray;
color:white;
padding:2px;
}
table tr td {
margin:0px;
padding:2px;
}Student: * Letter, Word or Number Knowledge * Student Name Teacher: Mrs. TeacherName Language Arts:Identifies Lower Case Letters a b c d e f g h i j k l m n o p q r s t u v w x y z http:///Images/answer-incorrect-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png Language Arts:Identifies sounds of letters Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-incorrect-20.png Language Arts:Identifies Upper Case Letters A B C D E F G H I J K L M N O P Q R S T U V W X Y Z http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-incorrect-20.png Language Arts:Recognizes beginning sounds in words apple ball girl mouse tooth http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png Language Arts:Recognizes ending sounds in words bag bus duck girl tiger http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png Language Arts:Rhyming Words bug cake cat dog pig http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png Language Arts:Segments Words Into Individual Sounds bat frog nap sit trick http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png Language Arts:Sight Word Knowledge a and are can do go he I is like little my see the to we with http:///Images/answer-correct-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-correct-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-correct-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-incorrect-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png Math:Number Recognition 1 2 3 4 5 6 7 8 9 10 http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png Math:Recognizes 3D shapes cone cube cylinder sphere http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png http:///Images/answer-notanswered-20.png Math:Recognizes shapes circle oval rectangle rhombus square triangle http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png http:///Images/answer-correct-20.png
— Reply to this email directly or view it on GitHub https://github.com/andyhutch77/MvcRazorToPdf/issues/20#issuecomment-65320751 .
Thanks for your response. I am using the _PdfLayout.cshtml straight from the sample project. I have pasted the contents below. I am a little new to how all of this works but I believe that it is not inheriting any css classes or anything other than style implemented within the head.
@{ Layout = null; } <!DOCTYPE html>
@lkeel75 I'm sure the xmlworker only parses valid XHTML.
Try changing
to
I am sorry but that didn't come through on the comment
@lkeel75 I'm sure the xmlworker only parses valid XHTML.
The br tag is html not xhtml, it needs to be closing.
Sorry on a phone & code keeps being removed.
Ok. I think I understand what you mean. The problem is this editor. There are no br tags in my layout file nor in my generated html page. I am using the same layout file that is provided with the sample and you referenced above as step 1. So I don't think that is the problem.
@ikeel75 I see what you mean. Sorry but I'm struggling for time to look at what is happening with it. I didn't realise the test project was broken. Will answer as soon as I get a chance.
Please package up a small sample project that reproduces the issue and i'll take a look. On Dec 5, 2014 5:10 PM, "Andrew Hutchinson" notifications@github.com wrote:
@ikeel75 I see what you mean. Sorry but I'm struggling for time to look at what is happening with it. I didn't realise the test project was broken. Will answer as soon as I get a chance.
— Reply to this email directly or view it on GitHub https://github.com/andyhutch77/MvcRazorToPdf/issues/20#issuecomment-65862789 .
Have a zip for a sample project. How should I get it to you?
Just trying to find out how to get the sample project to you...
I still have not heard anything from this. Is there anyone out there having the same issue? Has anyone resolved this problem?
Hi @lkeel75, sorry I am really short of time both in and outside of work. I currently don't have any time to look at this. I will keep you updated if I get time or if someone else submits a pull request.
Hello, I am experiencing the same error using the same layout and just some basic html in my view.
I solved my solution by passing absolute path to the view when doing return new PdfActionResult I was using relative.
I want to thank everyone for their troubles. Lulli gave me the correct solution. Once I put the full path in my html to the images, then everything was working as I wanted. Thanks so much for your time and effort!
@lkeel75 Please you managed to get it sorted, I thought it was something a lot more complicated. The demo app has the absolute path and I thought you would have based it upon that. Sorry I didn't pick that up earlier.
I found a problem,which the PDF file can't show words properly except English words. Is there anyone who met this problem?
In my case I had itextsharp version 5.5.8.0 and itextsharp.xmlworker version 5.5.5 which was causing the error. I updated the itextsharp.xmlworker to version 5.5.8.0 and it fixed the error! Asp.net MVC 5.2.3.0 itextsharp 5.5.8.0 itextsharp.xmlworker 5.5.8.0
Hi I am trying to use the MvcRazorToPdf for the first time, but I get an Exception when using PdfActionResult.
[IOException: The document has no pages.] iTextSharp.text.pdf.PdfPages.WritePageTree() +1112 iTextSharp.text.pdf.PdfWriter.Close() +378 iTextSharp.text.Document.Close() +152 MvcRazorToPdf.MvcRazorToPdf.GeneratePdfOutput(ControllerContext context, Object model, String viewName, Actionb 1e(IAsyncResult asyncResult) +241
System.Web.Mvc.Controller.b1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoidb 5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
2 configureSettings) +837 MvcRazorToPdf.PdfActionResult.ExecuteResult(ControllerContext context) +555 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList
1 filters, ActionResult actionResult) +97 System.Web.Mvc.Async.<>cDisplayClass21.1.CallEndDelegate(IAsyncResult asyncResult) +111 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) +19 System.Web.Mvc.MvcHandler.Any ideas?