• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PdfObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.lowagie.text.pdf.PdfObject的典型用法代码示例。如果您正苦于以下问题:Java PdfObject类的具体用法?Java PdfObject怎么用?Java PdfObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PdfObject类属于com.lowagie.text.pdf包,在下文中一共展示了PdfObject类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getContentBytesFromPdfObject

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
public static byte[] getContentBytesFromPdfObject(PdfObject object) throws IOException {
	switch (object.type()) {
	case PdfObject.INDIRECT:
		return getContentBytesFromPdfObject(PdfReader.getPdfObject(object));
	case PdfObject.STREAM:
		return PdfReader.getStreamBytes((PRStream) PdfReader.getPdfObject(object));
	case PdfObject.ARRAY:
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ListIterator<PdfObject> iter = ((PdfArray) object).listIterator();
		while (iter.hasNext()) {
			PdfObject element = iter.next();
			baos.write(getContentBytesFromPdfObject(element));
		}
		return baos.toByteArray();
	default:
		throw new IllegalStateException("Unsupported type: " + object.getClass().getCanonicalName());
	}
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:19,代码来源:PdfContentStreamProcessor.java


示例2: simplifyColorspace

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
/**
 * Replaces CalRGB and CalGray colorspaces with DeviceRGB and DeviceGray.
 */    
public void simplifyColorspace() {
    if (additional == null)
        return;
    PdfArray value = additional.getAsArray(PdfName.COLORSPACE);
    if (value == null)
        return;
    PdfObject cs = simplifyColorspace(value);
    PdfObject newValue;
    if (cs.isName())
        newValue = cs;
    else {
        newValue = value;
        PdfName first = value.getAsName(0);
        if (PdfName.INDEXED.equals(first)) {
            if (value.size() >= 2) {
                PdfArray second = value.getAsArray(1);
                if (second != null) {
                    value.set(1, simplifyColorspace(second));
                }
            }
        }
    }
    additional.put(PdfName.COLORSPACE, newValue);
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:28,代码来源:Image.java


示例3: getColorspace

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
PdfObject getColorspace() {
    if (icc_profile != null) {
        if ((colorType & 2) == 0)
            return PdfName.DEVICEGRAY;
        else
            return PdfName.DEVICERGB;
    }
    if (gamma == 1f && !hasCHRM) {
        if ((colorType & 2) == 0)
            return PdfName.DEVICEGRAY;
        else
            return PdfName.DEVICERGB;
    }
    else {
        PdfArray array = new PdfArray();
        PdfDictionary dic = new PdfDictionary();
        if ((colorType & 2) == 0) {
            if (gamma == 1f)
                return PdfName.DEVICEGRAY;
            array.add(PdfName.CALGRAY);
            dic.put(PdfName.GAMMA, new PdfNumber(gamma));
            dic.put(PdfName.WHITEPOINT, new PdfLiteral("[1 1 1]"));
            array.add(dic);
        }
        else {
            PdfObject wp = new PdfLiteral("[1 1 1]");
            array.add(PdfName.CALRGB);
            if (gamma != 1f) {
                PdfArray gm = new PdfArray();
                PdfNumber n = new PdfNumber(gamma);
                gm.add(n);
                gm.add(n);
                gm.add(n);
                dic.put(PdfName.GAMMA, gm);
            }
            if (hasCHRM) {
                float z = yW*((xG-xB)*yR-(xR-xB)*yG+(xR-xG)*yB);
                float YA = yR*((xG-xB)*yW-(xW-xB)*yG+(xW-xG)*yB)/z;
                float XA = YA*xR/yR;
                float ZA = YA*((1-xR)/yR-1);
                float YB = -yG*((xR-xB)*yW-(xW-xB)*yR+(xW-xR)*yB)/z;
                float XB = YB*xG/yG;
                float ZB = YB*((1-xG)/yG-1);
                float YC = yB*((xR-xG)*yW-(xW-xG)*yW+(xW-xR)*yG)/z;
                float XC = YC*xB/yB;
                float ZC = YC*((1-xB)/yB-1);
                float XW = XA+XB+XC;
                float YW = 1;//YA+YB+YC;
                float ZW = ZA+ZB+ZC;
                PdfArray wpa = new PdfArray();
                wpa.add(new PdfNumber(XW));
                wpa.add(new PdfNumber(YW));
                wpa.add(new PdfNumber(ZW));
                wp = wpa;
                PdfArray matrix = new PdfArray();
                matrix.add(new PdfNumber(XA));
                matrix.add(new PdfNumber(YA));
                matrix.add(new PdfNumber(ZA));
                matrix.add(new PdfNumber(XB));
                matrix.add(new PdfNumber(YB));
                matrix.add(new PdfNumber(ZB));
                matrix.add(new PdfNumber(XC));
                matrix.add(new PdfNumber(YC));
                matrix.add(new PdfNumber(ZC));
                dic.put(PdfName.MATRIX, matrix);
            }
            dic.put(PdfName.WHITEPOINT, wp);
            array.add(dic);
        }
        return array;
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:73,代码来源:PngImage.java


示例4: setPrefix

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:16,代码来源:PdfCollectionItem.java


示例5: setSortOrder

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
/**
 * Defines the sort order of the field (ascending or descending).
 * @param ascending	an array with every element corresponding with a name of a field.
 */
public void setSortOrder(boolean[] ascending) {
	PdfObject o = get(PdfName.S);
	if (o instanceof PdfArray) {
		if (((PdfArray)o).size() != ascending.length) {
			throw new IllegalArgumentException("The number of booleans in this array doesn't correspond with the number of fields.");
		}
		PdfArray array = new PdfArray();
		for (int i = 0; i < ascending.length; i++) {
			array.add(new PdfBoolean(ascending[i]));
		}
		put(PdfName.A, array);
	}
	else {
		throw new IllegalArgumentException("You need a single boolean for this collection sort dictionary.");
	}
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:21,代码来源:PdfCollectionSort.java


示例6: draw

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
@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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:25,代码来源:PdfGlyphRenderer.java


示例7: getInstance

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
/**
 * Reuses an existing image.
 * @param ref the reference to the image dictionary
 * @throws BadElementException on error
 * @return the image
 */    
public static Image getInstance(PRIndirectReference ref) throws BadElementException {
    PdfDictionary dic = (PdfDictionary)PdfReader.getPdfObjectRelease(ref);
    int width = ((PdfNumber)PdfReader.getPdfObjectRelease(dic.get(PdfName.WIDTH))).intValue();
    int height = ((PdfNumber)PdfReader.getPdfObjectRelease(dic.get(PdfName.HEIGHT))).intValue();
    Image imask = null;
    PdfObject obj = dic.get(PdfName.SMASK);
    if (obj != null && obj.isIndirect()) {
        imask = getInstance((PRIndirectReference)obj);
    }
    else {
        obj = dic.get(PdfName.MASK);
        if (obj != null && obj.isIndirect()) {
            PdfObject obj2 = PdfReader.getPdfObjectRelease(obj);
            if (obj2 instanceof PdfDictionary)
                imask = getInstance((PRIndirectReference)obj);
        }
    }
    Image img = new ImgRaw(width, height, 1, 1, null);
    img.imageMask = imask;
    img.directReference = ref;
    return img;
}
 
开发者ID:bullda,项目名称:DroidText,代码行数:29,代码来源:Image.java


示例8: getDirectObject

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
@Override
public PdfObject getDirectObject(PdfName key) {
	for (int i = stack.size() - 1; i >= 0; i--) {
		PdfDictionary dict = stack.get(i);
		PdfObject o = dict.getDirectObject(key);
		if (o != null) {
			return o;
		}
	}
	return null;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:12,代码来源:PdfContentStreamProcessor.java


示例9: convertAnnotation

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
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));
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:31,代码来源:PdfAnnotationsImp.java


示例10: PdfCollectionField

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:37,代码来源:PdfCollectionField.java


示例11: getValue

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:16,代码来源:PdfCollectionField.java


示例12: main

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
/**
 * Demonstrates some Layer functionality.
 * 
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Document document = new Document();
	// step 2:
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("Layers.pdf"));
	writer.setPdfVersion(PdfWriter.VERSION_1_5);
	// step 3:
	writer.setViewerPreferences(PdfWriter.PageModeUseOC);
	document.open();
	// step 4:
	PdfContentByte cb = writer.getDirectContent();
	Phrase explanation = new Phrase("Layer grouping", new Font(Font.HELVETICA, 20, Font.BOLD, Color.red));
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50, 650, 0);
	PdfLayer l1 = new PdfLayer("Layer 1", writer);
	PdfLayer l2 = new PdfLayer("Layer 2", writer);
	PdfLayer l3 = new PdfLayer("Layer 3", writer);
	PdfLayerMembership m1 = new PdfLayerMembership(writer);
	m1.addMember(l2);
	m1.addMember(l3);
	Phrase p1 = new Phrase("Text in layer 1");
	Phrase p2 = new Phrase("Text in layer 2 or layer 3");
	Phrase p3 = new Phrase("Text in layer 3");
	cb.beginLayer(l1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0);
	cb.endLayer();
	cb.beginLayer(m1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
	cb.endLayer();
	cb.beginLayer(l3);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
	cb.endLayer();
	PdfOCProperties p = writer.getOCProperties();
	PdfArray order = new PdfArray();
	order.add(l1.getRef());
	PdfArray group = new PdfArray();
	group.add(new PdfString("A group of two", PdfObject.TEXT_UNICODE));
	group.add(l2.getRef());
	group.add(l3.getRef());
	order.add(group);
	PdfDictionary d = new PdfDictionary();
	d.put(PdfName.ORDER, order);
	p.put(PdfName.D, d);

	// step 5: we close the document
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:53,代码来源:LayersTest.java


示例13: processBytes

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
private void processBytes(final byte[] pdfBytes, final int pageNumber) throws IOException {
	final PdfReader pdfReader = new PdfReader(pdfBytes);

	final PdfDictionary pageDictionary = pdfReader.getPageN(pageNumber);

	final PdfDictionary resourceDictionary = pageDictionary.getAsDict(PdfName.RESOURCES);

	final PdfObject contentObject = pageDictionary.get(PdfName.CONTENTS);
	final byte[] contentBytes = readContentBytes(contentObject);
	_processor.processContent(contentBytes, resourceDictionary);
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:12,代码来源:PdfContentStreamProcessorTest.java


示例14: readContentBytes

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
private byte[] readContentBytes(final PdfObject contentObject) throws IOException {
	final byte[] result;
	switch (contentObject.type()) {
	case PdfObject.INDIRECT:
		final PRIndirectReference ref = (PRIndirectReference) contentObject;
		final PdfObject directObject = PdfReader.getPdfObject(ref);
		result = readContentBytes(directObject);
		break;
	case PdfObject.STREAM:
		final PRStream stream = (PRStream) PdfReader.getPdfObject(contentObject);
		result = PdfReader.getStreamBytes(stream);
		break;
	case PdfObject.ARRAY:
		// Stitch together all content before calling processContent(),
		// because
		// processContent() resets state.
		final ByteArrayOutputStream allBytes = new ByteArrayOutputStream();
		final PdfArray contentArray = (PdfArray) contentObject;
		final ListIterator<?> iter = contentArray.listIterator();
		while (iter.hasNext()) {
			final PdfObject element = (PdfObject) iter.next();
			allBytes.write(readContentBytes(element));
		}
		result = allBytes.toByteArray();
		break;
	default:
		final String msg = "Unable to handle Content of type " + contentObject.getClass();
		throw new IllegalStateException(msg);
	}
	return result;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:32,代码来源:PdfContentStreamProcessorTest.java


示例15: startText

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
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);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:12,代码来源:JRPdfExporterTagHelper.java


示例16: mergeMetadata

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
/**
 * Merge metadata from the FOP-generated PDF and a PDF we're merging into it.
 * Generally metadata in the merge file takes precedence over the FOP metadata,
 * but the "overrideMetadata" option reverses that behavior.
 */
private void mergeMetadata(HashMap<String, String>[] infos, PdfWriter pdfWriter, XPathContext context) 
  throws XPathException 
{
  boolean override = getAttribBool("overrideMetadata", context, false);
  HashMap<String, String> toPut = new HashMap();
  if (override) {
    toPut.putAll(infos[1]);
    toPut.putAll(infos[0]);
  }
  else {
    toPut.putAll(infos[0]);
    toPut.putAll(infos[1]);
  }
  
  PdfDictionary outInfo = pdfWriter.getInfo();
  for (String key : toPut.keySet())
  {
    // Keep iText as the producer
    if (key.equals("Producer"))
      continue;
    
    // Filter out empty values.
    String val = toPut.get(key).trim();
    if (val.length() == 0)
      continue;
    
    // Add the new metadata
    outInfo.put(new PdfName(key), new PdfString(val, PdfObject.TEXT_UNICODE));
  }
}
 
开发者ID:CDLUC3,项目名称:dash-xtf,代码行数:36,代码来源:PipeFopElement.java


示例17: main

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
/**
 * Demonstrates how to group optional content.
 * 
 * @param args
 *            no arguments needed
 */
public static void main(String[] args) {
	System.out.println("Grouping optional content");
	try {
		// step 1
		Document document = new Document(PageSize.A4, 50, 50, 50, 50);
		// step 2
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "contentgroups.pdf"));
		writer.setPdfVersion(PdfWriter.VERSION_1_5);
		writer.setViewerPreferences(PdfWriter.PageModeUseOC);
		// step 3
		document.open();
		// step 4
		PdfContentByte cb = writer.getDirectContent();
		Phrase explanation = new Phrase("Layer grouping", new Font(Font.HELVETICA, 20, Font.BOLD, Color.red));
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50, 650, 0);
		PdfLayer l1 = new PdfLayer("Layer 1", writer);
		PdfLayer l2 = new PdfLayer("Layer 2", writer);
		PdfLayer l3 = new PdfLayer("Layer 3", writer);
		PdfLayerMembership m1 = new PdfLayerMembership(writer);
		m1.addMember(l2);
		m1.addMember(l3);
		Phrase p1 = new Phrase("Text in layer 1");
		Phrase p2 = new Phrase("Text in layer 2 or layer 3");
		Phrase p3 = new Phrase("Text in layer 3");
		cb.beginLayer(l1);
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0);
		cb.endLayer();
		cb.beginLayer(m1);
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
		cb.endLayer();
		cb.beginLayer(l3);
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
		cb.endLayer();
		cb.sanityCheck();

		PdfOCProperties p = writer.getOCProperties();
		PdfArray order = new PdfArray();
		order.add(l1.getRef());
		PdfArray group = new PdfArray();
		group.add(new PdfString("A group of two", PdfObject.TEXT_UNICODE));
		group.add(l2.getRef());
		group.add(l3.getRef());
		order.add(group);
		PdfDictionary d = new PdfDictionary();
		d.put(PdfName.ORDER, order);
		p.put(PdfName.D, d);
		// step 5
		document.close();
	} catch (Exception de) {
		de.printStackTrace();
	}
}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:59,代码来源:ContentGroups.java


