當前位置: 首頁>>代碼示例>>Java>>正文


Java JRPdfExporter.setExporterInput方法代碼示例

本文整理匯總了Java中net.sf.jasperreports.engine.export.JRPdfExporter.setExporterInput方法的典型用法代碼示例。如果您正苦於以下問題:Java JRPdfExporter.setExporterInput方法的具體用法?Java JRPdfExporter.setExporterInput怎麽用?Java JRPdfExporter.setExporterInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.jasperreports.engine.export.JRPdfExporter的用法示例。


在下文中一共展示了JRPdfExporter.setExporterInput方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: savePDFReportToOutputStream

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
 * Generates a PDF report from a pre-compiled report and returns it into an output stream.
 * 
 * @param jasperPrint
 *          JasperPrint object which contains a compiled report.
 * @param exportParameters
 *          Export parameters than can be added to configure the resulting report.
 * @param outputStream
 *          The output stream used to return the report.
 * @throws JRException
 *           In case there is any error generating the report an exception is thrown with the
 *           error message.
 */
public static void savePDFReportToOutputStream(JasperPrint jasperPrint,
    Map<Object, Object> exportParameters, OutputStream outputStream) throws JRException {
  if (exportParameters != null && exportParameters.size() > 0) {
    final JRPdfExporter exporter = new JRPdfExporter();
    SimpleExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
    SimpleOutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(
        outputStream);
    SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
    String jsContent = (String) exportParameters.get(PDF_JAVASCRIPT);
    if (jsContent != null) {
      configuration.setPdfJavaScript(jsContent);
    }
    exporter.setExporterInput(exporterInput);
    exporter.setExporterOutput(exporterOutput);
    exporter.setConfiguration(configuration);
    exporter.exportReport();
  } else {
    JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
  }
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:34,代碼來源:ReportingUtils.java

示例2: concatPDFReport

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
 * Returns a PDF file into an output stream as result of the concatenation of the JasperPrint
 * objects list passed as parameter.
 * 
 * @param jasperPrintList
 *          A list of JasperPrint objects.
 * @param createBookmarks
 *          A flag to indicate if the document should contain bookmarks, to mark the beginning of
 *          each individual document that was part of the initial document list.
 * @param outputStream
 *          The output stream used for returning the report.
 * @param reportConfiguration
 *          An optional configuration for the report.
 * @throws JRException
 *           In case there is any error compiling the report an exception is thrown with the error
 *           message.
 */
public static void concatPDFReport(List<JasperPrint> jasperPrintList, boolean createBookmarks,
    OutputStream outputStream, SimplePdfExporterConfiguration reportConfiguration)
    throws JRException {

  JRPdfExporter exporter = new JRPdfExporter();
  SimpleOutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(
      outputStream);
  SimplePdfExporterConfiguration configuration = reportConfiguration != null ? reportConfiguration
      : new SimplePdfExporterConfiguration();

  reportConfiguration.setCreatingBatchModeBookmarks(createBookmarks);
  exporter.setConfiguration(configuration);
  exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
  exporter.setExporterOutput(exporterOutput);

  exporter.exportReport();
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:35,代碼來源:ReportingUtils.java

示例3: concatPDFReportEncrypted

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
 * Returns an encrypted PDF file into an output stream as result of the concatenation of the
 * JasperPrint objects list passed as parameter.
 * 
 * @param jasperPrintList
 *          A list of JasperPrint objects.
 * @param createBookmarks
 *          A flag to indicate if the document should contain bookmarks, to mark the beginning of
 *          each individual document that was part of the initial document list.
 * @param userPassword
 *          A String that contains the user password of the resulting document.
 * @param ownerPassword
 *          A String that contains the owner password of the resulting document.
 * @param outputStream
 *          The output stream used for returning the report.
 * @throws JRException
 *           In case there is any error compiling the report an exception is thrown with the error
 *           message.
 */
public static void concatPDFReportEncrypted(List<JasperPrint> jasperPrintList,
    boolean createBookmarks, String userPassword, String ownerPassword, OutputStream outputStream)
    throws JRException {

  JRPdfExporter exporter = new JRPdfExporter();
  SimpleOutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(
      outputStream);
  SimplePdfExporterConfiguration reportConfiguration = new SimplePdfExporterConfiguration();

  reportConfiguration.setEncrypted(true);
  reportConfiguration.set128BitKey(true);
  reportConfiguration.setUserPassword(userPassword);
  reportConfiguration.setOwnerPassword(ownerPassword);
  reportConfiguration.setCreatingBatchModeBookmarks(createBookmarks);
  exporter.setConfiguration(reportConfiguration);
  exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
  exporter.setExporterOutput(exporterOutput);

  exporter.exportReport();
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:40,代碼來源:ReportingUtils.java

示例4: pdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
 *
 */
public void pdf() throws JRException
{
	long start = System.currentTimeMillis();
	
	JRPdfExporter exporter = new JRPdfExporter();
	
	exporter.setExporterInput(new SimpleExporterInput("build/reports/BookReport.jrprint"));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("build/reports/BookReport.pdf"));
	SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
	configuration.setCreatingBatchModeBookmarks(true);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();
	//JasperExportManager.exportReportToPdfFile("build/reports/BookReport.jrprint");
	System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:20,代碼來源:BookApp.java

示例5: pdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
 *
 */
public void pdf() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/PdfEncryptReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf");
	
	JRPdfExporter exporter = new JRPdfExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
	configuration.setEncrypted(true);
	configuration.set128BitKey(true);
	configuration.setUserPassword("jasper");
	configuration.setOwnerPassword("reports");
	configuration.setPermissions(PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING);
	exporter.setConfiguration(configuration);
	exporter.exportReport();

	System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:28,代碼來源:PdfEncryptApp.java

示例6: pdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
 *
 */
public void pdf() throws JRException
{
	long start = System.currentTimeMillis();
	List<JasperPrint> jasperPrintList = new ArrayList<JasperPrint>();
	jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report1.jrprint"));
	jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report2.jrprint"));
	jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report3.jrprint"));
	
	JRPdfExporter exporter = new JRPdfExporter();
	
	exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("build/reports/BatchExportReport.pdf"));
	SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
	configuration.setCreatingBatchModeBookmarks(true);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();
	
	System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:24,代碼來源:BatchExportApp.java

示例7: save

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
@Override
public void save(JasperPrint jasperPrint, File file) throws JRException
{
	if (!file.getName().toLowerCase().endsWith(EXTENSION_PDF))
	{
		file = new File(file.getAbsolutePath() + EXTENSION_PDF);
	}
	
	if (
		!file.exists() ||
		JOptionPane.OK_OPTION == 
			JOptionPane.showConfirmDialog(
				null, 
				MessageFormat.format(
					getBundleString("file.exists"),
					new Object[]{file.getName()}
					), 
				getBundleString("save"), 
				JOptionPane.OK_CANCEL_OPTION
				)
		)
	{
		JRPdfExporter exporter = new JRPdfExporter(getJasperReportsContext());
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); 
		exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(file));
		exporter.exportReport(); 
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:29,代碼來源:JRPdfSaveContributor.java

示例8: exportToPdfFile

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
 * Exports the generated report file specified by the first parameter into PDF format,
 * the result being placed in the second file parameter.
 *
 * @param jasperPrint  report object to export 
 * @param destFileName file name to place the PDF content into
 * @see net.sf.jasperreports.engine.export.JRPdfExporter
 */
public void exportToPdfFile(
	JasperPrint jasperPrint, 
	String destFileName
	) throws JRException
{
	/*   */
	JRPdfExporter exporter = new JRPdfExporter(jasperReportsContext);
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFileName));
	
	exporter.exportReport();
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:22,代碼來源:JasperExportManager.java

示例9: exportToPdfStream

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
 * Exports the generated report object received as first parameter into PDF format and
 * writes the results to the output stream specified by the second parameter.
 * 
 * @param jasperPrint  report object to export 
 * @param outputStream output stream to write the resulting PDF content to
 * @see net.sf.jasperreports.engine.export.JRPdfExporter
 */
public void exportToPdfStream(
	JasperPrint jasperPrint, 
	OutputStream outputStream
	) throws JRException
{
	JRPdfExporter exporter = new JRPdfExporter(jasperReportsContext);
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream));
	
	exporter.exportReport();
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:21,代碼來源:JasperExportManager.java

示例10: exportToPdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
 * Exports the generated report object received as parameter into PDF format and
 * returns the binary content as a byte array.
 * 
 * @param jasperPrint report object to export 
 * @return byte array representing the resulting PDF content 
 * @see net.sf.jasperreports.engine.export.JRPdfExporter
 */
public byte[] exportToPdf(JasperPrint jasperPrint) throws JRException
{
	ByteArrayOutputStream baos = new ByteArrayOutputStream();

	JRPdfExporter exporter = new JRPdfExporter(jasperReportsContext);
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos));
	
	exporter.exportReport();
	
	return baos.toByteArray();
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:22,代碼來源:JasperExportManager.java

