@Override public void exportElement( JRPdfExporterContext exporterContext, JRGenericPrintElement element ) { try { JRPdfExporter exporter = (JRPdfExporter)exporterContext.getExporterRef(); exporter.exportImage(MapElementImageProvider.getImage(exporterContext.getJasperReportsContext(), element)); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) { PdfWriter writer = exporterContext.getPdfWriter(); JasperPrint jasperPrint = exporterContext.getExportedReport(); JRPrintText printText = (JRPrintText)element.getParameterValue(TextInputElement.PARAMETER_PRINT_TEXT_ELEMENT); if (printText == null) //FIXMEINPUT deal with xml serialization { return; } Rectangle rectangle = new Rectangle( element.getX() + exporterContext.getOffsetX(), jasperPrint.getPageHeight() - element.getY() - exporterContext.getOffsetY(), element.getX() + exporterContext.getOffsetX() + element.getWidth(), jasperPrint.getPageHeight() - element.getY() - exporterContext.getOffsetY() - element.getHeight() ); TextField text = new TextField(writer, rectangle, getFieldName(element)); Color backColor = printText.getBackcolor(); if(backColor != null){ text.setBackgroundColor(backColor); } Color forecolor = printText.getForecolor(); if(forecolor != null){ text.setTextColor(forecolor); } text.setText(printText.getFullText()); text.setDefaultText("default:" + printText.getFullText()); // text.setBackgroundColor(element.getBackcolor()); // text.setTextColor(element.getForecolor()); // text.setText(getText(element)); // text.setDefaultText(getDefaultText(element)); //FIXME: dynamic settings below: // text.setAlignment(Element.ALIGN_LEFT); // text.setBorderColor(Color.BLACK); // text.setBorderWidth(TextField.BORDER_WIDTH_THIN); // text.setBorderStyle(PdfBorderDictionary.STYLE_INSET); // text.setChoiceExports(null); // text.setChoices(null); // text.setChoiceSelection(0); // text.setExtensionFont(null); // text.setExtraMargin(0, 0); // try{ // text.setFont(BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1250, true)); // }catch(Exception e){ // throw new JRRuntimeException(e); // } text.setFontSize(printText.getFontsize()); if (Boolean.TRUE.equals(element.getParameterValue(TextInputElement.PARAMETER_MULTI_LINE))) { text.setOptions(TextField.MULTILINE); } // text.setRotation(90); text.setVisibility(TextField.VISIBLE); try{ PdfFormField field = text.getTextField(); writer.addAnnotation(field); }catch(Exception e){ throw new JRRuntimeException(e); } }
public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) { JRPdfExporter exporter = (JRPdfExporter)exporterContext.getExporterRef(); JRPrintText text = getTextElementReplacement(exporterContext, element); try { exporter.exportText(text); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) { try { JRPdfExporter exporter = (JRPdfExporter) exporterContext.getExporter(); JRPrintImage image = WmsMapElementImageProvider.getImage( exporterContext.getJasperReportsContext(), element); exporter.exportImage(image); } catch (Exception e) { throw new RuntimeException(e); } }
public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) { try { PdfWriter writer = exporterContext.getPdfWriter(); PdfIndirectObject swfRef; boolean newContext = !existingContexts.containsKey(exporterContext); if (newContext) { // add the Adobe 1.7 extensions catalog dictionary PdfDictionary extensions = new PdfDictionary(); PdfDictionary adobeExtension = new PdfDictionary(); adobeExtension.put(new PdfName("BaseVersion"), PdfWriter.PDF_VERSION_1_7); adobeExtension.put(new PdfName("ExtensionLevel"), new PdfNumber(3)); extensions.put(new PdfName("ADBE"), adobeExtension); writer.getExtraCatalog().put(new PdfName("Extensions"), extensions); // add the swf file byte[] swfData = readSwf(); PdfFileSpecification swfFile = PdfFileSpecification.fileEmbedded(writer, null, "Open Flash Chart", swfData); swfRef = writer.addToBody(swfFile); existingContexts.put(exporterContext, swfRef); } else { swfRef = (PdfIndirectObject) existingContexts.get(exporterContext); } Rectangle rect = new Rectangle(element.getX() + exporterContext.getOffsetX(), exporterContext.getExportedReport().getPageHeight() - element.getY() - exporterContext.getOffsetY(), element.getX() + exporterContext.getOffsetX() + element.getWidth(), exporterContext.getExportedReport().getPageHeight() - element.getY() - exporterContext.getOffsetY() - element.getHeight()); PdfAnnotation ann = new PdfAnnotation(writer, rect); ann.put(PdfName.SUBTYPE, new PdfName("RichMedia")); PdfDictionary settings = new PdfDictionary(); PdfDictionary activation = new PdfDictionary(); activation.put(new PdfName("Condition"), new PdfName("PV")); settings.put(new PdfName("Activation"), activation); ann.put(new PdfName("RichMediaSettings"), settings); PdfDictionary content = new PdfDictionary(); HashMap<String, PdfIndirectReference> assets = new HashMap<String, PdfIndirectReference>(); assets.put("map.swf", swfRef.getIndirectReference()); PdfDictionary assetsDictionary = PdfNameTree.writeTree(assets, writer); content.put(new PdfName("Assets"), assetsDictionary); PdfArray configurations = new PdfArray(); PdfDictionary configuration = new PdfDictionary(); PdfArray instances = new PdfArray(); PdfDictionary instance = new PdfDictionary(); instance.put(new PdfName("Subtype"), new PdfName("Flash")); PdfDictionary params = new PdfDictionary(); String chartData = (String) element.getParameterValue(PARAMETER_CHART_DATA); String vars = "inline_data=" + chartData; params.put(new PdfName("FlashVars"), new PdfString(vars)); instance.put(new PdfName("Params"), params); instance.put(new PdfName("Asset"), swfRef.getIndirectReference()); PdfIndirectObject instanceRef = writer.addToBody(instance); instances.add(instanceRef.getIndirectReference()); configuration.put(new PdfName("Instances"), instances); PdfIndirectObject configurationRef = writer.addToBody(configuration); configurations.add(configurationRef.getIndirectReference()); content.put(new PdfName("Configurations"), configurations); ann.put(new PdfName("RichMediaContent"), content); writer.addAnnotation(ann); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) { JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT); if (labelPrintText == null) //FIXMEINPUT deal with xml serialization { return; } JRBasePrintFrame frame = new JRBasePrintFrame(element.getDefaultStyleProvider()); frame.setX(element.getX()); frame.setY(element.getY()); frame.setWidth(element.getWidth()); frame.setHeight(element.getHeight()); frame.setStyle(element.getStyle()); frame.setBackcolor(element.getBackcolor()); frame.setForecolor(element.getForecolor()); frame.setMode(element.getModeValue()); JRLineBox lineBox = (JRLineBox)element.getParameterValue(IconLabelElement.PARAMETER_LINE_BOX); if (lineBox != null) { frame.copyBox(lineBox); } frame.addElement(labelPrintText); JRPrintText iconPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_ICON_TEXT_ELEMENT); if (iconPrintText != null) //FIXMEINPUT deal with xml serialization { frame.addElement(iconPrintText); } JRPdfExporter exporter = (JRPdfExporter)exporterContext.getExporterRef(); try { exporter.exportFrame(frame); } catch(Exception e) { throw new JRRuntimeException(e); } }
@Override public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) { Object eqaKey = element.getParameterValue("eqaKey"); PdfWriter pdfWriter = exporterContext.getPdfWriter(); PdfContentByte canvas = exporterContext.getPdfWriter().getDirectContentUnder(); canvas.saveState(); canvas.setLineWidth(0.2f); //canvas.setLineDash(3f); //canvas.setLineDash(0.5f, 0.1f); canvas.setColorStroke(Color.white); canvas.setColorFill(Color.white); int x = element.getX() + exporterContext.getOffsetX(); int y = exporterContext.getExportedReport().getPageHeight() - element.getY() - exporterContext.getOffsetY(); int x2 = x + element.getWidth(); int y2 = exporterContext.getExportedReport().getPageHeight() - element.getY() - exporterContext.getOffsetY() - element.getHeight(); int w = x2-x; int h = y-y2; if(log.isDebugEnabled()) log.debug("id="+eqaKey+" x="+x+",y="+y+",w="+w+",h="+h+""); canvas.ellipse(x,y,x2,y2); canvas.fillStroke(); canvas.restoreState(); canvas.saveState(); /* BaseFont bf; try { bf = BaseFont.createFont(); } catch (Exception e) { throw new RuntimeException("Erro ao tentar criar fonte",e); } canvas.setFontAndSize(bf, 10f); canvas.showText(" id="+obj); */ canvas.restoreState(); }
@Override public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) { try { PdfWriter writer = exporterContext.getPdfWriter(); PdfIndirectObject swfRef; boolean newContext = !existingContexts.containsKey(exporterContext); if (newContext) { PdfDictionary extensions = new PdfDictionary(); PdfDictionary adobeExtension = new PdfDictionary(); adobeExtension.put(new PdfName("BaseVersion"), PdfWriter.PDF_VERSION_1_7); adobeExtension.put(new PdfName("ExtensionLevel"), new PdfNumber(3)); extensions.put(new PdfName("ADBE"), adobeExtension); writer.getExtraCatalog().put(new PdfName("Extensions"), extensions); byte[] swfData = getChartSwf(); PdfFileSpecification swfFile = PdfFileSpecification.fileEmbedded(writer, null, "Open Flash Chart", swfData); swfRef = writer.addToBody(swfFile); existingContexts.put(exporterContext, swfRef); } else { swfRef = (PdfIndirectObject) existingContexts.get(exporterContext); } Rectangle rect = new Rectangle(element.getX() + exporterContext.getOffsetX(), exporterContext.getExportedReport().getPageHeight() - element.getY() - exporterContext.getOffsetY(), element.getX() + exporterContext.getOffsetX() + element.getWidth(), exporterContext.getExportedReport().getPageHeight() - element.getY() - exporterContext.getOffsetY() - element.getHeight()); PdfAnnotation ann = new PdfAnnotation(writer, rect); ann.put(PdfName.SUBTYPE, new PdfName("RichMedia")); PdfDictionary settings = new PdfDictionary(); PdfDictionary activation = new PdfDictionary(); activation.put(new PdfName("Condition"), new PdfName("PV")); settings.put(new PdfName("Activation"), activation); ann.put(new PdfName("RichMediaSettings"), settings); PdfDictionary content = new PdfDictionary(); HashMap<String, PdfIndirectReference> assets = new HashMap<String, PdfIndirectReference>(); assets.put("map.swf", swfRef.getIndirectReference()); PdfDictionary assetsDictionary = PdfNameTree.writeTree(assets, writer); content.put(new PdfName("Assets"), assetsDictionary); PdfArray configurations = new PdfArray(); PdfDictionary configuration = new PdfDictionary(); PdfArray instances = new PdfArray(); PdfDictionary instance = new PdfDictionary(); instance.put(new PdfName("Subtype"), new PdfName("Flash")); PdfDictionary params = new PdfDictionary(); String chartData = ((ChartGenerator) element.getParameterValue(ChartGenerator.PARAMETER_CHART_GENERATOR)).generateChart(); String vars = "inline_data=" + chartData; params.put(new PdfName("FlashVars"), new PdfString(vars)); instance.put(new PdfName("Params"), params); instance.put(new PdfName("Asset"), swfRef.getIndirectReference()); PdfIndirectObject instanceRef = writer.addToBody(instance); instances.add(instanceRef.getIndirectReference()); configuration.put(new PdfName("Instances"), instances); PdfIndirectObject configurationRef = writer.addToBody(configuration); configurations.add(configurationRef.getIndirectReference()); content.put(new PdfName("Configurations"), configurations); ann.put(new PdfName("RichMediaContent"), content); writer.addAnnotation(ann); } catch (Exception e) { throw new RuntimeException(e); } }