如何执行自动间距,以使文本填充整个div
而不会离开blank spaces
,文本是动态的,有时会很大,但是在其他小的文本中,{ {1}}的文字是您想要的,转换为html
时会丢失pdf
。
我正在使用:css style
,html2pdf-2.0.2
,jsoup-1.11.3
itextpdf-7.1.2
PdfWriter writer = new PdfWriter ( "path" );
PdfDocument pdf = new PdfDocument ( writer );
PdfMerger merger = new PdfMerger ( pdf );
Document document = Jsoup.parse ( listaHtml.get ( index ).replace ( "< !-- body", "body" ), "UTF-8" );
document.select ( "pre" ).first ( ).tagName ( "div" ).attr ( "style", "text-align: justify;text-align-last: justify;font-size: 0.9691em;margin-top: 5px; margin-bottom: 5px;" );
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream ( );
PdfDocument tempPagePdf = new PdfDocument ( new PdfWriter ( byteArrayOutputStream ) );
HtmlConverter.convertToPdf ( new ByteArrayInputStream ( document .toString ( ).getBytes ( StandardCharsets.UTF_8 ) ), tempPagePdf, properties );
tempPagePdf = new PdfDocument ( new PdfReader ( new ByteArrayInputStream ( byteArrayOutputStream.toByteArray ( ) ) ) );
merger.merge ( tempPagePdf , 1, tempPagePdf .getNumberOfPages ( ) );
tempPagePdf.close ( );
}
pdf.close ( );