本文整理汇总了Java中com.lowagie.text.pdf.PdfString类的典型用法代码示例。如果您正苦于以下问题:Java PdfString类的具体用法?Java PdfString怎么用?Java PdfString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfString类属于com.lowagie.text.pdf包,在下文中一共展示了PdfString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: invoke
import com.lowagie.text.pdf.PdfString; //导入依赖的package包/类
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);
}
开发者ID:albfernandez,项目名称:itext2,代码行数:18,代码来源:PdfContentStreamProcessor.java
示例2: completeInfoDictionary
import com.lowagie.text.pdf.PdfString; //导入依赖的package包/类
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"));
}
}
}
开发者ID:albfernandez,项目名称:itext2,代码行数:22,代码来源:PdfXConformanceImp.java
示例3: setPrefix
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例4: draw
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例5: unpackFile
import com.lowagie.text.pdf.PdfString; //导入依赖的package包/类
public PdfAttachment unpackFile(PdfDictionary filespec) throws IOException {
if (filespec == null)
return null;
PdfName type = filespec.getAsName(PdfName.TYPE);
if (!PdfName.F.equals(type) && !PdfName.FILESPEC.equals(type))
return null;
PdfDictionary ef = filespec.getAsDict(PdfName.EF);
if (ef == null)
return null;
PRStream prs = (PRStream)PdfReader.getPdfObject(ef.get(PdfName.F));
if (prs == null)
return null;
PdfString pdfDesc = filespec.getAsString(PdfName.DESC);
String desc = pdfDesc != null ? pdfDesc.toString() : "";
PdfString pdfName = filespec.getAsString(PdfName.F);
String name = pdfName != null ? pdfName.toString() : "";
byte[] data = PdfReader.getStreamBytes(prs);
return new PdfAttachment(name, desc, data);
}
开发者ID:opendatalab-de,项目名称:zugferd,代码行数:20,代码来源:PdfInvoiceReader.java
示例6: invoke
import com.lowagie.text.pdf.PdfString; //导入依赖的package包/类
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);
}
开发者ID:bullda,项目名称:DroidText,代码行数:18,代码来源:PdfContentStreamProcessor.java
示例7: displayPdfString
import com.lowagie.text.pdf.PdfString; //导入依赖的package包/类
/**
* 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;
}
开发者ID:albfernandez,项目名称:itext2,代码行数:14,代码来源:PdfContentStreamProcessor.java
示例8: convertAnnotation
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例9: completeExtraCatalog
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例10: indexedModel
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例11: PdfCollectionField
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例12: getValue
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例13: main
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例14: init
import com.lowagie.text.pdf.PdfString; //导入依赖的package包/类
/**
*
*/
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);
}
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:35,代码来源:JRPdfExporterTagHelper.java
示例15: startImage
import com.lowagie.text.pdf.PdfString; //导入依赖的package包/类
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()));
}
}
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:13,代码来源:JRPdfExporterTagHelper.java
示例16: startText
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例17: CreationListener
import com.lowagie.text.pdf.PdfString; //导入依赖的package包/类
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());
}
开发者ID:OpenBD,项目名称:openbd-core,代码行数:12,代码来源:cfDOCUMENT.java
示例18: mergeMetadata
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例19: main
import com.lowagie.text.pdf.PdfString; //导入依赖的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
示例20: addItem
import com.lowagie.text.pdf.PdfString; //导入依赖的package包/类
/**
* 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);
}
}
开发者ID:bullda,项目名称:DroidText,代码行数:12,代码来源:PdfCollectionItem.java
注:本文中的com.lowagie.text.pdf.PdfString类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论