iText Java - Can't get the image show on pdf on html header -


i following example htmlheaderfooter.java creating pdf file has same header , footers on each page reason can't image display on pdf. it's blank needs show image.

i tried moving image on every single folder in case it's path issue no luck on either.

here example of code below.

package amt.view.pdf.section0;   import amt.methods;  import com.itextpdf.text.*;  import com.itextpdf.text.pdf.*;  import com.itextpdf.tool.xml.*;  import java.io.file;  import java.io.fileoutputstream;  import java.io.ioexception;  import java.sql.connection;  import java.sql.resultset;  import java.sql.sqlexception;    public class section0 {         static string customer;      static string customertitle;      static string refno;      static string revision;      static string refnotitle;      public static string dest;      public static final string userdesktop = system.getproperty("user.home") + "/desktop";       static string selectedid = "1";       public static void getvariables() throws sqlexception {          connection c = methods.chooseconnection();          string sql = "select * preset_values id '" + selectedid + "'";          resultset rs = c.createstatement().executequery(sql);          while (rs.next()) {              customer = rs.getstring("customer");              refno = rs.getstring("reference_no");              customertitle = rs.getstring("customer").replace(" ", "_");              refnotitle = rs.getstring("reference_no").replace(" ", "_");              revision = rs.getstring("revision");          }          dest = userdesktop + "/" + customertitle + "-" + refnotitle + "_rev-" + revision + ".pdf";       }        public static final string header = "<table width=\"100%\" border=\"0\"><tr><td><img src=\"logo.png\" /></td><td align=\"right\">some title</td></tr></table>";      public static final string footer = "<table width=\"100%\" border=\"0\"><tr><td>footer</td><td align=\"right\">some title</td></tr></table>";        public class headerfooter extends pdfpageeventhelper {           protected elementlist header;          protected elementlist footer;           public headerfooter() throws ioexception {              header = xmlworkerhelper.parsetoelementlist(header, "../headerfooter.css");              footer = xmlworkerhelper.parsetoelementlist(footer, null);          }           @          override          public void onendpage(pdfwriter writer, document document) {              try {                  columntext ct = new columntext(writer.getdirectcontent());                  ct.setsimplecolumn(new rectangle(36, 832, 559, 810));                  header.stream().foreach((e) - > {                      ct.addelement(e);                  });                  ct.go();                  ct.setsimplecolumn(new rectangle(36, 10, 559, 32));                  footer.stream().foreach((e) - > {                      ct.addelement(e);                  });                  ct.go();              } catch (documentexception de) {                  throw new exceptionconverter(de);              }          }      }       public static void main(string[] args) throws ioexception, documentexception, sqlexception {          getvariables();          file file = new file(dest);          file.getparentfile().mkdirs();          new section0().createpdf(dest);      }       public void createpdf(string filename) throws ioexception, documentexception {          // step 1          document document = new document(pagesize.a4, 36, 36, 36, 72);          // step 2          pdfwriter writer = pdfwriter.getinstance(document, new fileoutputstream(filename));          writer.setpageevent(new headerfooter());          // step 3          document.open();          // step 4          (int = 0; < 50; i++)              document.add(new paragraph(customer + "\n" + refno));          // step 5          document.close();      }  } 


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -