Java Code Examples for com.lowagie.text.pdf.PdfString

The following examples show how to use com.lowagie.text.pdf.PdfString. These examples are extracted from open source projects. 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 Project: gcs   Source File: PdfContentStreamProcessor.java    License: Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList operands) {
	PdfNumber aw = (PdfNumber) operands.get(0);
	PdfNumber ac = (PdfNumber) operands.get(1);
	PdfString string = (PdfString) operands.get(2);

	ArrayList twOperands = new ArrayList(1);
	twOperands.add(0, aw);
	processor.invokeOperator(new PdfLiteral("Tw"), twOperands);

	ArrayList tcOperands = new ArrayList(1);
	tcOperands.add(0, ac);
	processor.invokeOperator(new PdfLiteral("Tc"), tcOperands);

	ArrayList tickOperands = new ArrayList(1);
	tickOperands.add(0, string);
	processor.invokeOperator(new PdfLiteral("'"), tickOperands);
}
 
Example 2
Source Project: gcs   Source File: PdfXConformanceImp.java    License: Mozilla Public License 2.0 6 votes vote down vote up
public void completeInfoDictionary(PdfDictionary info) {
    if (isPdfX() && !isPdfA1()) {
        if (info.get(PdfName.GTS_PDFXVERSION) == null) {
            if (isPdfX1A2001()) {
                info.put(PdfName.GTS_PDFXVERSION, new PdfString("PDF/X-1:2001"));
                info.put(new PdfName("GTS_PDFXConformance"), new PdfString("PDF/X-1a:2001"));
            }
            else if (isPdfX32002())
                info.put(PdfName.GTS_PDFXVERSION, new PdfString("PDF/X-3:2002"));
        }
        if (info.get(PdfName.TITLE) == null) {
            info.put(PdfName.TITLE, new PdfString("Pdf document"));
        }
        if (info.get(PdfName.CREATOR) == null) {
            info.put(PdfName.CREATOR, new PdfString("Unknown"));
        }
        if (info.get(PdfName.TRAPPED) == null) {
            info.put(PdfName.TRAPPED, new PdfName("False"));
        }
    }
}
 
Example 3
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList operands) {
	PdfNumber aw = (PdfNumber) operands.get(0);
	PdfNumber ac = (PdfNumber) operands.get(1);
	PdfString string = (PdfString) operands.get(2);

	ArrayList twOperands = new ArrayList(1);
	twOperands.add(0, aw);
	processor.invokeOperator(new PdfLiteral("Tw"), twOperands);

	ArrayList tcOperands = new ArrayList(1);
	tcOperands.add(0, ac);
	processor.invokeOperator(new PdfLiteral("Tc"), tcOperands);

	ArrayList tickOperands = new ArrayList(1);
	tickOperands.add(0, string);
	processor.invokeOperator(new PdfLiteral("'"), tickOperands);
}
 
Example 4
public void completeInfoDictionary(PdfDictionary info) {
    if (isPdfX() && !isPdfA1()) {
        if (info.get(PdfName.GTS_PDFXVERSION) == null) {
            if (isPdfX1A2001()) {
                info.put(PdfName.GTS_PDFXVERSION, new PdfString("PDF/X-1:2001"));
                info.put(new PdfName("GTS_PDFXConformance"), new PdfString("PDF/X-1a:2001"));
            }
            else if (isPdfX32002())
                info.put(PdfName.GTS_PDFXVERSION, new PdfString("PDF/X-3:2002"));
        }
        if (info.get(PdfName.TITLE) == null) {
            info.put(PdfName.TITLE, new PdfString("Pdf document"));
        }
        if (info.get(PdfName.CREATOR) == null) {
            info.put(PdfName.CREATOR, new PdfString("Unknown"));
        }
        if (info.get(PdfName.TRAPPED) == null) {
            info.put(PdfName.TRAPPED, new PdfName("False"));
        }
    }
}
 
