.net - iTextSharp - Document has no pages when working with table -


    dim doc new document()     dim pdfwrite pdfwriter = pdfwriter.getinstance(doc, new filestream("invoice.pdf", filemode.create))     doc.open()      dim table new pdfptable(6)     table.widthpercentage = 110      dim celldate new pdfpcell(new phrase("9/10/14"))     celldate.colspan = 2     table.addcell(celldate)      dim cellcompany new pdfpcell(new phrase("company inc." & vbnewline & _                                                    "sales person" & vbnewline & _                                                    "123 s 150th road" & vbnewline & _                                                    "somecity, na 12345" & vbnewline & _                                                     "405.555.9999"))     celldate.colspan = 2     table.addcell(cellcompany)      dim cellinvoiceno new pdfpcell(new phrase("12345"))     celldate.colspan = 2     table.addcell(cellinvoiceno)      doc.add(table)     doc.close() 

after executing code "document has no pages" error. have found few others error issue forgot add table document, i'm not sure why i'm getting error.

more detail:

system.io.ioexception unhandled   hresult=-2146232800   message=the document has no pages.   source=itextsharp   stacktrace:        @ itextsharp.text.pdf.pdfpages.writepagetree()        @ itextsharp.text.pdf.pdfwriter.close()        @ itextsharp.text.pdf.pdfdocument.close()        @ itextsharp.text.document.close()        @ {project}.form1.btndoit_click(object sender, eventargs e) in c:\users\james\documents\visual studio 2013\projects\{project}\form1.vb:line 78        @ system.windows.forms.control.onclick(eventargs e)        @ system.windows.forms.control.wmmouseup(message& m, mousebuttons button, int32 clicks)        @ system.windows.forms.control.wndproc(message& m)        @ system.windows.forms.control.controlnativewindow.onmessage(message& m)        @ system.windows.forms.control.controlnativewindow.wndproc(message& m)        @ system.windows.forms.nativewindow.debuggablecallback(intptr hwnd, int32 msg, intptr wparam, intptr lparam)        @ system.windows.forms.unsafenativemethods.dispatchmessagew(msg& msg)        @ system.windows.forms.application.componentmanager.system.windows.forms.unsafenativemethods.imsocomponentmanager.fpushmessageloop(intptr dwcomponentid, int32 reason, int32 pvloopdata)        @ system.windows.forms.application.threadcontext.runmessageloopinner(int32 reason, applicationcontext context)        @ system.windows.forms.application.threadcontext.runmessageloop(int32 reason, applicationcontext context)        @ system.windows.forms.application.run(applicationcontext context)        @ microsoft.visualbasic.applicationservices.windowsformsapplicationbase.onrun()        @ microsoft.visualbasic.applicationservices.windowsformsapplicationbase.doapplicationmodel()        @ microsoft.visualbasic.applicationservices.windowsformsapplicationbase.run(string[] commandline)        @ {project}.my.myapplication.main(string[] args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81        @ system.appdomain._nexecuteassembly(runtimeassembly assembly, string[] args)        @ system.appdomain.executeassembly(string assemblyfile, evidence assemblysecurity, string[] args)        @ microsoft.visualstudio.hostingprocess.hostproc.runusersassembly()        @ system.threading.threadhelper.threadstart_context(object state)        @ system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)        @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)        @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state)        @ system.threading.threadhelper.threadstart()   innerexception:  

you asking itextsharp create 12 column table using 4 of columns, 3 cells 1 cell spanned 2 columns.

dim table new pdfptable(12) 

related, have glitch or copy , paste error because keep settings colspan on same variable on , over.

celldate.colspan = 2 ''//this in code 3 times 

itextsharp ignores incomplete rows default , since have single row , isn't complete have 0 content.

you can change column count in constructor you're going use:

dim table new pdfptable(4) 

if assumption typo correct want when fixed:

dim table new pdfptable(6) 

if you've got valid reason not use same number of columns specify can use right before adding table document "fill in blanks".

table.completerow() 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -