com.lowagie.text.pdf.PdfString Java Examples

The following examples show how to use com.lowagie.text.pdf.PdfString. 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: PdfXConformanceImp.java    From itext2 with GNU Lesser General Public License v3.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 #2
Source File: PdfContentStreamProcessor.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #3
Source File: PdfContentStreamProcessor.java    From gcs with 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 #4
Source File: PdfXConformanceImp.java    From gcs with 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 #5
Source File: PdfGlyphRenderer.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 File: JRPdfExporterTagHelper.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #7
Source File: PdfXConformanceImp.java    From itext2 with GNU Lesser General Public License v3.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 #8
Source File: PdfCollectionField.java    From itext2 with GNU Lesser General Public License v3.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 #9
Source File: PdfCollectionField.java    From itext2 with GNU Lesser General Public License v3.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 #10
Source File: PdfCollectionItem.java    From itext2 with GNU Lesser General Public License v3.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 #11
Source File: PdfCollectionItem.java    From itext2 with GNU Lesser General Public License v3.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 #12
Source File: JRPdfExporterTagHelper.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
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 #13
Source File: JRPdfExporterTagHelper.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #14
Source File: BmpImage.java    From itext2 with 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 #15
Source File: ITextPDFSignatureService.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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 #16
Source File: ITextPdfDict.java    From dss with 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 #17
Source File: ITextPdfDict.java    From dss with 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 #18
Source File: ITextPdfDict.java    From dss with 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 #19
Source File: cfDOCUMENT.java    From openbd-core with 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());
}
 
Example #20
Source File: cfDOCUMENT.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
public void onClose(ITextRenderer renderer) 
{
	PdfString creator = new PdfString("OpenBD " + cfEngine.PRODUCT_VERSION + " (" + cfEngine.BUILD_ISSUE + ")");
	renderer.getOutputDevice().getWriter().getInfo().put(PdfName.CREATOR,creator);  
	
	if (author != null)
		renderer.getOutputDevice().getWriter().getInfo().put(PdfName.AUTHOR,author);  
	if (title != null)
		renderer.getOutputDevice().getWriter().getInfo().put(PdfName.TITLE,title);  
	if (subject != null)
		renderer.getOutputDevice().getWriter().getInfo().put(PdfName.SUBJECT,subject);  
	if (keywords != null)
		renderer.getOutputDevice().getWriter().getInfo().put(PdfName.KEYWORDS,keywords);  
}
 
Example #21
Source File: PdfLogicalPageDrawable.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private PdfAction createActionForLink( final String target ) {
  if ( StringUtils.isEmpty( target ) ) {
    return null;
  }
  final PdfAction action = new PdfAction();
  if ( target.startsWith( "#" ) ) {
    // its a local link ..
    action.put( PdfName.S, PdfName.GOTO );
    action.put( PdfName.D, new PdfString( target.substring( 1 ) ) );
  } else {
    action.put( PdfName.S, PdfName.URI );
    action.put( PdfName.URI, new PdfString( target ) );
  }
  return action;
}
 
Example #22
Source File: PdfLogicalPageDrawable.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void drawImageMap( final RenderableReplacedContentBox content ) {
  if ( version < '6' ) {
    return;
  }

  final ImageMap imageMap = RenderUtility.extractImageMap( content );
  // only generate a image map, if the user does not specify their own onw via the override.
  // Of course, they would have to provide the map by other means as well.

  if ( imageMap == null ) {
    return;
  }

  final ImageMapEntry[] imageMapEntries = imageMap.getMapEntries();
  for ( int i = 0; i < imageMapEntries.length; i++ ) {
    final ImageMapEntry imageMapEntry = imageMapEntries[i];
    final String link = imageMapEntry.getAttribute( LibXmlInfo.XHTML_NAMESPACE, "href" );
    final String tooltip = imageMapEntry.getAttribute( LibXmlInfo.XHTML_NAMESPACE, "title" );
    if ( StringUtils.isEmpty( tooltip ) ) {
      continue;
    }

    final AffineTransform affineTransform = getGraphics().getTransform();
    final float translateX = (float) affineTransform.getTranslateX();
    final int x = (int) ( translateX + StrictGeomUtility.toExternalValue( content.getX() ) );
    final int y = (int) StrictGeomUtility.toExternalValue( content.getY() );
    final float[] translatedCoords = translateCoordinates( imageMapEntry.getAreaCoordinates(), x, y );

    final PolygonAnnotation polygonAnnotation = new PolygonAnnotation( writer, translatedCoords );
    polygonAnnotation.put( PdfName.CONTENTS, new PdfString( tooltip, PdfObject.TEXT_UNICODE ) );
    writer.addAnnotation( polygonAnnotation );
  }
}
 
Example #23
Source File: PdfAnnotationsImp.java    From itext2 with GNU Lesser General Public License v3.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 #24
Source File: PdfContentStreamProcessor.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #25
Source File: PdfContentStreamProcessor.java    From gcs with 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 #26
Source File: PdfContentStreamProcessor.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
    * 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 #27
Source File: PdfAnnotationsImp.java    From gcs with 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 #28
Source File: PdfXConformanceImp.java    From gcs with 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 #29
Source File: BmpImage.java    From gcs with 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 #30
Source File: PdfCollectionField.java    From gcs with 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;
	}
}