Example 5
@Override
public void draw()
{
	if (addActualText)
	{
		PdfDictionary markedContentProps = new PdfDictionary();
		markedContentProps.put(PdfName.ACTUALTEXT, new PdfString(allText, PdfObject.TEXT_UNICODE));
		pdfContentByte.beginMarkedContentSequence(PdfName.SPAN, markedContentProps, true);
	}
	
	TabSegment segment = segments.get(segmentIndex);
	segment.layout.draw(
			pdfGraphics2D,
			x + drawPosX,// + leftPadding,
			y + topPadding + verticalAlignOffset + drawPosY
			);
	
	if (addActualText)
	{
		pdfContentByte.endMarkedContentSequence();
	}
	
	return;
}
 
Example 6
Source Project: gcs   Source File: PdfContentStreamProcessor.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList operands) {
	PdfArray array = (PdfArray) operands.get(0);
	float tj = 0;
	for (Iterator i = array.listIterator(); i.hasNext();) {
		Object entryObj = i.next();
		if (entryObj instanceof PdfString) {
			processor.displayPdfString((PdfString) entryObj, tj);
			tj = 0;
		} else {
			tj = ((PdfNumber) entryObj).floatValue();
		}
	}

}
 
Example 7
Source Project: gcs   Source File: PdfAnnotationsImp.java    License: Mozilla Public License 2.0 5 votes vote down vote up
public static PdfAnnotation convertAnnotation(PdfWriter writer, Annotation annot, Rectangle defaultRect) throws IOException {
	switch (annot.annotationType()) {
		case Annotation.URL_NET:
			return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((URL) annot.attributes().get(Annotation.URL)));
		case Annotation.URL_AS_STRING:
			return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE)));
		case Annotation.FILE_DEST:
			return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), (String) annot.attributes().get(Annotation.DESTINATION)));
		case Annotation.SCREEN:
			boolean sparams[] = (boolean[]) annot.attributes().get(Annotation.PARAMETERS);
			String fname = (String) annot.attributes().get(Annotation.FILE);
			String mimetype = (String) annot.attributes().get(Annotation.MIMETYPE);
			PdfFileSpecification fs;
			if (sparams[0]) {
				fs = PdfFileSpecification.fileEmbedded(writer, fname, fname, null);
			} else {
				fs = PdfFileSpecification.fileExtern(writer, fname);
			}
			PdfAnnotation ann = PdfAnnotation.createScreen(writer, new Rectangle(annot.llx(), annot.lly(), annot.urx(), annot.ury()), fname, fs, mimetype, sparams[1]);
			return ann;
		case Annotation.FILE_PAGE:
			return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), ((Integer) annot.attributes().get(Annotation.PAGE)).intValue()));
		case Annotation.NAMED_DEST:
			return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction(((Integer) annot.attributes().get(Annotation.NAMED)).intValue()));
		case Annotation.LAUNCH:
			return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.APPLICATION), (String) annot.attributes().get(Annotation.PARAMETERS), (String) annot.attributes().get(Annotation.OPERATION), (String) annot.attributes().get(Annotation.DEFAULTDIR)));
		default:
			return new PdfAnnotation(writer, defaultRect.getLeft(), defaultRect.getBottom(), defaultRect.getRight(), defaultRect.getTop(), new PdfString(annot.title(), PdfObject.TEXT_UNICODE), new PdfString(annot.content(), PdfObject.TEXT_UNICODE));
	}
}
 
Example 8
Source Project: gcs   Source File: PdfXConformanceImp.java    License: Mozilla Public License 2.0 5 votes vote down vote up
public void completeExtraCatalog(PdfDictionary extraCatalog) {
    if (isPdfX() && !isPdfA1()) {
        if (extraCatalog.get(PdfName.OUTPUTINTENTS) == null) {
            PdfDictionary out = new PdfDictionary(PdfName.OUTPUTINTENT);
            out.put(PdfName.OUTPUTCONDITION, new PdfString("SWOP CGATS TR 001-1995"));
            out.put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString("CGATS TR 001"));
            out.put(PdfName.REGISTRYNAME, new PdfString("http://www.color.org"));
            out.put(PdfName.INFO, new PdfString(""));
            out.put(PdfName.S, PdfName.GTS_PDFX);
            extraCatalog.put(PdfName.OUTPUTINTENTS, new PdfArray(out));
        }
    }
}
 
