/** * Constructs a <CODE>PdfOutline</CODE>. * <P> * This is the constructor for an <CODE>outline entry</CODE>. * * @param parent the parent of this outline item * @param destination the destination for this outline item * @param title the title of this outline item * @param open <CODE>true</CODE> if the children are visible */ public PdfOutline(PdfOutline parent, PdfDestination destination, PdfString title, boolean open) { this(parent, destination, title.toString(), true); }
/** * Constructs a <CODE>PdfOutline</CODE>. * <P> * This is the constructor for an <CODE>outline entry</CODE>. * * @param parent the parent of this outline item * @param destination the destination for this outline item * @param title the title of this outline item * @param open <CODE>true</CODE> if the children are visible */ public PdfOutline(PdfOutline parent, PdfDestination destination, PdfString title, boolean open) { this(parent, destination, title.toString(), true); }
/** * Constructs a <CODE>PdfOutline</CODE>. * <P> * This is the constructor for an <CODE>outline entry</CODE>. * * @param parent the parent of this outline item * @param action the <CODE>PdfAction</CODE> for this outline item * @param title the title of this outline item * @param open <CODE>true</CODE> if the children are visible */ public PdfOutline(PdfOutline parent, PdfAction action, PdfString title, boolean open) { this(parent, action, title.toString(), open); }
/** * Constructs a <CODE>PdfOutline</CODE>. * <P> * This is the constructor for an <CODE>outline entry</CODE>. * * @param parent the parent of this outline item * @param action the <CODE>PdfAction</CODE> for this outline item * @param title the title of this outline item * @param open <CODE>true</CODE> if the children are visible */ public PdfOutline(PdfOutline parent, PdfAction action, PdfString title, boolean open) { this(parent, action, title.toString(), open); }
/** * Gets the title of this outline * @return the title as a String */ public String getTitle() { PdfString title = (PdfString)get(PdfName.TITLE); return title.toString(); }
/** * Gets the title of this outline * @return the title as a String */ public String getTitle() { PdfString title = (PdfString)get(PdfName.TITLE); return title.toString(); }
//code within the above while() PdfDictionary d = entry.getValue().getMerged(0); PdfString fieldDA = d.getAsString(PdfName.DA); //in case of no form field default appearance create a default one if(fieldDA==null) ... Object[] infos = AcroFields.splitDAelements(fieldDA.toString()); if(infos[0]!=null) String fontName = (String)infos[0]; if(infos[1]!=null) float fontSize= (((Float)infos[1]).floatValue());
public void setType(PdfString type) { if (!allowedArtifactTypes.contains(type.toString())) throw new IllegalArgumentException(MessageLocalization.getComposedMessage("the.artifact.type.1.is.invalid", type)); setAccessibleAttribute(PdfName.TYPE, type); }
public void setType(PdfString type) { if (!allowedArtifactTypes.contains(type.toString())) throw new IllegalArgumentException(MessageLocalization.getComposedMessage("the.artifact.type.1.is.invalid", type)); setAccessibleAttribute(PdfName.TYPE, type); }
/** * Split PDF string into array of single character PDF strings. * @param string PDF string to be splitted. * @return splitted PDF string. */ private PdfString[] splitString(PdfString string) { List<PdfString> strings = new ArrayList<PdfString>(); String stringValue = string.toString(); for (int i = 0; i < stringValue.length(); i++) { PdfString newString = new PdfString(stringValue.substring(i, i + 1), string.getEncoding()); String text = decode(newString); if (text.length() == 0 && i < stringValue.length() - 1) { newString = new PdfString(stringValue.substring(i, i + 2), string.getEncoding()); i++; } strings.add(newString); } return strings.toArray(new PdfString[strings.size()]); }
public PRIndirectReference findNamedFont( PdfReader myReader, String desiredFontName) { int objNum = 0; PdfObject curObj; do { //The "Release" version doesn't keep a reference //to the object so it can be GC'd later. Quite Handy //when dealing with Really Big PDFs. curObj = myReader.getPdfObjectRelease( objNum++ ); if (curObj instanceof PRStream) { PRStream stream = (PRStream)curObj; PdfName type = stream.getAsName(PdfName.TYPE); if (PdfName.FONT.equals(type)) { PdfString fontName = stream.getAsString(PdfName.BASEFONT); if (desiredFontName.equals(fontName.toString())) { return curObj.getIndRef(); } } } } while (curObj != null); return null; }
/** * Split PDF string into array of single character PDF strings. * @param string PDF string to be splitted. * @return splitted PDF string. */ private PdfString[] splitString(PdfString string) { List<PdfString> strings = new ArrayList<PdfString>(); String stringValue = string.toString(); for (int i = 0; i < stringValue.length(); i++) { PdfString newString = new PdfString(stringValue.substring(i, i + 1), string.getEncoding()); String text = decode(newString); if (text.length() == 0 && i < stringValue.length() - 1) { newString = new PdfString(stringValue.substring(i, i + 2), string.getEncoding()); i++; } strings.add(newString); } return strings.toArray(new PdfString[strings.size()]); }
/** * Retrieve the rich value for the given field * @param name * @return The rich value if present, or null. * @since 5.0.6 */ public String getFieldRichValue(String name) { if (xfa.isXfaPresent()) { return null; } Item item = fields.get(name); if (item == null) { return null; } PdfDictionary merged = item.getMerged(0); PdfString rich = merged.getAsString(PdfName.RV); String markup = null; if (rich != null) { markup = rich.toString(); } return markup; } /**
/** * Retrieve the rich value for the given field * @param name * @return The rich value if present, or null. * @since 5.0.6 */ public String getFieldRichValue(String name) { if (xfa.isXfaPresent()) { return null; } Item item = fields.get(name); if (item == null) { return null; } PdfDictionary merged = item.getMerged(0); PdfString rich = merged.getAsString(PdfName.RV); String markup = null; if (rich != null) { markup = rich.toString(); } return markup; } /**
layer = (PdfLayer) pdfOCG; if (layer.getTitle() == null) { key = layer.getAsString(PdfName.NAME).toString(); } else { key = layer.getTitle();
layer = (PdfLayer) pdfOCG; if (layer.getTitle() == null) { key = layer.getAsString(PdfName.NAME).toString(); } else { key = layer.getTitle();
PdfReader reader = new PdfReader(resourceStream); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("target/test-outputs/test-annotated-edited.pdf")); PdfDictionary page1 = reader.getPageNRelease(1); PdfArray annots = page1.getAsArray(PdfName.ANNOTS); for (int i = 0; i < annots.size(); i++) { PdfDictionary annot = annots.getAsDict(i); PdfString contents = annot.getAsString(PdfName.CONTENTS); if (contents != null) { String value = contents.toString(); StringBuilder builder = new StringBuilder(value); value = builder.reverse().toString(); annot.put(PdfName.CONTENTS, new PdfString(value)); annot.remove(PdfName.AP); } stamper.markUsed(annot); } stamper.close();