本文整理汇总了Java中com.lowagie.text.pdf.PdfArray类的典型用法代码示例。如果您正苦于以下问题:Java PdfArray类的具体用法?Java PdfArray怎么用?Java PdfArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfArray类属于com.lowagie.text.pdf包,在下文中一共展示了PdfArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getContentBytesFromPdfObject
import com.lowagie.text.pdf.PdfArray; //导入依赖的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.PdfArray; //导入依赖的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: invoke
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList operands) {
PdfName dictionaryName = (PdfName) operands.get(0);
PdfDictionary extGState = processor.resources.getAsDict(PdfName.EXTGSTATE);
if (extGState == null) {
throw new IllegalArgumentException(
"Resources do not contain ExtGState entry. Unable to process operator " + operator);
}
PdfDictionary gsDic = extGState.getAsDict(dictionaryName);
if (gsDic == null) {
throw new IllegalArgumentException(dictionaryName + " is an unknown graphics state dictionary");
}
// at this point, all we care about is the FONT entry in the GS dictionary
PdfArray fontParameter = gsDic.getAsArray(PdfName.FONT);
if (fontParameter != null) {
CMapAwareDocumentFont font = new CMapAwareDocumentFont(
(PRIndirectReference) fontParameter.getPdfObject(0));
float size = fontParameter.getAsNumber(1).floatValue();
processor.gs().font = font;
processor.gs().fontSize = size;
}
}
开发者ID:albfernandez,项目名称:itext2,代码行数:24,代码来源:PdfContentStreamProcessor.java
示例4: rotateAnnotations
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
public PdfArray rotateAnnotations(PdfWriter writer, Rectangle pageSize) {
PdfArray array = new PdfArray();
int rotation = pageSize.getRotation() % 360;
int currentPage = writer.getCurrentPageNumber();
for (int k = 0; k < annotations.size(); ++k) {
PdfAnnotation dic = (PdfAnnotation)annotations.get(k);
int page = dic.getPlaceInPage();
if (page > currentPage) {
delayedAnnotations.add(dic);
continue;
}
if (dic.isForm()) {
if (!dic.isUsed()) {
HashMap templates = dic.getTemplates();
if (templates != null)
acroForm.addFieldTemplates(templates);
}
PdfFormField field = (PdfFormField)dic;
if (field.getParent() == null)
acroForm.addDocumentField(field.getIndirectReference());
}
if (dic.isAnnotation()) {
array.add(dic.getIndirectReference());
if (!dic.isUsed()) {
PdfRectangle rect = (PdfRectangle)dic.get(PdfName.RECT);
if (rect != null) {
switch (rotation) {
case 90:
dic.put(PdfName.RECT, new PdfRectangle(
pageSize.getTop() - rect.bottom(),
rect.left(),
pageSize.getTop() - rect.top(),
rect.right()));
break;
case 180:
dic.put(PdfName.RECT, new PdfRectangle(
pageSize.getRight() - rect.left(),
pageSize.getTop() - rect.bottom(),
pageSize.getRight() - rect.right(),
pageSize.getTop() - rect.top()));
break;
case 270:
dic.put(PdfName.RECT, new PdfRectangle(
rect.bottom(),
pageSize.getRight() - rect.left(),
rect.top(),
pageSize.getRight() - rect.right()));
break;
}
}
}
}
if (!dic.isUsed()) {
dic.setUsed();
try {
writer.addToBody(dic, dic.getIndirectReference());
}
catch (IOException e) {
throw new ExceptionConverter(e);
}
}
}
return array;
}
开发者ID:albfernandez,项目名称:itext2,代码行数:65,代码来源:PdfAnnotationsImp.java
示例5: getColorspace
import com.lowagie.text.pdf.PdfArray; //导入依赖的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
示例6: setSortOrder
import com.lowagie.text.pdf.PdfArray; //导入依赖的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
示例7: invoke
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList operands) {
PdfName dictionaryName = (PdfName)operands.get(0);
PdfDictionary extGState = processor.resources.getAsDict(PdfName.EXTGSTATE);
if (extGState == null)
throw new IllegalArgumentException("Resources do not contain ExtGState entry. Unable to process operator " + operator);
PdfDictionary gsDic = extGState.getAsDict(dictionaryName);
if (gsDic == null)
throw new IllegalArgumentException(dictionaryName + " is an unknown graphics state dictionary");
// at this point, all we care about is the FONT entry in the GS dictionary
PdfArray fontParameter = gsDic.getAsArray(PdfName.FONT);
if (fontParameter != null){
CMapAwareDocumentFont font = new CMapAwareDocumentFont((PRIndirectReference)fontParameter.getPdfObject(0));
float size = fontParameter.getAsNumber(1).floatValue();
processor.gs().font = font;
processor.gs().fontSize = size;
}
}
开发者ID:bullda,项目名称:DroidText,代码行数:20,代码来源:PdfContentStreamProcessor.java
示例8: completeExtraCatalog
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
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));
}
}
}
开发者ID:albfernandez,项目名称:itext2,代码行数:14,代码来源:PdfXConformanceImp.java
示例9: indexedModel
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
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;
}
开发者ID:albfernandez,项目名称:itext2,代码行数:15,代码来源:BmpImage.java
示例10: PdfCollectionSort
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
/**
* Constructs a PDF Collection Sort Dictionary.
* @param keys the keys of the fields that will be used to sort entries
*/
public PdfCollectionSort(String[] keys) {
super(PdfName.COLLECTIONSORT);
PdfArray array = new PdfArray();
for (int i = 0; i < keys.length; i++) {
array.add(new PdfName(keys[i]));
}
put(PdfName.S, array);
}
开发者ID:albfernandez,项目名称:itext2,代码行数:13,代码来源:PdfCollectionSort.java
示例11: main
import com.lowagie.text.pdf.PdfArray; //导入依赖的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
示例12: readContentBytes
import com.lowagie.text.pdf.PdfArray; //导入依赖的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
示例13: createStartHeadingTags
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
protected void createStartHeadingTags(String prop, PdfName pdfName)
{
if (TAG_START.equals(prop) || TAG_FULL.equals(prop))
{
PdfStructureElement headingTag = new PdfStructureElement(tagStack.peek(), pdfName);
//pdfContentByte.beginMarkedContentSequence(headingTag);
headingTag.put(PdfName.K, new PdfArray());
tagStack.push(headingTag);
isTagEmpty = true;
}
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:12,代码来源:JRPdfExporterTagHelper.java
示例14: createTableStartTag
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
protected void createTableStartTag()
{
PdfStructureElement tableTag = new PdfStructureElement(allTag, PdfName.TABLE);
//pdfContentByte.beginMarkedContentSequence(tableTag);
tableTag.put(PdfName.K, new PdfArray());
tagStack.push(tableTag);
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:8,代码来源:JRPdfExporterTagHelper.java
示例15: createTrStartTag
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
protected void createTrStartTag()
{
PdfStructureElement tableRowTag = new PdfStructureElement(tagStack.peek(), PdfName.TABLEROW);
//pdfContentByte.beginMarkedContentSequence(tableRowTag);
tableRowTag.put(PdfName.K, new PdfArray());
tagStack.push(tableRowTag);
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:8,代码来源:JRPdfExporterTagHelper.java
示例16: createThStartTag
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
protected void createThStartTag(JRPrintElement element)
{
PdfStructureElement tableHeaderTag = new PdfStructureElement(tagStack.peek(), PdfName.TH);
//pdfContentByte.beginMarkedContentSequence(tableHeaderTag);
tableHeaderTag.put(PdfName.K, new PdfArray());
tagStack.push(tableHeaderTag);
isTagEmpty = true;
createSpanTags(element, tableHeaderTag);
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:11,代码来源:JRPdfExporterTagHelper.java
示例17: createTdStartTag
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
protected void createTdStartTag(JRPrintElement element)
{
PdfStructureElement tableCellTag = new PdfStructureElement(tagStack.peek(), PdfName.TD);
//pdfContentByte.beginMarkedContentSequence(tableCellTag);
tableCellTag.put(PdfName.K, new PdfArray());
tagStack.push(tableCellTag);
isTagEmpty = true;
createSpanTags(element, tableCellTag);
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:11,代码来源:JRPdfExporterTagHelper.java
示例18: createListStartTag
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
protected void createListStartTag()
{
PdfStructureElement listTag = new PdfStructureElement(allTag, PdfName.L);
//pdfContentByte.beginMarkedContentSequence(tableTag);
listTag.put(PdfName.K, new PdfArray());
tagStack.push(listTag);
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:8,代码来源:JRPdfExporterTagHelper.java
示例19: createListItemStartTag
import com.lowagie.text.pdf.PdfArray; //导入依赖的package包/类
protected void createListItemStartTag(JRPrintElement element)
{
PdfStructureElement listItemTag = new PdfStructureElement(tagStack.peek(), PdfName.LI);
//pdfContentByte.beginMarkedContentSequence(tableHeaderTag);
listItemTag.put(PdfName.K, new PdfArray());
tagStack.push(listItemTag);
isTagEmpty = true;
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:9,代码来源:JRPdfExporterTagHelper.java
示例20: main
import com.lowagie.text.pdf.PdfArray; //导入依赖的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
注:本文中的com.lowagie.text.pdf.PdfArray类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论