/** * This will set an item in the dictionary. If value is null then the result will be the same as removeItem( key ). * * @param key The key to the dictionary object. * @param value The value to the dictionary object. */ public void setItem(COSName key, COSBase value) { if (value == null) { removeItem(key); } else { items.put(key, value); } }
/** * {@inheritDoc} */ @Override public V remove(Object key) { map.removeItem( COSName.getPDFName( (String)key ) ); return actuals.remove( key ); }
/** * This will set the BleedBox for this page. * * @param bleedBox The new BleedBox for this page. */ public void setBleedBox(PDRectangle bleedBox) { if (bleedBox == null) { page.removeItem(COSName.BLEED_BOX); } else { page.setItem(COSName.BLEED_BOX, bleedBox); } }
/** * This will set the TrimBox for this page. * * @param trimBox The new TrimBox for this page. */ public void setTrimBox(PDRectangle trimBox) { if (trimBox == null) { page.removeItem(COSName.TRIM_BOX); } else { page.setItem(COSName.TRIM_BOX, trimBox); } }
/** * This will set the ArtBox for this page. * * @param artBox The new ArtBox for this page. */ public void setArtBox(PDRectangle artBox) { if (artBox == null) { page.removeItem(COSName.ART_BOX); } else { page.setItem(COSName.ART_BOX, artBox); } }
/** * This will set the mediaBox for this page. * * @param mediaBox The new mediaBox for this page. */ public void setMediaBox(PDRectangle mediaBox) { this.mediaBox = mediaBox; if (mediaBox == null) { page.removeItem(COSName.MEDIA_BOX); } else { page.setItem(COSName.MEDIA_BOX, mediaBox); } }
/** * Set the page number (zero-based) in the current document containing the file attachment * annotation. * * @param pageNumber the zero based page number. If this is < 0 then the entry is removed. */ public void setPageNumber(int pageNumber) { if (pageNumber < 0) { dict.removeItem(COSName.P); } else { dict.setInt(COSName.P, pageNumber); } }
/** * This will set the resources for this page. * * @param resources The new resources for this page. */ public void setResources(PDResources resources) { pageResources = resources; if (resources != null) { page.setItem(COSName.RESOURCES, resources); } else { page.removeItem(COSName.RESOURCES); } }
/** * Sets the numbering style for this page range. * * @param style * one of the STYLE_* constants or {@code null} if no page * numbering is desired. */ public void setStyle(String style) { if (style != null) { root.setName(KEY_STYLE, style); } else { root.removeItem(KEY_STYLE); } }
/** * This will set a named destination in the current document that provides the page number of * the file attachment annotation. * * @param dest a named destination or null if the entry is to be removed. */ public void setNamedDestination(PDNamedDestination dest) { if (dest == null) { dict.removeItem(COSName.P); } else { dict.setItem(COSName.P, dest); } }
/** * This will set the index (zero-based) of the annotation in the /Annots array of the page * specified by the /P entry. * * @param index the zero based index. If this is < 0 then the entry is removed. */ public void setAnnotationIndex(int index) { if (index < 0) { dict.removeItem(COSName.A); } else { dict.setInt(COSName.A, index); } }
/** * Sets the page label prefix for this page range. * * @param prefix * the page label prefix for this page range, or {@code null} to * unset the prefix. */ public void setPrefix(String prefix) { if (prefix != null) { root.setString(KEY_PREFIX, prefix); } else { root.removeItem(KEY_PREFIX); } } }
/** * This will set a float object. * * @param key The key to the data that we are setting. * @param value The value that we are setting. */ private void setFloatItem( COSName key, Float value ) { if( value == null ) { dict.removeItem(key); } else { dict.setItem(key, new COSFloat(value)); } }
/** * This will set the BBox (bounding box) for this Shading. * * @param newBBox the new BBox */ public void setBBox(PDRectangle newBBox) { bBox = newBBox; if (bBox == null) { dictionary.removeItem(COSName.BBOX); } else { dictionary.setItem(COSName.BBOX, bBox.getCOSArray()); } }
/** * This will set the CropBox for this page. * * @param cropBox The new CropBox for this page. */ public void setCropBox(PDRectangle cropBox) { if (cropBox == null) { page.removeItem(COSName.CROP_BOX); } else { page.setItem(COSName.CROP_BOX, cropBox.getCOSArray()); } }
/** * This will set the color space for the shading. * * @param colorSpace the color space */ public void setColorSpace(PDColorSpace colorSpace) { this.colorSpace = colorSpace; if (colorSpace != null) { dictionary.setItem(COSName.COLORSPACE, colorSpace.getCOSObject()); } else { dictionary.removeItem(COSName.COLORSPACE); } }
/** * This will set top index "TI" value. * * @param topIndex the value for the top index, null will remove the value. */ public void setTopIndex(Integer topIndex) { if (topIndex != null) { getCOSObject().setInt(COSName.TI, topIndex); } else { getCOSObject().removeItem(COSName.TI); } }
/** * This will set the export values. * * @see #getExportValues() * @param values List containing all possible export values. Supplying null or an empty list will remove the Opt entry. */ public void setExportValues(List<String> values) { COSArray cosValues; if (values != null && !values.isEmpty()) { cosValues = COSArrayList.convertStringListToCOSStringCOSArray(values); getCOSObject().setItem(COSName.OPT, cosValues); } else { getCOSObject().removeItem(COSName.OPT); } }
/** * This will set the BBox (bounding box) for this Pattern. * @param bbox The new BBox for this Pattern. */ public void setBBox(PDRectangle bbox) { if( bbox == null ) { getCOSObject().removeItem( COSName.BBOX ); } else { getCOSObject().setItem( COSName.BBOX, bbox.getCOSArray() ); } } }
/** * Set the default style string. * * Providing null as the value will remove the default style string. * * @param defaultStyleString a string describing the default style. */ public void setDefaultStyleString(String defaultStyleString) { if (defaultStyleString != null) { getCOSObject().setItem(COSName.DS, new COSString(defaultStyleString)); } else { getCOSObject().removeItem(COSName.DS); } }