Method from com.lowagie.text.pdf.PdfWriter Detail: |
protected PdfIndirectReference add(PdfICCBased icc) {
PdfIndirectObject object;
try {
object = addToBody(icc);
}
catch(IOException ioe) {
throw new ExceptionConverter(ioe);
}
return object.getIndirectReference();
}
|
PdfIndirectReference add(PdfPage page,
PdfContents contents) throws PdfException {
if (!open) {
throw new PdfException("The document isn't open.");
}
PdfIndirectObject object;
try {
object = addToBody(contents);
}
catch(IOException ioe) {
throw new ExceptionConverter(ioe);
}
page.add(object.getIndirectReference());
// [U5]
if (group != null) {
page.put(PdfName.GROUP, group);
group = null;
}
else if (rgbTransparencyBlending) {
PdfDictionary pp = new PdfDictionary();
pp.put(PdfName.TYPE, PdfName.GROUP);
pp.put(PdfName.S, PdfName.TRANSPARENCY);
pp.put(PdfName.CS, PdfName.DEVICERGB);
page.put(PdfName.GROUP, pp);
}
root.addPage(page);
currentPageNumber++;
return null;
}
|
PdfIndirectReference add(PdfImage pdfImage,
PdfIndirectReference fixedRef) throws PdfException {
if (! imageDictionary.contains(pdfImage.name())) {
PdfXConformanceImp.checkPDFXConformance(this, PdfXConformanceImp.PDFXKEY_IMAGE, pdfImage);
if (fixedRef instanceof PRIndirectReference) {
PRIndirectReference r2 = (PRIndirectReference)fixedRef;
fixedRef = new PdfIndirectReference(0, getNewObjectNumber(r2.getReader(), r2.getNumber(), r2.getGeneration()));
}
try {
if (fixedRef == null)
fixedRef = addToBody(pdfImage).getIndirectReference();
else
addToBody(pdfImage, fixedRef);
}
catch(IOException ioe) {
throw new ExceptionConverter(ioe);
}
imageDictionary.put(pdfImage.name(), fixedRef);
return fixedRef;
}
return (PdfIndirectReference) imageDictionary.get(pdfImage.name());
}
Writes a PdfImage to the outputstream. |
public void addAnnotation(PdfAnnotation annot) {
pdf.addAnnotation(annot);
}
|
void addAnnotation(PdfAnnotation annot,
int page) {
addAnnotation(annot);
}
|
public void addCalculationOrder(PdfFormField annot) {
pdf.addCalculationOrder(annot);
}
|
public void addDeveloperExtension(PdfDeveloperExtension de) {
pdf_version.addDeveloperExtension(de);
}
|
public PdfName addDirectImageSimple(Image image) throws PdfException, DocumentException {
return addDirectImageSimple(image, null);
}
Use this method to adds an image to the document
but not to the page resources. It is used with
templates and Document.add(Image) .
Use this method only if you know what you're doing! |
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;
}
Adds an image to the document but not to the page resources.
It is used with templates and Document.add(Image) .
Use this method only if you know what you're doing! |
PdfName addDirectTemplateSimple(PdfTemplate template,
PdfName forcedName) {
PdfIndirectReference ref = template.getIndirectReference();
Object obj[] = (Object[])formXObjects.get(ref);
PdfName name = null;
try {
if (obj == null) {
if (forcedName == null) {
name = new PdfName("Xf" + formXObjectsCounter);
++formXObjectsCounter;
}
else
name = forcedName;
if (template.getType() == PdfTemplate.TYPE_IMPORTED) {
// If we got here from PdfCopy we'll have to fill importedPages
PdfImportedPage ip = (PdfImportedPage)template;
PdfReader r = ip.getPdfReaderInstance().getReader();
if (!importedPages.containsKey(r)) {
importedPages.put(r, ip.getPdfReaderInstance());
}
template = null;
}
formXObjects.put(ref, new Object[]{name, template});
}
else
name = (PdfName)obj[0];
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
return name;
}
Adds a template to the document but not to the page resources. |
public void addFileAttachment(PdfFileSpecification fs) throws IOException {
addFileAttachment(null, fs);
}
Use this method to add a file attachment at the document level. |
public void addFileAttachment(String description,
PdfFileSpecification fs) throws IOException {
pdf.addFileAttachment(description, fs);
}
Use this method to add a file attachment at the document level. |
public void addFileAttachment(String description,
byte[] fileStore,
String file,
String fileDisplay) throws IOException {
addFileAttachment(description, PdfFileSpecification.fileEmbedded(this, file, fileDisplay, fileStore));
}
Use this method to add a file attachment at the document level. |
public void addJavaScript(PdfAction js) {
pdf.addJavaScript(js);
}
Use this method to add a JavaScript action at the document level.
When the document opens, all this JavaScript runs. |
public void addJavaScript(String code) {
addJavaScript(code, false);
}
Use this method to adds a JavaScript action at the document level.
When the document opens, all this JavaScript runs. |
public void addJavaScript(String code,
boolean unicode) {
addJavaScript(PdfAction.javaScript(code, this, unicode));
}
Use this method to add a JavaScript action at the document level.
When the document opens, all this JavaScript runs. |
public void addJavaScript(String name,
PdfAction js) {
pdf.addJavaScript(name, js);
}
Use this method to add a JavaScript action at the document level.
When the document opens, all this JavaScript runs. |
public void addJavaScript(String name,
String code) {
addJavaScript(name, code, false);
}
Use this method to adds a JavaScript action at the document level.
When the document opens, all this JavaScript runs. |
public void addJavaScript(String name,
String code,
boolean unicode) {
addJavaScript(name, PdfAction.javaScript(code, this, unicode));
}
Use this method to add a JavaScript action at the document level.
When the document opens, all this JavaScript runs. |
void addLocalDestinations(TreeMap dest) throws IOException {
for (Iterator i = dest.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
String name = (String) entry.getKey();
Object obj[] = (Object[]) entry.getValue();
PdfDestination destination = (PdfDestination)obj[2];
if (obj[1] == null)
obj[1] = getPdfIndirectReference();
if (destination == null)
addToBody(new PdfString("invalid_" + name), (PdfIndirectReference)obj[1]);
else
addToBody(destination, (PdfIndirectReference)obj[1]);
}
}
Adds the local destinations to the body of the document. |
public void addOCGRadioGroup(ArrayList group) {
PdfArray ar = new PdfArray();
for (int k = 0; k < group.size(); ++k) {
PdfLayer layer = (PdfLayer)group.get(k);
if (layer.getTitle() == null)
ar.add(layer.getRef());
}
if (ar.size() == 0)
return;
OCGRadioGroup.add(ar);
}
Use this method to set a collection of optional content groups
whose states are intended to follow a "radio button" paradigm.
That is, the state of at most one optional content group
in the array should be ON at a time: if one group is turned
ON, all others must be turned OFF. |
protected void addSharedObjectsToBody() throws IOException {
// [F3] add the fonts
for (Iterator it = documentFonts.values().iterator(); it.hasNext();) {
FontDetails details = (FontDetails)it.next();
details.writeFont(this);
}
// [F4] add the form XObjects
for (Iterator it = formXObjects.values().iterator(); it.hasNext();) {
Object objs[] = (Object[])it.next();
PdfTemplate template = (PdfTemplate)objs[1];
if (template != null && template.getIndirectReference() instanceof PRIndirectReference)
continue;
if (template != null && template.getType() == PdfTemplate.TYPE_TEMPLATE) {
addToBody(template.getFormXObject(compressionLevel), template.getIndirectReference());
}
}
// [F5] add all the dependencies in the imported pages
for (Iterator it = importedPages.values().iterator(); it.hasNext();) {
currentPdfReaderInstance = (PdfReaderInstance)it.next();
currentPdfReaderInstance.writeAllPages();
}
currentPdfReaderInstance = null;
// [F6] add the spotcolors
for (Iterator it = documentColors.values().iterator(); it.hasNext();) {
ColorDetails color = (ColorDetails)it.next();
addToBody(color.getSpotColor(this), color.getIndirectReference());
}
// [F7] add the pattern
for (Iterator it = documentPatterns.keySet().iterator(); it.hasNext();) {
PdfPatternPainter pat = (PdfPatternPainter)it.next();
addToBody(pat.getPattern(compressionLevel), pat.getIndirectReference());
}
// [F8] add the shading patterns
for (Iterator it = documentShadingPatterns.keySet().iterator(); it.hasNext();) {
PdfShadingPattern shadingPattern = (PdfShadingPattern)it.next();
shadingPattern.addToBody();
}
// [F9] add the shadings
for (Iterator it = documentShadings.keySet().iterator(); it.hasNext();) {
PdfShading shading = (PdfShading)it.next();
shading.addToBody();
}
// [F10] add the extgstate
for (Iterator it = documentExtGState.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
PdfDictionary gstate = (PdfDictionary) entry.getKey();
PdfObject obj[] = (PdfObject[]) entry.getValue();
addToBody(gstate, (PdfIndirectReference)obj[1]);
}
// [F11] add the properties
for (Iterator it = documentProperties.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
Object prop = entry.getKey();
PdfObject[] obj = (PdfObject[]) entry.getValue();
if (prop instanceof PdfLayerMembership){
PdfLayerMembership layer = (PdfLayerMembership)prop;
addToBody(layer.getPdfObject(), layer.getRef());
}
else if ((prop instanceof PdfDictionary) && !(prop instanceof PdfLayer)){
addToBody((PdfDictionary)prop, (PdfIndirectReference)obj[1]);
}
}
// [F13] add the OCG layers
for (Iterator it = documentOCG.iterator(); it.hasNext();) {
PdfOCG layer = (PdfOCG)it.next();
addToBody(layer.getPdfObject(), layer.getRef());
}
}
|
FontDetails addSimple(BaseFont bf) {
if (bf.getFontType() == BaseFont.FONT_TYPE_DOCUMENT) {
return new FontDetails(new PdfName("F" + (fontNumber++)), ((DocumentFont)bf).getIndirectReference(), bf);
}
FontDetails ret = (FontDetails)documentFonts.get(bf);
if (ret == null) {
PdfXConformanceImp.checkPDFXConformance(this, PdfXConformanceImp.PDFXKEY_FONT, bf);
ret = new FontDetails(new PdfName("F" + (fontNumber++)), body.getPdfIndirectReference(), bf);
documentFonts.put(bf, ret);
}
return ret;
}
Adds a BaseFont to the document but not to the page resources.
It is used for templates. |
ColorDetails addSimple(PdfSpotColor spc) {
ColorDetails ret = (ColorDetails)documentColors.get(spc);
if (ret == null) {
ret = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), spc);
documentColors.put(spc, ret);
}
return ret;
}
Adds a SpotColor to the document but not to the page resources. |
PdfObject[] addSimpleExtGState(PdfDictionary gstate) {
if (!documentExtGState.containsKey(gstate)) {
PdfXConformanceImp.checkPDFXConformance(this, PdfXConformanceImp.PDFXKEY_GSTATE, gstate);
documentExtGState.put(gstate, new PdfObject[]{new PdfName("GS" + (documentExtGState.size() + 1)), getPdfIndirectReference()});
}
return (PdfObject[])documentExtGState.get(gstate);
}
|
PdfName addSimplePattern(PdfPatternPainter painter) {
PdfName name = (PdfName)documentPatterns.get(painter);
try {
if ( name == null ) {
name = new PdfName("P" + patternNumber);
++patternNumber;
documentPatterns.put(painter, name);
}
} catch (Exception e) {
throw new ExceptionConverter(e);
}
return name;
}
|
ColorDetails addSimplePatternColorspace(Color color) {
int type = ExtendedColor.getType(color);
if (type == ExtendedColor.TYPE_PATTERN || type == ExtendedColor.TYPE_SHADING)
throw new RuntimeException("An uncolored tile pattern can not have another pattern or shading as color.");
try {
switch (type) {
case ExtendedColor.TYPE_RGB:
if (patternColorspaceRGB == null) {
patternColorspaceRGB = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), null);
PdfArray array = new PdfArray(PdfName.PATTERN);
array.add(PdfName.DEVICERGB);
addToBody(array, patternColorspaceRGB.getIndirectReference());
}
return patternColorspaceRGB;
case ExtendedColor.TYPE_CMYK:
if (patternColorspaceCMYK == null) {
patternColorspaceCMYK = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), null);
PdfArray array = new PdfArray(PdfName.PATTERN);
array.add(PdfName.DEVICECMYK);
addToBody(array, patternColorspaceCMYK.getIndirectReference());
}
return patternColorspaceCMYK;
case ExtendedColor.TYPE_GRAY:
if (patternColorspaceGRAY == null) {
patternColorspaceGRAY = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), null);
PdfArray array = new PdfArray(PdfName.PATTERN);
array.add(PdfName.DEVICEGRAY);
addToBody(array, patternColorspaceGRAY.getIndirectReference());
}
return patternColorspaceGRAY;
case ExtendedColor.TYPE_SEPARATION: {
ColorDetails details = addSimple(((SpotColor)color).getPdfSpotColor());
ColorDetails patternDetails = (ColorDetails)documentSpotPatterns.get(details);
if (patternDetails == null) {
patternDetails = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), null);
PdfArray array = new PdfArray(PdfName.PATTERN);
array.add(details.getIndirectReference());
addToBody(array, patternDetails.getIndirectReference());
documentSpotPatterns.put(details, patternDetails);
}
return patternDetails;
}
default:
throw new RuntimeException("Invalid color type in PdfWriter.addSimplePatternColorspace().");
}
}
catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
|
PdfObject[] addSimpleProperty(Object prop,
PdfIndirectReference refi) {
if (!documentProperties.containsKey(prop)) {
if (prop instanceof PdfOCG)
PdfXConformanceImp.checkPDFXConformance(this, PdfXConformanceImp.PDFXKEY_LAYER, null);
documentProperties.put(prop, new PdfObject[]{new PdfName("Pr" + (documentProperties.size() + 1)), refi});
}
return (PdfObject[])documentProperties.get(prop);
}
|
void addSimpleShading(PdfShading shading) {
if (!documentShadings.containsKey(shading)) {
documentShadings.put(shading, null);
shading.setName(documentShadings.size());
}
}
|
void addSimpleShadingPattern(PdfShadingPattern shading) {
if (!documentShadingPatterns.containsKey(shading)) {
shading.setName(patternNumber);
++patternNumber;
documentShadingPatterns.put(shading, null);
addSimpleShading(shading.getShading());
}
}
|
public PdfIndirectObject addToBody(PdfObject object) throws IOException {
PdfIndirectObject iobj = body.add(object);
return iobj;
}
Use this method to add a PDF object to the PDF body.
Use this method only if you know what you're doing! |
public PdfIndirectObject addToBody(PdfObject object,
boolean inObjStm) throws IOException {
PdfIndirectObject iobj = body.add(object, inObjStm);
return iobj;
}
Use this method to add a PDF object to the PDF body.
Use this method only if you know what you're doing! |
public PdfIndirectObject addToBody(PdfObject object,
PdfIndirectReference ref) throws IOException {
PdfIndirectObject iobj = body.add(object, ref);
return iobj;
}
Use this method to add a PDF object to the PDF body.
Use this method only if you know what you're doing! |
public PdfIndirectObject addToBody(PdfObject object,
int refNumber) throws IOException {
PdfIndirectObject iobj = body.add(object, refNumber);
return iobj;
}
Use this method to add a PDF object to the PDF body.
Use this method only if you know what you're doing! |
public PdfIndirectObject addToBody(PdfObject object,
PdfIndirectReference ref,
boolean inObjStm) throws IOException {
PdfIndirectObject iobj = body.add(object, ref, inObjStm);
return iobj;
}
Use this method to add a PDF object to the PDF body.
Use this method only if you know what you're doing! |
public PdfIndirectObject addToBody(PdfObject object,
int refNumber,
boolean inObjStm) throws IOException {
PdfIndirectObject iobj = body.add(object, refNumber, inObjStm);
return iobj;
}
Use this method to add a PDF object to the PDF body.
Use this method only if you know what you're doing! |
public void addViewerPreference(PdfName key,
PdfObject value) {
pdf.addViewerPreference(key, value);
}
|
public void clearTextWrap() throws DocumentException {
pdf.clearTextWrap();
}
Use this method to clear text wrapping around images (if applicable). |
public void close() {
if (open) {
if ((currentPageNumber - 1) != pageReferences.size())
throw new RuntimeException("The page " + pageReferences.size() +
" was requested but the document has only " + (currentPageNumber - 1) + " pages.");
pdf.close();
try {
addSharedObjectsToBody();
// add the root to the body
PdfIndirectReference rootRef = root.writePageTree();
// make the catalog-object and add it to the body
PdfDictionary catalog = getCatalog(rootRef);
// [C9] if there is XMP data to add: add it
if (xmpMetadata != null) {
PdfStream xmp = new PdfStream(xmpMetadata);
xmp.put(PdfName.TYPE, PdfName.METADATA);
xmp.put(PdfName.SUBTYPE, PdfName.XML);
if (crypto != null && !crypto.isMetadataEncrypted()) {
PdfArray ar = new PdfArray();
ar.add(PdfName.CRYPT);
xmp.put(PdfName.FILTER, ar);
}
catalog.put(PdfName.METADATA, body.add(xmp).getIndirectReference());
}
// [C10] make pdfx conformant
if (isPdfX()) {
pdfxConformance.completeInfoDictionary(getInfo());
pdfxConformance.completeExtraCatalog(getExtraCatalog());
}
// [C11] Output Intents
if (extraCatalog != null) {
catalog.mergeDifferent(extraCatalog);
}
writeOutlines(catalog, false);
// add the Catalog to the body
PdfIndirectObject indirectCatalog = addToBody(catalog, false);
// add the info-object to the body
PdfIndirectObject infoObj = addToBody(getInfo(), false);
// [F1] encryption
PdfIndirectReference encryption = null;
PdfObject fileID = null;
body.flushObjStm();
if (crypto != null) {
PdfIndirectObject encryptionObject = addToBody(crypto.getEncryptionDictionary(), false);
encryption = encryptionObject.getIndirectReference();
fileID = crypto.getFileID();
}
else
fileID = PdfEncryption.createInfoId(PdfEncryption.createDocumentId());
// write the cross-reference table of the body
body.writeCrossReferenceTable(os, indirectCatalog.getIndirectReference(),
infoObj.getIndirectReference(), encryption, fileID, prevxref);
// make the trailer
// [F2] full compression
if (fullCompression) {
os.write(getISOBytes("startxref\n"));
os.write(getISOBytes(String.valueOf(body.offset())));
os.write(getISOBytes("\n%%EOF\n"));
}
else {
PdfTrailer trailer = new PdfTrailer(body.size(),
body.offset(),
indirectCatalog.getIndirectReference(),
infoObj.getIndirectReference(),
encryption,
fileID, prevxref);
trailer.toPdf(this, os);
}
super.close();
}
catch(IOException ioe) {
throw new ExceptionConverter(ioe);
}
}
}
Signals that the Document was closed and that no other
Elements will be added.
The pages-tree is built and written to the outputstream.
A Catalog is constructed, as well as an Info-object,
the reference table is composed and everything is written
to the outputstream embedded in a Trailer. |
public void createXmpMetadata() {
setXmpMetadata(createXmpMetadataBytes());
}
Use this method to creates XMP Metadata based
on the metadata in the PdfDocument. |
void eliminateFontSubset(PdfDictionary fonts) {
for (Iterator it = documentFonts.values().iterator(); it.hasNext();) {
FontDetails ft = (FontDetails)it.next();
if (fonts.get(ft.getFontName()) != null)
ft.setSubset(false);
}
}
|
protected void fillOCProperties(boolean erase) {
if (OCProperties == null)
OCProperties = new PdfOCProperties();
if (erase) {
OCProperties.remove(PdfName.OCGS);
OCProperties.remove(PdfName.D);
}
if (OCProperties.get(PdfName.OCGS) == null) {
PdfArray gr = new PdfArray();
for (Iterator it = documentOCG.iterator(); it.hasNext();) {
PdfLayer layer = (PdfLayer)it.next();
gr.add(layer.getRef());
}
OCProperties.put(PdfName.OCGS, gr);
}
if (OCProperties.get(PdfName.D) != null)
return;
ArrayList docOrder = new ArrayList(documentOCGorder);
for (Iterator it = docOrder.iterator(); it.hasNext();) {
PdfLayer layer = (PdfLayer)it.next();
if (layer.getParent() != null)
it.remove();
}
PdfArray order = new PdfArray();
for (Iterator it = docOrder.iterator(); it.hasNext();) {
PdfLayer layer = (PdfLayer)it.next();
getOCGOrder(order, layer);
}
PdfDictionary d = new PdfDictionary();
OCProperties.put(PdfName.D, d);
d.put(PdfName.ORDER, order);
PdfArray gr = new PdfArray();
for (Iterator it = documentOCG.iterator(); it.hasNext();) {
PdfLayer layer = (PdfLayer)it.next();
if (!layer.isOn())
gr.add(layer.getRef());
}
if (gr.size() > 0)
d.put(PdfName.OFF, gr);
if (OCGRadioGroup.size() > 0)
d.put(PdfName.RBGROUPS, OCGRadioGroup);
if (OCGLocked.size() > 0)
d.put(PdfName.LOCKED, OCGLocked);
addASEvent(PdfName.VIEW, PdfName.ZOOM);
addASEvent(PdfName.VIEW, PdfName.VIEW);
addASEvent(PdfName.PRINT, PdfName.PRINT);
addASEvent(PdfName.EXPORT, PdfName.EXPORT);
d.put(PdfName.LISTMODE, PdfName.VISIBLEPAGES);
}
|
public boolean fitsPage(Table table) {
return fitsPage(table, 0);
}
Checks if a Table fits the current page of the PdfDocument . |
public boolean fitsPage(Table table,
float margin) {
return pdf.bottom(table) > pdf.indentBottom() + margin;
}
Checks if a Table fits the current page of the PdfDocument . |
public void freeReader(PdfReader reader) throws IOException {
currentPdfReaderInstance = (PdfReaderInstance)importedPages.get(reader);
if (currentPdfReaderInstance == null)
return;
currentPdfReaderInstance.writeAllPages();
currentPdfReaderInstance = null;
importedPages.remove(reader);
}
Use this method to writes the reader to the document
and free the memory used by it.
The main use is when concatenating multiple documents
to keep the memory usage restricted to the current
appending document. |
public PdfAcroForm getAcroForm() {
return pdf.getAcroForm();
}
|
public Rectangle getBoxSize(String boxName) {
return pdf.getBoxSize(boxName);
}
Use this method to get the size of a trim, art, crop or bleed box,
or null if not defined. |
protected PdfDictionary getCatalog(PdfIndirectReference rootObj) {
PdfDictionary catalog = pdf.getCatalog(rootObj);
// [F12] tagged PDF
if (tagged) {
try {
getStructureTreeRoot().buildTree();
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
catalog.put(PdfName.STRUCTTREEROOT, structureTreeRoot.getReference());
PdfDictionary mi = new PdfDictionary();
mi.put(PdfName.MARKED, PdfBoolean.PDFTRUE);
if (userProperties)
mi.put(PdfName.USERPROPERTIES, PdfBoolean.PDFTRUE);
catalog.put(PdfName.MARKINFO, mi);
}
// [F13] OCG
if (!documentOCG.isEmpty()) {
fillOCProperties(false);
catalog.put(PdfName.OCPROPERTIES, OCProperties);
}
return catalog;
}
|
PdfName getColorspaceName() {
return new PdfName("CS" + (colorNumber++));
}
|
public int getCompressionLevel() {
return compressionLevel;
}
Returns the compression level used for streams written by this writer. |
public int getCurrentDocumentSize() {
return body.offset() + body.size() * 20 + 0x48;
}
Use this method to gets the current document size.
This size only includes the data already written
to the output stream, it does not include templates or fonts.
It is useful if used with freeReader()
when concatenating many documents and an idea of
the current size is needed. |
PdfIndirectReference getCurrentPage() {
return getPageReference(currentPageNumber);
}
|
public int getCurrentPageNumber() {
return currentPageNumber;
}
|
public PdfDictionary getDefaultColorspace() {
return defaultColorspace;
}
Use this method to get the default colorspaces. |
public PdfContentByte getDirectContent() {
if (!open)
throw new RuntimeException("The document is not open.");
return directContent;
}
Use this method to get the direct content for this document.
There is only one direct content, multiple calls to this method
will allways retrieve the same object. |
public PdfContentByte getDirectContentUnder() {
if (!open)
throw new RuntimeException("The document is not open.");
return directContentUnder;
}
Use this method to get the direct content under for this document.
There is only one direct content, multiple calls to this method
will always retrieve the same object. |
PdfEncryption getEncryption() {
return crypto;
}
|
public PdfDictionary getExtraCatalog() {
if (extraCatalog == null)
extraCatalog = new PdfDictionary();
return this.extraCatalog;
}
Sets extra keys to the catalog. |
public PdfDictionary getGroup() {
return this.group;
}
Use this method to get the group dictionary. |
PdfIndirectReference getImageReference(PdfName name) {
return (PdfIndirectReference) imageDictionary.get(name);
}
return the PdfIndirectReference to the image with a given name. |
public PdfImportedPage getImportedPage(PdfReader reader,
int pageNumber) {
PdfReaderInstance inst = (PdfReaderInstance)importedPages.get(reader);
if (inst == null) {
inst = reader.getPdfReaderInstance(this);
importedPages.put(reader, inst);
}
return inst.getImportedPage(pageNumber);
}
Use this method to get a page from other PDF document.
The page can be used as any other PdfTemplate.
Note that calling this method more than once with the same parameters
will retrieve the same object. |
int getIndirectReferenceNumber() {
return body.getIndirectReferenceNumber();
}
|
public PdfDictionary getInfo() {
return pdf.getInfo();
}
Use this method to get the info dictionary if you want to
change it directly (add keys and values to the info dictionary). |
public static PdfWriter getInstance(Document document,
OutputStream os) throws DocumentException {
PdfDocument pdf = new PdfDocument();
document.addDocListener(pdf);
PdfWriter writer = new PdfWriter(pdf, os);
pdf.addWriter(writer);
return writer;
}
Use this method to get an instance of the PdfWriter . |
public static PdfWriter getInstance(Document document,
OutputStream os,
DocListener listener) throws DocumentException {
PdfDocument pdf = new PdfDocument();
pdf.addDocListener(listener);
document.addDocListener(pdf);
PdfWriter writer = new PdfWriter(pdf, os);
pdf.addWriter(writer);
return writer;
}
Use this method to get an instance of the PdfWriter . |
protected int getNewObjectNumber(PdfReader reader,
int number,
int generation) {
return currentPdfReaderInstance.getNewObjectNumber(number, generation);
}
|
public PdfOCProperties getOCProperties() {
fillOCProperties(true);
return OCProperties;
}
Use this method to get the Optional Content Properties Dictionary.
Each call fills the dictionary with the current layer state.
It's advisable to only call this method right before close
and do any modifications at that time. |
OutputStreamCounter getOs() {
return os;
}
Returns the outputStreamCounter. |
public int getPDFXConformance() {
return pdfxConformance.getPDFXConformance();
}
|
public PdfPageEvent getPageEvent() {
return pageEvent;
}
Gets the PdfPageEvent for this document or null
if none is set. |
public int getPageNumber() {
return pdf.getPageNumber();
}
Gets the pagenumber of this document.
This number can be different from the real pagenumber,
if you have (re)set the page number previously. |
public PdfIndirectReference getPageReference(int page) {
--page;
if (page < 0)
throw new IndexOutOfBoundsException("The page numbers start at 1.");
PdfIndirectReference ref;
if (page < pageReferences.size()) {
ref = (PdfIndirectReference)pageReferences.get(page);
if (ref == null) {
ref = body.getPdfIndirectReference();
pageReferences.set(page, ref);
}
}
else {
int empty = page - pageReferences.size();
for (int k = 0; k < empty; ++k)
pageReferences.add(null);
ref = body.getPdfIndirectReference();
pageReferences.add(ref);
}
return ref;
}
Use this method to get a reference to a page existing or not.
If the page does not exist yet the reference will be created
in advance. If on closing the document, a page number greater
than the total number of pages was requested, an exception
is thrown. |
public Rectangle getPageSize() {
return pdf.getPageSize();
}
Use this method to get the size of the media box. |
PdfDocument getPdfDocument() {
return pdf;
}
Gets the PdfDocument associated with this writer. |
public PdfIndirectReference getPdfIndirectReference() {
return body.getPdfIndirectReference();
}
Use this to get an PdfIndirectReference for an object that
will be created in the future.
Use this method only if you know what you're doing! |
PdfVersionImp getPdfVersion() {
return pdf_version;
}
Returns the version information. |
RandomAccessFileOrArray getReaderFile(PdfReader reader) {
return currentPdfReaderInstance.getReaderFile();
}
|
protected PdfIndirectReference getReferenceJBIG2Globals(byte[] content) {
if (content == null) return null;
PdfStream stream;
for (Iterator i = JBIG2Globals.keySet().iterator(); i.hasNext(); ) {
stream = (PdfStream) i.next();
if (Arrays.equals(content, stream.getBytes())) {
return (PdfIndirectReference) JBIG2Globals.get(stream);
}
}
stream = new PdfStream(content);
PdfIndirectObject ref;
try {
ref = addToBody(stream);
} catch (IOException e) {
return null;
}
JBIG2Globals.put(stream, ref.getIndirectReference());
return ref.getIndirectReference();
}
Gets an indirect reference to a JBIG2 Globals stream.
Adds the stream if it hasn't already been added to the writer. |
public PdfOutline getRootOutline() {
return directContent.getRootOutline();
}
Use this method to get the root outline
and construct bookmarks. |
public int getRunDirection() {
return runDirection;
}
Use this method to set the run direction. |
public float getSpaceCharRatio() {
return spaceCharRatio;
}
Use this method to gets the space/character extra spacing ratio
for fully justified text. |
public PdfStructureTreeRoot getStructureTreeRoot() {
if (tagged && structureTreeRoot == null)
structureTreeRoot = new PdfStructureTreeRoot(this);
return structureTreeRoot;
}
Gets the structure tree root. If the document is not marked for tagging it will return null . |
public PdfName getTabs() {
return tabs;
}
Returns the value to be used for the Tabs entry in the page tree. |
public float getUserunit() {
return userunit;
}
Use this method to get the user unit.
A user unit is a value that defines the default user space unit.
The minimum UserUnit is 1 (1 unit = 1/72 inch).
The maximum UserUnit is 75,000.
Note that this userunit only works starting with PDF1.6! |
public float getVerticalPosition(boolean ensureNewLine) {
return pdf.getVerticalPosition(ensureNewLine);
}
Use this method to get the current vertical page position. |
public boolean isFullCompression() {
return this.fullCompression;
}
Use this method to find out if 1.5 compression is on. |
public boolean isPdfX() {
return pdfxConformance.isPdfX();
}
|
public boolean isRgbTransparencyBlending() {
return this.rgbTransparencyBlending;
}
Gets the transparency blending colorspace. |
public boolean isStrictImageSequence() {
return pdf.isStrictImageSequence();
}
Use this method to get the strictImageSequence status. |
public boolean isTagged() {
return tagged;
}
Check if the document is marked for tagging. |
public boolean isUserProperties() {
return this.userProperties;
}
Gets the flag indicating the presence of structure elements that contain user properties attributes. |
public void lockLayer(PdfLayer layer) {
OCGLocked.add(layer.getRef());
}
Use this method to lock an optional content group.
The state of a locked group cannot be changed through the user interface
of a viewer application. Producers can use this entry to prevent the visibility
of content that depends on these groups from being changed by users. |
public void open() {
super.open();
try {
pdf_version.writeHeader(os);
body = new PdfBody(this);
if (pdfxConformance.isPdfX32002()) {
PdfDictionary sec = new PdfDictionary();
sec.put(PdfName.GAMMA, new PdfArray(new float[]{2.2f,2.2f,2.2f}));
sec.put(PdfName.MATRIX, new PdfArray(new float[]{0.4124f,0.2126f,0.0193f,0.3576f,0.7152f,0.1192f,0.1805f,0.0722f,0.9505f}));
sec.put(PdfName.WHITEPOINT, new PdfArray(new float[]{0.9505f,1f,1.089f}));
PdfArray arr = new PdfArray(PdfName.CALRGB);
arr.add(sec);
setDefaultColorspace(PdfName.DEFAULTRGB, addToBody(arr).getIndirectReference());
}
}
catch(IOException ioe) {
throw new ExceptionConverter(ioe);
}
}
Signals that the Document has been opened and that
Elements can be added.
When this method is called, the PDF-document header is
written to the outputstream. |
boolean propertyExists(Object prop) {
return documentProperties.containsKey(prop);
}
|
void registerLayer(PdfOCG layer) {
PdfXConformanceImp.checkPDFXConformance(this, PdfXConformanceImp.PDFXKEY_LAYER, null);
if (layer instanceof PdfLayer) {
PdfLayer la = (PdfLayer)layer;
if (la.getTitle() == null) {
if (!documentOCG.contains(layer)) {
documentOCG.add(layer);
documentOCGorder.add(layer);
}
}
else {
documentOCGorder.add(layer);
}
}
else
throw new IllegalArgumentException("Only PdfLayer is accepted.");
}
|
public void releaseTemplate(PdfTemplate tp) throws IOException {
PdfIndirectReference ref = tp.getIndirectReference();
Object[] objs = (Object[])formXObjects.get(ref);
if (objs == null || objs[1] == null)
return;
PdfTemplate template = (PdfTemplate)objs[1];
if (template.getIndirectReference() instanceof PRIndirectReference)
return;
if (template.getType() == PdfTemplate.TYPE_TEMPLATE) {
addToBody(template.getFormXObject(compressionLevel), template.getIndirectReference());
objs[1] = null;
}
}
Use this method to releases the memory used by a template.
This method writes the template to the output.
The template can still be added to any content
but changes to the template itself won't have any effect. |
public int reorderPages(int[] order) throws DocumentException {
return root.reorderPages(order);
}
Use this method to reorder the pages in the document.
A null argument value only returns the number of pages to process.
It is advisable to issue a Document.newPage() before using this method. |
void resetContent() {
directContent.reset();
directContentUnder.reset();
}
Resets all the direct contents to empty.
This happens when a new page is started. |
public void setAdditionalAction(PdfName actionType,
PdfAction action) throws DocumentException {
if (!(actionType.equals(DOCUMENT_CLOSE) ||
actionType.equals(WILL_SAVE) ||
actionType.equals(DID_SAVE) ||
actionType.equals(WILL_PRINT) ||
actionType.equals(DID_PRINT))) {
throw new DocumentException("Invalid additional action type: " + actionType.toString());
}
pdf.addAdditionalAction(actionType, action);
}
|
public void setAtLeastPdfVersion(char version) {
pdf_version.setAtLeastPdfVersion(version);
}
|
public void setBoxSize(String boxName,
Rectangle size) {
pdf.setBoxSize(boxName, size);
}
Use this method to set the page box sizes.
Allowed names are: "crop", "trim", "art" and "bleed". |
public void setCollection(PdfCollection collection) {
setAtLeastPdfVersion(VERSION_1_7);
pdf.setCollection(collection);
}
Use this method to add the Collection dictionary. |
public void setCompressionLevel(int compressionLevel) {
if (compressionLevel < PdfStream.NO_COMPRESSION || compressionLevel > PdfStream.BEST_COMPRESSION)
this.compressionLevel = PdfStream.DEFAULT_COMPRESSION;
else
this.compressionLevel = compressionLevel;
}
Sets the compression level to be used for streams written by this writer. |
public void setCropBoxSize(Rectangle crop) {
pdf.setCropBoxSize(crop);
}
Use this method to set the crop box.
The crop box should not be rotated even if the page is rotated.
This change only takes effect in the next page. |
public void setDefaultColorspace(PdfName key,
PdfObject cs) {
if (cs == null || cs.isNull())
defaultColorspace.remove(key);
defaultColorspace.put(key, cs);
}
Use this method to sets the default colorspace that will be applied
to all the document. The colorspace is only applied if another colorspace
with the same name is not present in the content.
The colorspace is applied immediately when creating templates and
at the page end for the main document content. |
public void setDuration(int seconds) {
pdf.setDuration(seconds);
}
|
public void setEncryption(Certificate[] certs,
int[] permissions,
int encryptionType) throws DocumentException {
if (pdf.isOpen())
throw new DocumentException("Encryption can only be added before opening the document.");
crypto = new PdfEncryption();
if (certs != null) {
for (int i=0; i < certs.length; i++) {
crypto.addRecipient(certs[i], permissions[i]);
}
}
crypto.setCryptoMode(encryptionType, 0);
crypto.getEncryptionDictionary();
}
|
public void setEncryption(byte[] userPassword,
byte[] ownerPassword,
int permissions,
int encryptionType) throws DocumentException {
if (pdf.isOpen())
throw new DocumentException("Encryption can only be added before opening the document.");
crypto = new PdfEncryption();
crypto.setCryptoMode(encryptionType, 0);
crypto.setupAllKeys(userPassword, ownerPassword, permissions);
}
|
public void setEncryption(byte[] userPassword,
byte[] ownerPassword,
int permissions,
boolean strength128Bits) throws DocumentException {
setEncryption(userPassword, ownerPassword, permissions, strength128Bits ? STANDARD_ENCRYPTION_128 : STANDARD_ENCRYPTION_40);
} Deprecated! As - of iText 2.0.3, replaced by (@link #setEncryption(byte[], byte[], int, int)}. Scheduled for removal at or after 2.2.0
Sets the encryption options for this document. The userPassword and the
ownerPassword can be null or have zero length. In this case the ownerPassword
is replaced by a random string. The open permissions for the document can be
AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
The permissions can be combined by ORing them. |
public void setEncryption(boolean strength,
String userPassword,
String ownerPassword,
int permissions) throws DocumentException {
setEncryption(getISOBytes(userPassword), getISOBytes(ownerPassword), permissions, strength ? STANDARD_ENCRYPTION_128 : STANDARD_ENCRYPTION_40);
} Deprecated! As - of iText 2.0.3, replaced by (@link #setEncryption(byte[], byte[], int, int)}. Scheduled for removal at or after 2.2.0
Sets the encryption options for this document. The userPassword and the
ownerPassword can be null or have zero length. In this case the ownerPassword
is replaced by a random string. The open permissions for the document can be
AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
The permissions can be combined by ORing them. |
public void setEncryption(int encryptionType,
String userPassword,
String ownerPassword,
int permissions) throws DocumentException {
setEncryption(getISOBytes(userPassword), getISOBytes(ownerPassword), permissions, encryptionType);
} Deprecated! As - of iText 2.0.3, replaced by (@link #setEncryption(byte[], byte[], int, int)}. Scheduled for removal at or after 2.2.0
Sets the encryption options for this document. The userPassword and the
ownerPassword can be null or have zero length. In this case the ownerPassword
is replaced by a random string. The open permissions for the document can be
AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
The permissions can be combined by ORing them. |
public void setFullCompression() {
this.fullCompression = true;
setAtLeastPdfVersion(VERSION_1_5);
}
|
public void setGroup(PdfDictionary group) {
this.group = group;
}
Use this method to set the group dictionary. |
public void setInitialLeading(float leading) throws DocumentException {
if (open)
throw new DocumentException("You can't set the initial leading if the document is already open.");
pdf.setLeading(leading);
}
Sets the initial leading for the PDF document.
This has to be done before the document is opened. |
public void setLinearPageMode() {
root.setLinearMode(null);
}
Use this method to make sure the page tree has a linear structure
(every leave is attached directly to the root).
Use this method to allow page reordering with method reorderPages. |
public void setOpenAction(String name) {
pdf.setOpenAction(name);
}
|
public void setOpenAction(PdfAction action) {
pdf.setOpenAction(action);
}
|
public void setOutlines(List outlines) {
newBookmarks = outlines;
}
|
public boolean setOutputIntents(PdfReader reader,
boolean checkExistence) throws IOException {
PdfDictionary catalog = reader.getCatalog();
PdfArray outs = catalog.getAsArray(PdfName.OUTPUTINTENTS);
if (outs == null)
return false;
if (outs.isEmpty())
return false;
PdfDictionary out = outs.getAsDict(0);
PdfObject obj = PdfReader.getPdfObject(out.get(PdfName.S));
if (obj == null || !PdfName.GTS_PDFX.equals(obj))
return false;
if (checkExistence)
return true;
PRStream stream = (PRStream)PdfReader.getPdfObject(out.get(PdfName.DESTOUTPUTPROFILE));
byte destProfile[] = null;
if (stream != null) {
destProfile = PdfReader.getStreamBytes(stream);
}
setOutputIntents(getNameString(out, PdfName.OUTPUTCONDITIONIDENTIFIER), getNameString(out, PdfName.OUTPUTCONDITION),
getNameString(out, PdfName.REGISTRYNAME), getNameString(out, PdfName.INFO), destProfile);
return true;
}
Use this method to copy the output intent dictionary
from another document to this one. |
public void setOutputIntents(String outputConditionIdentifier,
String outputCondition,
String registryName,
String info,
ICC_Profile colorProfile) throws IOException {
getExtraCatalog();
PdfDictionary out = new PdfDictionary(PdfName.OUTPUTINTENT);
if (outputCondition != null)
out.put(PdfName.OUTPUTCONDITION, new PdfString(outputCondition, PdfObject.TEXT_UNICODE));
if (outputConditionIdentifier != null)
out.put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString(outputConditionIdentifier, PdfObject.TEXT_UNICODE));
if (registryName != null)
out.put(PdfName.REGISTRYNAME, new PdfString(registryName, PdfObject.TEXT_UNICODE));
if (info != null)
out.put(PdfName.INFO, new PdfString(info, PdfObject.TEXT_UNICODE));
if (colorProfile != null) {
PdfStream stream = new PdfICCBased(colorProfile, compressionLevel);
out.put(PdfName.DESTOUTPUTPROFILE, addToBody(stream).getIndirectReference());
}
PdfName intentSubtype;
if (pdfxConformance.isPdfA1() || "PDFA/1".equals(outputCondition)) {
intentSubtype = PdfName.GTS_PDFA1;
}
else {
intentSubtype = PdfName.GTS_PDFX;
}
out.put(PdfName.S, intentSubtype);
extraCatalog.put(PdfName.OUTPUTINTENTS, new PdfArray(out));
}
Sets the values of the output intent dictionary. Null values are allowed to
suppress any key. |
public void setOutputIntents(String outputConditionIdentifier,
String outputCondition,
String registryName,
String info,
byte[] destOutputProfile) throws IOException {
ICC_Profile colorProfile = (destOutputProfile == null) ? null : ICC_Profile.getInstance(destOutputProfile);
setOutputIntents(outputConditionIdentifier, outputCondition, registryName, info, colorProfile);
}
Sets the values of the output intent dictionary. Null values are allowed to
suppress any key.
Prefer the ICC_Profile -based version of this method. |
public void setPDFXConformance(int pdfx) {
if (pdfxConformance.getPDFXConformance() == pdfx)
return;
if (pdf.isOpen())
throw new PdfXConformanceException("PDFX conformance can only be set before opening the document.");
if (crypto != null)
throw new PdfXConformanceException("A PDFX conforming document cannot be encrypted.");
if (pdfx == PDFA1A || pdfx == PDFA1B)
setPdfVersion(VERSION_1_4);
else if (pdfx != PDFXNONE)
setPdfVersion(VERSION_1_3);
pdfxConformance.setPDFXConformance(pdfx);
}
|
public void setPageAction(PdfName actionType,
PdfAction action) throws DocumentException {
if (!actionType.equals(PAGE_OPEN) && !actionType.equals(PAGE_CLOSE))
throw new DocumentException("Invalid page additional action type: " + actionType.toString());
pdf.setPageAction(actionType, action);
}
|
public void setPageEmpty(boolean pageEmpty) {
pdf.setPageEmpty(pageEmpty);
}
Use this method to make sure a page is added,
even if it's empty. If you use setPageEmpty(false),
invoking newPage() after a blank page will add a newPage. |
public void setPageEvent(PdfPageEvent event) {
if (event == null) this.pageEvent = null;
else if (this.pageEvent == null) this.pageEvent = event;
else if (this.pageEvent instanceof PdfPageEventForwarder) ((PdfPageEventForwarder)this.pageEvent).addPageEvent(event);
else {
PdfPageEventForwarder forward = new PdfPageEventForwarder();
forward.addPageEvent(this.pageEvent);
forward.addPageEvent(event);
this.pageEvent = forward;
}
}
Sets the PdfPageEvent for this document. |
public void setPageLabels(PdfPageLabels pageLabels) {
pdf.setPageLabels(pageLabels);
}
Use this method to add page labels |
public void setPageXmpMetadata(byte[] xmpMetadata) {
pdf.setXmpMetadata(xmpMetadata);
}
Use this method to set the XMP Metadata for each page. |
public void setPdfVersion(char version) {
pdf_version.setPdfVersion(version);
}
|
public void setPdfVersion(PdfName version) {
pdf_version.setPdfVersion(version);
}
|
public void setRgbTransparencyBlending(boolean rgbTransparencyBlending) {
this.rgbTransparencyBlending = rgbTransparencyBlending;
}
Sets the transparency blending colorspace to RGB. The default blending colorspace is
CMYK and will result in faded colors in the screen and in printing. Calling this method
will return the RGB colors to what is expected. The RGB blending will be applied to all subsequent pages
until other value is set.
Note that this is a generic solution that may not work in all cases. |
public void setRunDirection(int runDirection) {
if (runDirection < RUN_DIRECTION_NO_BIDI || runDirection > RUN_DIRECTION_RTL)
throw new RuntimeException("Invalid run direction: " + runDirection);
this.runDirection = runDirection;
}
Use this method to set the run direction.
This is only used as a placeholder as it does not affect anything. |
public void setSigFlags(int f) {
pdf.setSigFlags(f);
}
|
public void setSpaceCharRatio(float spaceCharRatio) {
if (spaceCharRatio < 0.001f)
this.spaceCharRatio = 0.001f;
else
this.spaceCharRatio = spaceCharRatio;
}
Use this method to set the ratio between the extra word spacing and
the extra character spacing when the text is fully justified.
Extra word spacing will grow spaceCharRatio times more
than extra character spacing. If the ratio is PdfWriter.NO_SPACE_CHAR_RATIO
then the extra character spacing will be zero. |
public void setStrictImageSequence(boolean strictImageSequence) {
pdf.setStrictImageSequence(strictImageSequence);
}
Use this method to set the image sequence, so that it follows
the text in strict order (or not). |
public void setTabs(PdfName tabs) {
this.tabs = tabs;
}
Sets the value for the Tabs entry in the page tree. |
public void setTagged() {
if (open)
throw new IllegalArgumentException("Tagging must be set before opening the document.");
tagged = true;
}
Mark this document for tagging. It must be called before open. |
public void setThumbnail(Image image) throws PdfException, DocumentException {
pdf.setThumbnail(image);
}
Use this method to set the thumbnail image for the current page. |
public void setTransition(PdfTransition transition) {
pdf.setTransition(transition);
}
|
public void setUserProperties(boolean userProperties) {
this.userProperties = userProperties;
}
Sets the flag indicating the presence of structure elements that contain user properties attributes. |
public void setUserunit(float userunit) throws DocumentException {
if (userunit < 1f || userunit > 75000f) throw new DocumentException("UserUnit should be a value between 1 and 75000.");
this.userunit = userunit;
setAtLeastPdfVersion(VERSION_1_6);
}
Use this method to set the user unit.
A UserUnit is a value that defines the default user space unit.
The minimum UserUnit is 1 (1 unit = 1/72 inch).
The maximum UserUnit is 75,000.
Note that this userunit only works starting with PDF1.6! |
public void setViewerPreferences(int preferences) {
pdf.setViewerPreferences(preferences);
}
|
public void setXmpMetadata(byte[] xmpMetadata) {
this.xmpMetadata = xmpMetadata;
}
Use this method to set the XMP Metadata. |
protected void writeOutlines(PdfDictionary catalog,
boolean namedAsNames) throws IOException {
if (newBookmarks == null || newBookmarks.isEmpty())
return;
PdfDictionary top = new PdfDictionary();
PdfIndirectReference topRef = getPdfIndirectReference();
Object kids[] = SimpleBookmark.iterateOutlines(this, topRef, newBookmarks, namedAsNames);
top.put(PdfName.FIRST, (PdfIndirectReference)kids[0]);
top.put(PdfName.LAST, (PdfIndirectReference)kids[1]);
top.put(PdfName.COUNT, new PdfNumber(((Integer)kids[2]).intValue()));
addToBody(top, topRef);
catalog.put(PdfName.OUTLINES, topRef);
}
|