List of usage examples for com.lowagie.text.rtf RtfBasicElement TWIPS_FACTOR
double TWIPS_FACTOR
To view the source code for com.lowagie.text.rtf RtfBasicElement TWIPS_FACTOR.
Click Source Link
From source file:com.mirth.connect.connectors.doc.DocumentDispatcher.java
License:Open Source License
private void createRTF(InputStream inputStream, OutputStream outputStream, DocumentDispatcherProperties props) throws Exception { com.lowagie.text.Document document = null; try {/* www . java2s . com*/ document = new com.lowagie.text.Document(); //TODO verify the character encoding RtfWriter2.getInstance(document, outputStream); document.open(); try { double width = Double.parseDouble(props.getPageWidth()); double height = Double.parseDouble(props.getPageHeight()); Unit unit = props.getPageUnit(); /* * The version of iText being used only accepts points, so we need to convert to * twips first and then convert to points (1 point = 20 twips). */ if (unit != Unit.TWIPS) { width = unit.convertTo(width, Unit.TWIPS); height = unit.convertTo(height, Unit.TWIPS); unit = Unit.TWIPS; } width = Math.max(width, 1); height = Math.max(height, 1); document.setPageSize(new Rectangle((float) (Math.round(width) / RtfBasicElement.TWIPS_FACTOR), (float) (Math.round(height) / RtfBasicElement.TWIPS_FACTOR))); } catch (Exception e) { } HtmlParser parser = new HtmlParser(); parser.go(document, inputStream); } finally { if (document != null) { document.close(); } } }