PDF Generating Tool Support Forum

HOME   Login   Register    Search




  Subject: PDF Pages are all blank
   PostPosted: 16 Feb 2013, 18:47 
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

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


Attachments:
File comment: Output PDF generated from code shown above.
WGBELabels(10).pdf [1.67 KiB]
Downloaded 427 times
  Subject: Re: PDF Pages are all blank
   PostPosted: 18 Feb 2013, 18:04 
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:
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();


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.



[Reply]     [ 2 posts ] 

cron
Copyright ©2004-10 zefer|org. All rights reserved. Bookmark and Share