com.lowagie.text.pdf.PdfIndirectReference Java Examples

The following examples show how to use com.lowagie.text.pdf.PdfIndirectReference. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ITextPdfArray.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public long getObjectNumber(int i) {
	PdfObject pdfObject = wrapped.getPdfObject(i);
	if (pdfObject.isStream()) {
		PdfStream asStream = wrapped.getAsStream(i);
		return asStream.getIndRef().getNumber();
	} else if (pdfObject.isIndirect()) {
		PdfIndirectReference asIndirectObject = wrapped.getAsIndirectObject(i);
		return asIndirectObject.getNumber();
	}
	throw new DSSException("Not supported " + pdfObject);
}
 
Example #2
Source File: ChartPdfHandler.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
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 = 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);
	}
}
 
Example #3
Source File: Image.java    From gcs with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Getter for property directReference.
 * 
 * @return Value of property directReference.
 */
public PdfIndirectReference getDirectReference() {
	return directReference;
}
 
Example #4
Source File: Image.java    From gcs with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Setter for property directReference.
 * 
 * @param directReference New value of property directReference.
 */
public void setDirectReference(PdfIndirectReference directReference) {
	this.directReference = directReference;
}
 
Example #5
Source File: Image.java    From itext2 with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Getter for property directReference.
 * @return Value of property directReference.
 */
public PdfIndirectReference getDirectReference() {
    return this.directReference;
}
 
Example #6
Source File: Image.java    From itext2 with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Setter for property directReference.
 * @param directReference New value of property directReference.
 */
public void setDirectReference(PdfIndirectReference directReference) {
    this.directReference = directReference;
}