public void testRichText() throws ReportProcessingException, ContentProcessingException { final Element e = new Element(); e.setElementType(LabelType.INSTANCE); e.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.RICH_TEXT_TYPE, "text/html"); e.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "Hi I am trying to use the <b>rich text type = text/html</b> in PRD version - 3.7."); e.getStyle().setStyleProperty(TextStyleKeys.FONTSIZE, 12); e.getStyle().setStyleProperty(TextStyleKeys.FONT, "Arial"); e.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 285f); e.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 20f); final MasterReport report = new MasterReport(); report.getReportHeader().addElement(e); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand(report, report.getReportHeader(), false, false); logicalPageBox.getRepeatFooterArea().setY(logicalPageBox.getContentArea().getHeight()); logicalPageBox.getFooterArea().setY(logicalPageBox.getContentArea().getHeight()); // ModelPrinter.INSTANCE.print(logicalPageBox); final RenderNode[] elementsByNodeType = MatchFactory.findElementsByNodeType(logicalPageBox, LayoutNodeTypes.TYPE_NODE_TEXT); assertEquals( 17, elementsByNodeType.length); // quick and easy way to see that all elements are there. // debugPrintText(elementsByNodeType); final LocalFontRegistry registry = new LocalFontRegistry(); registry.initialize(); final GraphicsOutputProcessorMetaData metaData = new GraphicsOutputProcessorMetaData(new DefaultFontStorage(registry)); metaData.initialize(report.getConfiguration()); final LogicalPageDrawable drawable = new LogicalPageDrawable(); drawable.init(logicalPageBox, metaData, report.getResourceManager()); final TracingGraphics g2 = new TracingGraphics(); drawable.draw(g2, new Rectangle2D.Double(0, 0, 500, 500)); /* for (int i = 0; i < g2.records.size(); i++) { final TextTraceRecord record = g2.records.get(i); System.out.println ("goldenSamples.add(new TextTraceRecord(" + record.x + ", " + record.y + ", \"" + record.text +"\"));"); } */ assertEquals(getSamples(), g2.records); }
protected void finishInlineBox(final InlineRenderBox box) { if (box.getStaticBoxLayoutProperties().isVisible()) { return; } if (box.isBoxVisible(getDrawArea()) == false) { return; } final PdfTextSpec textSpec = (PdfTextSpec) getTextSpec(); if (textSpec != null) { textSpec.finishText(); } super.finishInlineBox(box); }
public void init( final LogicalPageBox rootBox, final PdfOutputProcessorMetaData metaData, final ResourceManager resourceManager, final PhysicalPageBox page) { super.init(rootBox, metaData, resourceManager); if (page != null) { this.globalHeight = (float) StrictGeomUtility.toExternalValue( page.getHeight() - page.getImageableY() + page.getGlobalY()); } else { this.globalHeight = rootBox.getPageHeight(); } this.globalEmbed = getMetaData().isFeatureSupported(OutputProcessorFeature.EMBED_ALL_FONTS); }
/** * Draws the object. * * @param graphics the graphics device. * @param area the area inside which the object should be drawn. */ public void draw(final Graphics2D graphics, final Rectangle2D area) { super.draw(graphics, area); }