Example 9
Source Project: gcs   Source File: BmpImage.java    License: Mozilla Public License 2.0 5 votes vote down vote up
private Image indexedModel(byte bdata[], int bpc, int paletteEntries) throws BadElementException {
	Image img = new ImgRaw(width, height, 1, bpc, bdata);
	PdfArray colorspace = new PdfArray();
	colorspace.add(PdfName.INDEXED);
	colorspace.add(PdfName.DEVICERGB);
	byte np[] = getPalette(paletteEntries);
	int len = np.length;
	colorspace.add(new PdfNumber(len / 3 - 1));
	colorspace.add(new PdfString(np));
	PdfDictionary ad = new PdfDictionary();
	ad.put(PdfName.COLORSPACE, colorspace);
	img.setAdditional(ad);
	return img;
}
 
Example 10
Source Project: gcs   Source File: PdfCollectionField.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Creates a PdfCollectionField.
 * @param name		the field name
 * @param type		the field type
 */
public PdfCollectionField(String name, int type) {
	super(PdfName.COLLECTIONFIELD);
	put(PdfName.N, new PdfString(name, PdfObject.TEXT_UNICODE));
	this.fieldType = type;
	switch(type) {
	default:
		put(PdfName.SUBTYPE, PdfName.S);
		break;
	case DATE:
		put(PdfName.SUBTYPE, PdfName.D);
		break;
	case NUMBER:
		put(PdfName.SUBTYPE, PdfName.N);
		break;
	case FILENAME:
		put(PdfName.SUBTYPE, PdfName.F);
		break;
	case DESC:
		put(PdfName.SUBTYPE, PdfName.DESC);
		break;
	case MODDATE:
		put(PdfName.SUBTYPE, PdfName.MODDATE);
		break;
	case CREATIONDATE:
		put(PdfName.SUBTYPE, PdfName.CREATIONDATE);
		break;
	case SIZE:
		put(PdfName.SUBTYPE, PdfName.SIZE);
		break;
	}
}
 
Example 11
Source Project: gcs   Source File: PdfCollectionField.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Returns a PdfObject that can be used as the value of a Collection Item.
 * @param v	value	the value that has to be changed into a PdfObject (PdfString, PdfDate or PdfNumber)	
 */
public PdfObject getValue(String v) {
	switch(fieldType) {
	case TEXT:
		return new PdfString(v, PdfObject.TEXT_UNICODE);
	case DATE:
		return new PdfDate(PdfDate.decode(v));
	case NUMBER:
		return new PdfNumber(v);
	}
	throw new IllegalArgumentException(v + " is not an acceptable value for the field " + get(PdfName.N).toString());
}
 
Example 12
Source Project: gcs   Source File: PdfCollectionItem.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Sets the value of the collection item.
 * @param value
 */
public void addItem(String key, PdfString value) {
	PdfName fieldname = new PdfName(key);
	PdfCollectionField field = (PdfCollectionField)schema.get(fieldname);
	if (field.fieldType == PdfCollectionField.TEXT) {
		put(fieldname, value);
	}
}
 
Example 13
Source Project: gcs   Source File: PdfCollectionItem.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Adds a prefix for the Collection item.
 * You can only use this method after you have set the value of the item.
 * @param prefix	a prefix
 */
public void setPrefix(String key, String prefix) {
	PdfName fieldname = new PdfName(key);
	PdfObject o = get(fieldname);
	if (o == null)
		throw new IllegalArgumentException("You must set a value before adding a prefix.");
	PdfDictionary dict = new PdfDictionary(PdfName.COLLECTIONSUBITEM);
	dict.put(PdfName.D, o);
	dict.put(PdfName.P, new PdfString(prefix, PdfObject.TEXT_UNICODE));
	put(fieldname, dict);
}
 
Example 14
/**
    * Displays text.
    * @param string	the text to display
    * @param tj		the text adjustment
    */
