Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26815

    I’ve seen this question a couple of times when searching the forum, but no answers.

    I am brand new to PD4ML. I downloaded the probe yesterday and played with it quite a bit. It was generating the output as expected. So I downloaded the trial version (Java) and embedded it in my code. I do get a PDF document created. It appears to have the correct number of pages. But all of the pages are blank. Figuring it might be something in the HTML (even though the probe had no problem with the identical HTML), I reduced the html down to basically an H1 Helllo World. It produced 1 page as expected. But it was blank as well. Just to see if I was really controlling the converter, i changed the page size from LETTER to A4, and the next PDF correctly reflected the new page size.

    Since this a completely new integration of this product into my system, I’m sure I’m doing something wrong. But I can’t see it. I’ve got about 5 lines of Java code, and the only real difference between what I installed and the probe might be jar file version. I am running this inside a webapp in Tomcat 7.0. But I wouldn’t think that would make a difference. (I downloaded the current trial version yesterday, if you need the version number).

    My code is below, which includes the hardcoded test HTML. I’ve got the debug thing enabled. But it doesn’t appear to be generating anything (or I’m not looking in the right place). If there is any other info I can generrate/analyze, please let me know.

    I’m ready to purchase a license. But I’ve got to make sure it will work in my environment first.

    Thanks.

    Jerry

    public String getPDF()<br /> {<br /> StringReader html = new StringReader( "<html><body><h1>Hello</h1></body></html>" );<br /> ByteArrayOutputStream pdf = new ByteArrayOutputStream();<br /> PD4ML pd4ml = new PD4ML();<br /> try<br /> {<br /> pd4ml.useTTF("java:fonts", true);<br /> pd4ml.setPageSize( PD4Constants.A4);<br /> pd4ml.enableDebugInfo();<br /> pd4ml.render( html, pdf );<br /> }<br /> catch( Exception e)<br /> {<br /> e.printStackTrace( System.out );<br /> }<br /> return( pdf.toString() );<br /> }

    #29223

    It seems the binary PDF document data is corrupted. Usually that happens by a HTTP transfer, when an undesired character encoding conversion is applied to a binary PDF document.

    In PD4ML JSP taglib byte[] result PDF data is sent 2 ways:
    [language=java:3bo2snuj]sr.setContentLength(result.length);
    ServletOutputStream sos = sr.getOutputStream();
    if ( this.getEncoding() != null && this.getEncoding().equals(“default”) ) {
    sos.write(result);
    } else {
    sos.print( new String( result, “ISO8859_1” ) );
    }
    sos.close();[/language:3bo2snuj]

    Try both in your Tomcat app.

    Another more rare reason of such corruption is a replacement of UNIX-style new line characters with Win-style double chars. The problem may happen, but it is quite unlikely to face with in web scenarios.

Viewing 2 posts - 1 through 2 (of 2 total)

The forum ‘Troubleshooting’ is closed to new topics and replies.