示例11: export

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
@Override
public void export(JasperPrint jasper_print, OutputStream stream, SimpleReportExportConfiguration config,
		Map<String, byte[]> images) throws JRException
{
	JRPdfExporter exporter = new JRPdfExporter();
	exporter.setExporterInput(new SimpleExporterInput(jasper_print));
	exporter.setConfiguration((PdfReportConfiguration) config);
	SimpleOutputStreamExporterOutput output = new SimpleOutputStreamExporterOutput(stream);
	exporter.setExporterOutput(output);
	exporter.exportReport();
}
 
開發者ID:rlsutton1,項目名稱:VaadinUtils,代碼行數:12,代碼來源:JasperManager.java

示例12: pdf

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
 *
 */
public void pdf() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/StylesReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf");

	JRPdfExporter exporter = new JRPdfExporter();

	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));

	exporter.exportReport();

	System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:22,代碼來源:StylesApp.java

示例13: pdfa1

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
/**
	 * 
	 */
	public void pdfa1() throws JRException
	{
		long start = System.currentTimeMillis();

		try{
			ByteArrayOutputStream os = new ByteArrayOutputStream();

			JRPdfExporter exporter = new JRPdfExporter();
			exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(os));
			
			JasperPrint jp = (JasperPrint)JRLoader.loadObject(new File("build/reports/FirstJasper.jrprint"));
			
			// Exclude transparent images when exporting to PDF; elements marked with the key 'TransparentImage'
			// will be excluded from the exported PDF
			jp.setProperty("net.sf.jasperreports.export.pdf.exclude.key.TransparentImage", null);
			
			exporter.setExporterInput(new SimpleExporterInput(jp));
			
			SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
			
			// Include structure tags for PDF/A-1a compliance; unnecessary for PDF/A-1b
			configuration.setTagged(true);
			
			configuration.setPdfaConformance(PdfaConformanceEnum.PDFA_1A);
			
			// Uncomment the following line and specify a valid path for the ICC profile
//			configuration.setIccProfilePath("path/to/ICC/profile");
			
			exporter.setConfiguration(configuration);
			exporter.exportReport();

			FileOutputStream fos = new FileOutputStream("build/reports/FirstJasper_pdfa.pdf");
			os.writeTo(fos);
			fos.close();
		}catch(Exception e){
			 e.printStackTrace();
		}
				
		System.err.println("PDF/A-1a creation time : " + (System.currentTimeMillis() - start));
	}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:44,代碼來源:JasperApp.java

