java - FlyingSaucer setNamespaceAware to false -


compiling pdfrender class transforms html pdf got "premature end of file":

import com.lowagie.text.documentexception; import org.xhtmlrenderer.pdf.*; import org.xhtmlrenderer.resource.*; import org.w3c.dom.document; import org.xml.sax.inputsource;  import java.io.*;  public class pdfrender {      public static void main(string[] args) throws ioexception, documentexception     {          createpdf("/home/user/test.pdf", renderer.class.getresource("/resource/print/test.html").getpath());     }      public static void createpdf(string url, string pdf)             throws ioexception, documentexception     {         outputstream os = null;         try         {             os = new fileoutputstream(pdf);             itextrenderer renderer = new itextrenderer();             resourceloaderuseragent callback = new resourceloaderuseragent(renderer.getoutputdevice());             callback.setsharedcontext(renderer.getsharedcontext());             renderer.getsharedcontext().setuseragentcallback(callback);              document doc = xmlresource.load(new inputsource(url)).getdocument();              renderer.setdocument(doc, url);             renderer.layout();             renderer.createpdf(os);              os.close();             os = null;         }         catch(exception e)         {}     }      private static class resourceloaderuseragent extends itextuseragent     {          public resourceloaderuseragent(itextoutputdevice outputdevice)         {             super(outputdevice);         }          protected inputstream resolveandopenstream(string uri)         {             inputstream = super.resolveandopenstream(uri);             return is;         }     } } 

i use setnamespaceaware false snippet, code doesn't use documentbuilderfactory

documentbuilderfactory documentbuilderfactory =     documentbuilderfactory.newinstance(); documentbuilderfactory.setnamespaceaware(false); 

how can this?


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -