В документе нет страниц.
I got this error in online server, Exception Details: System.IO.IOException: The document has no pages.
Что я уже пробовал:
<pre><pre> byte[] bytes = null; var cssText = File.ReadAllText(MapPath("~/css/bootstrap.min.css")); //Read our HTML as a .Net stream using (var sr = new StringReader(htmlTable.ToString())) { //try //{ //Standard PDF setup using a MemoryStream, nothing special // using (var ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(cssText))) using (var ms = new MemoryStream()) { using (var pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f)) { //Bind a parser to our PDF document using (var htmlparser = new HTMLWorker(pdfDoc)) { //Bind the writer to our document and our final stream using (var w = PdfWriter.GetInstance(pdfDoc, ms)) { pdfDoc.Open(); //Parse the HTML directly into the document htmlparser.Parse(sr); pdfDoc.Close(); //Grab the bytes from the stream before closing it bytes = ms.ToArray(); } } } } //} //catch (Exception ex) //{ //} } //Assuming that the above worked we can now finally modify the HTTP response Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=xyz.pdf"); Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); //Send the bytes from the PDF Response.BinaryWrite(bytes); Response.End();
Richard MacCutchan
Где происходит ошибка?
sunil kumar
локально он работает , но ошибка в Интернете, я думаю, что ошибка здесь происходит
использование (var htmlparser = new HTMLWorker(pdfDoc))
Richard MacCutchan
Видеть itext - itextsharp HTMLWorker [устарел] - переполнение стека[^]
RickZeeland
Какую библиотеку PDF вы используете ?
Maciej Los
Похоже, что iTextSharp уже используется ;)
sunil kumar
с помощью iTextSharp.текст;
с помощью iTextSharp.текст.HTML-код.simpleparser;
с помощью iTextSharp.текст.формат PDF;