示例14: fillPDF

import net.sf.jasperreports.engine.export.JRPdfExporter; //導入方法依賴的package包/類
public ByteArrayOutputStream fillPDF(JasperPrint jasperPrint) throws Exception{
	ByteArrayOutputStream baos = new ByteArrayOutputStream();

	try{
		//JRPdfExporter exporter = new  JRPdfExporter();
		//exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
		
		StringBuilder javaScript = new StringBuilder("this.zoom=").append( "50" ).append(";")
			// Hide the Preferences menu item
			.append("app.hideMenuItem(\"GeneralPrefs\");")
			// Hide the Email and toolbar items
			.append("app.hideMenuItem(\"AcroSendMail:SendMail\");")
			.append("app.hideToolbarButton(\"AcroSendMail:SendMail\");")
			// Hide the Review Tracker
			.append("app.hideMenuItem(\"Annots:ReviewTracker\");")
			// Hide the Spelling Check menu item
			.append("app.hideMenuItem(\"Spelling:Spelling\");")
			// Hide the digital ID menu item
			.append("app.hideMenuItem(\"ppklite:UserSettings\");")
			.append("app.hideMenuItem(\"DIGSIG:DigitalSignatures\");")
			// Hide the Trusted Identities menu item
			.append("app.hideMenuItem(\"PUBSEC:AddressBook\");")
			// Turn off Auto-Complete
			.append("this.noautocomplete = true;")
			// Turn off Acrobat forms caching 
			.append("this.nocache = true;");

		List<JasperPrint> jasperPrintList = new ArrayList<JasperPrint>();
		jasperPrintList.add(jasperPrint);

		JRPdfExporter exporter = new JRPdfExporter();

		exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
		
		exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos));
		SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
		configuration.setCreatingBatchModeBookmarks(true);
		exporter.setConfiguration(configuration);

		exporter.exportReport();
		
		/*exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT, javaScript.toString() );
	    exporter.setParameter(JRPdfExporterParameter.OUTPUT_STREAM,baos); */
	    exporter.exportReport(); 
	    //JasperExportManager.exportReportToPdfStream(jasperPrint, baos);
	}catch (Throwable e){
		e.printStackTrace();
	}
	
	return baos;
}
 
開發者ID:ganzux,項目名稱:SIRME,代碼行數:52,代碼來源:GenerateReport.java


注:本文中的net.sf.jasperreports.engine.export.JRPdfExporter.setExporterInput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。