Tom
#28590

I just replaced with your code . Firstly document is getting generated with a size of 0kb by taking 10 sec to 12 secs time. When i try to open it obviously it is showing file is damaged.

if you want i can provide you my input html .

Please suggest the solution for this problem or give a conclusion on this regard. We need to tell the same to our client as soon as possible.

The following is the code i used

java.io.FileOutputStream fos = new java.io.FileOutputStream(outputPDFFile); PD4ML pd4ml = new PD4ML();
pd4ml.fitPageVertically();
pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.LEDGER)); // ledger page orientation
double desiredRatio = (double)PD4Constants.LEDGER.width / PD4Constants.LEDGER.height;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for ( int i = 0; i < 40; i++ ) { int width = 900 + (i * 20); pd4ml.setHtmlWidth( width ); pd4ml.render("file:" + inputHTMLFileName, baos); int height = ((Long)pd4ml.getLastRenderInfo(PD4Constants.PD4ML_DOCUMENT_HEIGHT_PX)).intValue(); //width = ((Long)pd4ml.getLastRenderInfo(PD4Constants.PD4ML_RIGHT_EDGE_PX)).intValue(); // for special cases double actualRatio = (double)width / height; if ( actualRatio < desiredRatio * 1.1 && actualRatio > desiredRatio * 0.9 ) {
break;
}

baos.reset();
}

fos.write( baos.toByteArray() );
fos.close();