示例18: getColorspace

import com.lowagie.text.pdf.PdfObject; //导入依赖的package包/类
PdfObject getColorspace() {
    if (gamma == 1f && !hasCHRM) {
        if ((colorType & 2) == 0)
            return PdfName.DEVICEGRAY;
        else
            return PdfName.DEVICERGB;
    }
    else {
        PdfArray array = new PdfArray();
        PdfDictionary dic = new PdfDictionary();
        if ((colorType & 2) == 0) {
            if (gamma == 1f)
                return PdfName.DEVICEGRAY;
            array.add(PdfName.CALGRAY);
            dic.put(PdfName.GAMMA, new PdfNumber(gamma));
            dic.put(PdfName.WHITEPOINT, new PdfLiteral("[1 1 1]"));
            array.add(dic);
        }
        else {
            PdfObject wp = new PdfLiteral("[1 1 1]");
            array.add(PdfName.CALRGB);
            if (gamma != 1f) {
                PdfArray gm = new PdfArray();
                PdfNumber n = new PdfNumber(gamma);
                gm.add(n);
                gm.add(n);
                gm.add(n);
                dic.put(PdfName.GAMMA, gm);
            }
            if (hasCHRM) {
                float z = yW*((xG-xB)*yR-(xR-xB)*yG+(xR-xG)*yB);
                float YA = yR*((xG-xB)*yW-(xW-xB)*yG+(xW-xG)*yB)/z;
                float XA = YA*xR/yR;
                float ZA = YA*((1-xR)/yR-1);
                float YB = -yG*((xR-xB)*yW-(xW-xB)*yR+(xW-xR)*yB)/z;
                float XB = YB*xG/yG;
                float ZB = YB*((1-xG)/yG-1);
                float YC = yB*((xR-xG)*yW-(xW-xG)*yW+(xW-xR)*yG)/z;
                float XC = YC*xB/yB;
                float ZC = YC*((1-xB)/yB-1);
                float XW = XA+XB+XC;
                float YW = 1;//YA+YB+YC;
                float ZW = ZA+ZB+ZC;
                PdfArray wpa = new PdfArray();
                wpa.add(new PdfNumber(XW));
                wpa.add(new PdfNumber(YW));
                wpa.add(new PdfNumber(ZW));
                wp = wpa;
                PdfArray matrix = new PdfArray();
                matrix.add(new PdfNumber(XA));
                matrix.add(new PdfNumber(YA));
                matrix.add(new PdfNumber(ZA));
                matrix.add(new PdfNumber(XB));
                matrix.add(new PdfNumber(YB));
                matrix.add(new PdfNumber(ZB));
                matrix.add(new PdfNumber(XC));
                matrix.add(new PdfNumber(YC));
                matrix.add(new PdfNumber(ZC));
                dic.put(PdfName.MATRIX, matrix);
            }
            dic.put(PdfName.WHITEPOINT, wp);
            array.add(dic);
        }
        return array;
    }
}
 
开发者ID:bullda,项目名称:DroidText,代码行数:67,代码来源:PngImage.java



注:本文中的com.lowagie.text.pdf.PdfObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConnectionException类代码示例发布时间:2022-05-22
下一篇:
Java SetTestSuiteBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap