本文整理汇总了Java中com.lowagie.text.Image.isImgTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java Image.isImgTemplate方法的具体用法?Java Image.isImgTemplate怎么用?Java Image.isImgTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.Image
的用法示例。
在下文中一共展示了Image.isImgTemplate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDirectImageSimple
import com.lowagie.text.Image; //导入方法依赖的package包/类
/**
* Adds an image to the document but not to the page resources.
* It is used with templates and <CODE>Document.add(Image)</CODE>.
* Use this method only if you know what you're doing!
* @param image the <CODE>Image</CODE> to add
* @param fixedRef the reference to used. It may be <CODE>null</CODE>,
* a <CODE>PdfIndirectReference</CODE> or a <CODE>PRIndirectReference</CODE>.
* @return the name of the image added
* @throws PdfException on error
* @throws DocumentException on error
*/
public PdfName addDirectImageSimple(Image image, PdfIndirectReference fixedRef) throws PdfException, DocumentException {
PdfName name;
// if the images is already added, just retrieve the name
if (images.containsKey(image.getMySerialId())) {
name = (PdfName) images.get(image.getMySerialId());
}
// if it's a new image, add it to the document
else {
if (image.isImgTemplate()) {
name = new PdfName("img" + images.size());
if(image instanceof ImgWMF){
try {
ImgWMF wmf = (ImgWMF)image;
wmf.readWMF(PdfTemplate.createTemplate(this, 0, 0));
}
catch (Exception e) {
throw new DocumentException(e);
}
}
}
else {
PdfIndirectReference dref = image.getDirectReference();
if (dref != null) {
PdfName rname = new PdfName("img" + images.size());
images.put(image.getMySerialId(), rname);
imageDictionary.put(rname, dref);
return rname;
}
Image maskImage = image.getImageMask();
PdfIndirectReference maskRef = null;
if (maskImage != null) {
PdfName mname = (PdfName)images.get(maskImage.getMySerialId());
maskRef = getImageReference(mname);
}
PdfImage i = new PdfImage(image, "img" + images.size(), maskRef);
if (image instanceof ImgJBIG2) {
byte[] globals = ((ImgJBIG2) image).getGlobalBytes();
if (globals != null) {
PdfDictionary decodeparms = new PdfDictionary();
decodeparms.put(PdfName.JBIG2GLOBALS, getReferenceJBIG2Globals(globals));
i.put(PdfName.DECODEPARMS, decodeparms);
}
}
if (image.hasICCProfile()) {
PdfICCBased icc = new PdfICCBased(image.getICCProfile(), image.getCompressionLevel());
PdfIndirectReference iccRef = add(icc);
PdfArray iccArray = new PdfArray();
iccArray.add(PdfName.ICCBASED);
iccArray.add(iccRef);
PdfArray colorspace = i.getAsArray(PdfName.COLORSPACE);
if (colorspace != null) {
if (colorspace.size() > 1 && PdfName.INDEXED.equals(colorspace.getPdfObject(0)))
colorspace.set(1, iccArray);
else
i.put(PdfName.COLORSPACE, iccArray);
}
else
i.put(PdfName.COLORSPACE, iccArray);
}
add(i, fixedRef);
name = i.name();
}
images.put(image.getMySerialId(), name);
}
return name;
}