public void displayPdfString(PdfString string, float tj) {
	String unicode = decode(string);
	// this is width in unscaled units - we have to normalize by the Tm scaling
	float width = getStringWidth(unicode, tj);
	Matrix nextTextMatrix = new Matrix(width, 0).multiply(textMatrix);
	displayText(unicode, nextTextMatrix);
	textMatrix = nextTextMatrix;
}
 
Example 15
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList operands) {
	PdfArray array = (PdfArray) operands.get(0);
	float tj = 0;
	for (Iterator i = array.listIterator(); i.hasNext();) {
		Object entryObj = i.next();
		if (entryObj instanceof PdfString) {
			processor.displayPdfString((PdfString) entryObj, tj);
			tj = 0;
		} else {
			tj = ((PdfNumber) entryObj).floatValue();
		}
	}

}
 
Example 16
public static PdfAnnotation convertAnnotation(PdfWriter writer, Annotation annot, Rectangle defaultRect) throws IOException {
     switch(annot.annotationType()) {
        case Annotation.URL_NET:
            return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((URL) annot.attributes().get(Annotation.URL)));
        case Annotation.URL_AS_STRING:
            return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE)));
        case Annotation.FILE_DEST:
            return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), (String) annot.attributes().get(Annotation.DESTINATION)));
        case Annotation.SCREEN:
            boolean sparams[] = (boolean[])annot.attributes().get(Annotation.PARAMETERS);
            String fname = (String) annot.attributes().get(Annotation.FILE);
            String mimetype = (String) annot.attributes().get(Annotation.MIMETYPE);
            PdfFileSpecification fs;
            if (sparams[0])
                fs = PdfFileSpecification.fileEmbedded(writer, fname, fname, null);
            else
                fs = PdfFileSpecification.fileExtern(writer, fname);
            PdfAnnotation ann = PdfAnnotation.createScreen(writer, new Rectangle(annot.llx(), annot.lly(), annot.urx(), annot.ury()),
                    fname, fs, mimetype, sparams[1]);
            return ann;
        case Annotation.FILE_PAGE:
            return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), ((Integer) annot.attributes().get(Annotation.PAGE)).intValue()));
        case Annotation.NAMED_DEST:
            return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction(((Integer) annot.attributes().get(Annotation.NAMED)).intValue()));
        case Annotation.LAUNCH:
            return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.APPLICATION),(String) annot.attributes().get(Annotation.PARAMETERS),(String) annot.attributes().get(Annotation.OPERATION),(String) annot.attributes().get(Annotation.DEFAULTDIR)));
        default:
     	   return new PdfAnnotation(writer, defaultRect.getLeft(), defaultRect.getBottom(), defaultRect.getRight(), defaultRect.getTop(), new PdfString(annot.title(), PdfObject.TEXT_UNICODE), new PdfString(annot.content(), PdfObject.TEXT_UNICODE));
    }
}
 
Example 17
public void completeExtraCatalog(PdfDictionary extraCatalog) {
    if (isPdfX() && !isPdfA1()) {
        if (extraCatalog.get(PdfName.OUTPUTINTENTS) == null) {
            PdfDictionary out = new PdfDictionary(PdfName.OUTPUTINTENT);
            out.put(PdfName.OUTPUTCONDITION, new PdfString("SWOP CGATS TR 001-1995"));
            out.put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString("CGATS TR 001"));
            out.put(PdfName.REGISTRYNAME, new PdfString("http://www.color.org"));
            out.put(PdfName.INFO, new PdfString(""));
            out.put(PdfName.S, PdfName.GTS_PDFX);
            extraCatalog.put(PdfName.OUTPUTINTENTS, new PdfArray(out));
        }
    }
}
 
Example 18
Source Project: itext2   Source File: BmpImage.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private Image indexedModel(byte bdata[], int bpc, int paletteEntries) throws BadElementException {
    Image img = new ImgRaw(width, height, 1, bpc, bdata);
    PdfArray colorspace = new PdfArray();
    colorspace.add(PdfName.INDEXED);
    colorspace.add(PdfName.DEVICERGB);
    byte np[] = getPalette(paletteEntries);
    int len = np.length;
    colorspace.add(new PdfNumber(len / 3 - 1));
    colorspace.add(new PdfString(np));
    PdfDictionary ad = new PdfDictionary();
    ad.put(PdfName.COLORSPACE, colorspace);
    img.setAdditional(ad);
    return img;
}
 
Example 19
/**
 * Creates a PdfCollectionField.
 * @param name		the field name
 * @param type		the field type
 */
public PdfCollectionField(String name, int type) {
	super(PdfName.COLLECTIONFIELD);
	put(PdfName.N, new PdfString(name, PdfObject.TEXT_UNICODE));
	this.fieldType = type;
	switch(type) {
	default:
		put(PdfName.SUBTYPE, PdfName.S);
		break;
	case DATE:
		put(PdfName.SUBTYPE, PdfName.D);
		break;
	case NUMBER:
		put(PdfName.SUBTYPE, PdfName.N);
		break;
	case FILENAME:
		put(PdfName.SUBTYPE, PdfName.F);
		break;
	case DESC:
		put(PdfName.SUBTYPE, PdfName.DESC);
		break;
	case MODDATE:
		put(PdfName.SUBTYPE, PdfName.MODDATE);
		break;
	case CREATIONDATE:
		put(PdfName.SUBTYPE, PdfName.CREATIONDATE);
		break;
	case SIZE:
		put(PdfName.SUBTYPE, PdfName.SIZE);
		break;
	}
}
 
Example 20
/**
 * Returns a PdfObject that can be used as the value of a Collection Item.
 * @param v	value	the value that has to be changed into a PdfObject (PdfString, PdfDate or PdfNumber)	
 */
public PdfObject getValue(String v) {
	switch(fieldType) {
	case TEXT:
		return new PdfString(v, PdfObject.TEXT_UNICODE);
	case DATE:
		return new PdfDate(PdfDate.decode(v));
	case NUMBER:
		return new PdfNumber(v);
	}
	throw new IllegalArgumentException(v + " is not an acceptable value for the field " + get(PdfName.N).toString());
}
 
Example 21
/**
 * Sets the value of the collection item.
 * @param value
 */
public void addItem(String key, PdfString value) {
	PdfName fieldname = new PdfName(key);
	PdfCollectionField field = (PdfCollectionField)schema.get(fieldname);
	if (field.fieldType == PdfCollectionField.TEXT) {
		put(fieldname, value);
	}
}
 
Example 22
/**
 * Adds a prefix for the Collection item.
 * You can only use this method after you have set the value of the item.
 * @param prefix	a prefix
 */
public void setPrefix(String key, String prefix) {
	PdfName fieldname = new PdfName(key);
	PdfObject o = get(fieldname);
	if (o == null)
		throw new IllegalArgumentException("You must set a value before adding a prefix.");
	PdfDictionary dict = new PdfDictionary(PdfName.COLLECTIONSUBITEM);
	dict.put(PdfName.D, o);
	dict.put(PdfName.P, new PdfString(prefix, PdfObject.TEXT_UNICODE));
	put(fieldname, dict);
}
 
Example 23
/**
 *
 */
protected void init(PdfContentByte pdfContentByte)
{
	this.pdfContentByte = pdfContentByte;
	
	if (isTagged)
	{
		PdfStructureTreeRoot root = pdfWriter.getStructureTreeRoot();
		
		PdfName pdfNameALL = new PdfName("All");
		root.mapRole(pdfNameALL, PdfName.SECT);
		root.mapRole(PdfName.IMAGE, PdfName.FIGURE);
		root.mapRole(PdfName.TEXT, PdfName.TEXT);
		allTag = new PdfStructureElement(root, pdfNameALL);
		if(pdfWriter.getPDFXConformance() == PdfWriter.PDFA1A)
		{
			root.mapRole(new PdfName("Anchor"), PdfName.NONSTRUCT);
			root.mapRole(PdfName.TEXT, PdfName.SPAN);
		}
		else
		{
			root.mapRole(new PdfName("Anchor"), PdfName.TEXT);
		}
		
		if (language != null)
		{
			allTag.put(PdfName.LANG, new PdfString(language));
		}
		tagStack = new Stack<PdfStructureElement>();
		tagStack.push(allTag);
	}
}
 
Example 24
protected void startImage(JRPrintImage printImage)
{
	if (isTagged)
	{
		PdfStructureElement imageTag = new PdfStructureElement(allTag, PdfName.IMAGE);
		pdfContentByte.beginMarkedContentSequence(imageTag);
		if (printImage.getHyperlinkTooltip() != null)
		{
			imageTag.put(PdfName.ALT, new PdfString(printImage.getHyperlinkTooltip()));
		}
	}
}
 
Example 25
protected void startText(String text, boolean isHyperlink)
{
	if (isTagged)
	{
		PdfDictionary markedContentProps = new PdfDictionary();
		markedContentProps.put(PdfName.ACTUALTEXT, new PdfString(text, PdfObject.TEXT_UNICODE));
		PdfStructureElement textTag = new PdfStructureElement(tagStack.peek(), isHyperlink ? PdfName.LINK : PdfName.TEXT);
		// the following method is part of the patched iText
		pdfContentByte.beginMarkedContentSequence(textTag, markedContentProps);
	}
}
 
Example 26
@Override
public DSSDocument sign(DSSDocument toSignDocument, byte[] signatureValue, PAdESCommonParameters parameters) {

	checkDocumentPermissions(toSignDocument, parameters.getPasswordProtection());

	try (InputStream is = toSignDocument.openStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
		PdfStamper stp = prepareStamper(is, baos, parameters);
		PdfSignatureAppearance sap = stp.getSignatureAppearance();

		byte[] pk = signatureValue;
		int csize = parameters.getContentSize();
		if (csize < pk.length) {
			throw new DSSException(
					String.format("The signature size [%s] is too small for the signature value with a length [%s]",
							csize, pk.length));
		}

		byte[] outc = new byte[csize];
		System.arraycopy(pk, 0, outc, 0, pk.length);

		PdfDictionary dic = new PdfDictionary();
		dic.put(PdfName.CONTENTS, new PdfString(outc).setHexWriting(true));
		sap.close(dic);

		DSSDocument signature = new InMemoryDocument(baos.toByteArray());
		signature.setMimeType(MimeType.PDF);
		return signature;
	} catch (Exception e) {
		throw new DSSException(e);
	}
}
 
Example 27
Source Project: dss   Source File: ITextPdfDict.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public byte[] getBinariesValue(String name) {
	PdfObject val = wrapped.get(new PdfName(name));
	if (val == null) {
		return null;
	} else if (val instanceof PdfString) {
		PdfString pdfString = (PdfString) val;
		return pdfString.getOriginalBytes();
	}
	return val.getBytes();
}
 
Example 28
Source Project: dss   Source File: ITextPdfDict.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public String getStringValue(String key) {
	PdfString pdfString = wrapped.getAsString(new PdfName(key));
	if (pdfString == null) {
		return null;
	} else {
		return pdfString.toUnicodeString();
	}
}
 
Example 29
Source Project: dss   Source File: ITextPdfDict.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Date getDateValue(String name) {
	PdfObject pdfObject = wrapped.get(new PdfName(name));
	PdfString s = (PdfString) pdfObject;
	if (s == null) {
		return null;
	}
	return PdfDate.decode(s.toString()).getTime();
}
 
Example 30
Source Project: openbd-core   Source File: cfDOCUMENT.java    License: GNU General Public License v3.0 5 votes vote down vote up
public CreationListener(cfData _author, cfData _title, cfData _subject, cfData _keywords)
{
	if ( _author != null )
		author = new PdfString(_author.toString());
	if ( _title != null )
		title = new PdfString(_title.toString());
	if ( _subject != null )
		subject = new PdfString(_subject.toString());
	if ( _keywords != null )
		keywords = new PdfString(_keywords.toString());
}