public static Hashtable ReadTree(PdfDictionary dic) { Hashtable items = new Hashtable(); if (dic != null) IterateItems(dic, items); return items; }
// methods internal void Add(PdfName key, PdfDictionary resource) { if (resource.Size == 0) return; PdfDictionary dic = GetAsDict(key); if (dic == null) Put(key, resource); else dic.Merge(resource); }
internal PdfMediaClipData(String file, PdfFileSpecification fs, String mimeType) { Put(PdfName.TYPE,new PdfName("MediaClip")); Put(PdfName.S, new PdfName("MCD")); Put(PdfName.N, new PdfString("Media clip for "+file)); Put(new PdfName("CT"), new PdfString(mimeType)); PdfDictionary dic = new PdfDictionary(); dic.Put(new PdfName("TF"), new PdfString("TEMPACCESS")); Put(new PdfName("P"), dic); Put(PdfName.D, fs.Reference); }
public PRStream(PRStream stream, PdfDictionary newDic) { reader = stream.reader; offset = stream.offset; length = stream.Length; compressed = stream.compressed; compressionLevel = stream.compressionLevel; streamBytes = stream.streamBytes; bytes = stream.bytes; objNum = stream.objNum; objGen = stream.objGen; if (newDic != null) Merge(newDic); else Merge(stream); }
internal PageStamp(PdfReader reader, PdfDictionary pageN, PdfCopy cstp) { this.pageN = pageN; this.reader = reader; this.cstp = cstp; }
private static void IterateItems(PdfDictionary dic, Hashtable items) { PdfArray nn = (PdfArray)PdfReader.GetPdfObjectRelease(dic.Get(PdfName.NAMES)); if (nn != null) { for (int k = 0; k < nn.Size; ++k) { PdfString s = (PdfString)PdfReader.GetPdfObjectRelease(nn[k++]); items[PdfEncodings.ConvertToString(s.GetBytes(), null)] = nn[k]; } } else if ((nn = (PdfArray)PdfReader.GetPdfObjectRelease(dic.Get(PdfName.KIDS))) != null) { for (int k = 0; k < nn.Size; ++k) { PdfDictionary kid = (PdfDictionary)PdfReader.GetPdfObjectRelease(nn[k]); IterateItems(kid, items); } } }
/** * @see com.lowagie.text.pdf.interfaces.PdfVersion#addDeveloperExtension(com.lowagie.text.pdf.PdfDeveloperExtension) * @since 2.1.6 */ public void AddDeveloperExtension(PdfDeveloperExtension de) { if (extensions == null) { extensions = new PdfDictionary(); } else { PdfDictionary extension = extensions.GetAsDict(de.Prefix); if (extension != null) { int diff = de.Baseversion.CompareTo(extension.GetAsName(PdfName.BASEVERSION)); if (diff < 0) return; diff = de.ExtensionLevel - extension.GetAsNumber(PdfName.EXTENSIONLEVEL).IntValue; if (diff <= 0) return; } } extensions.Put(de.Prefix, de.GetDeveloperExtensions()); }
private PdfDictionary GetFontBaseType(PdfIndirectReference CIDFont) { PdfDictionary dic = new PdfDictionary(PdfName.FONT); dic.Put(PdfName.SUBTYPE, PdfName.TYPE0); string name = fontName; if (style.Length > 0) name += "-" + style.Substring(1); name += "-" + CMap; dic.Put(PdfName.BASEFONT, new PdfName(name)); dic.Put(PdfName.ENCODING, new PdfName(CMap)); dic.Put(PdfName.DESCENDANTFONTS, new PdfArray(CIDFont)); return dic; }
/// <summary> /// Constructs an Image object duplicate. /// </summary> /// <param name="image">another Image object.</param> public Image(Image image) : base(image) { this.type = image.type; this.url = image.url; this.alignment = image.alignment; this.alt = image.alt; this.absoluteX = image.absoluteX; this.absoluteY = image.absoluteY; this.plainWidth = image.plainWidth; this.plainHeight = image.plainHeight; this.scaledWidth = image.scaledWidth; this.scaledHeight = image.scaledHeight; this.rotationRadians = image.rotationRadians; this.indentationLeft = image.indentationLeft; this.indentationRight = image.indentationRight; this.colorspace = image.colorspace; this.rawData = image.rawData; this.template = image.template; this.bpc = image.bpc; this.transparency = image.transparency; this.mySerialId = image.mySerialId; this.invert = image.invert; this.dpiX = image.dpiX; this.dpiY = image.dpiY; this.mask = image.mask; this.imageMask = image.imageMask; this.interpolation = image.interpolation; this.annotation = image.annotation; this.profile = image.profile; this.deflated = image.deflated; this.additional = image.additional; this.smask = image.smask; this.XYRatio = image.XYRatio; this.originalData = image.originalData; this.originalType = image.originalType; this.spacingAfter = image.spacingAfter; this.spacingBefore = image.spacingBefore; this.widthPercentage = image.widthPercentage; this.layer = image.layer; this.initialRotation = image.initialRotation; this.directReference = image.directReference; }
public void DecodeGenericDictionary(PdfDictionary merged, BaseField tx) { int flags = 0; // the text size and color PdfString da = merged.GetAsString(PdfName.DA); if (da != null) { Object[] dab = SplitDAelements(da.ToUnicodeString()); if (dab[DA_SIZE] != null) tx.FontSize = (float)dab[DA_SIZE]; if (dab[DA_COLOR] != null) tx.TextColor = (Color)dab[DA_COLOR]; if (dab[DA_FONT] != null) { PdfDictionary font = merged.GetAsDict(PdfName.DR); if (font != null) { font = font.GetAsDict(PdfName.FONT); if (font != null) { PdfObject po = font.Get(new PdfName((String)dab[DA_FONT])); if (po != null && po.Type == PdfObject.INDIRECT) { PRIndirectReference por = (PRIndirectReference)po; BaseFont bp = new DocumentFont((PRIndirectReference)po); tx.Font = bp; int porkey = por.Number; BaseFont porf = (BaseFont)extensionFonts[porkey]; if (porf == null) { if (!extensionFonts.ContainsKey(porkey)) { PdfDictionary fo = (PdfDictionary)PdfReader.GetPdfObject(po); PdfDictionary fd = fo.GetAsDict(PdfName.FONTDESCRIPTOR); if (fd != null) { PRStream prs = (PRStream)PdfReader.GetPdfObject(fd.Get(PdfName.FONTFILE2)); if (prs == null) prs = (PRStream)PdfReader.GetPdfObject(fd.Get(PdfName.FONTFILE3)); if (prs == null) { extensionFonts[porkey] = null; } else { try { porf = BaseFont.CreateFont("font.ttf", BaseFont.IDENTITY_H, true, false, PdfReader.GetStreamBytes(prs), null); } catch { } extensionFonts[porkey] = porf; } } } } if (tx is TextField) ((TextField)tx).ExtensionFont = porf; } else { BaseFont bf = (BaseFont)localFonts[dab[DA_FONT]]; if (bf == null) { String[] fn = (String[])stdFieldFontNames[dab[DA_FONT]]; if (fn != null) { try { String enc = "winansi"; if (fn.Length > 1) enc = fn[1]; bf = BaseFont.CreateFont(fn[0], enc, false); tx.Font = bf; } catch { // empty } } } else tx.Font = bf; } } } } } //rotation, border and backgound color PdfDictionary mk = merged.GetAsDict(PdfName.MK); if (mk != null) { PdfArray ar = mk.GetAsArray(PdfName.BC); Color border = GetMKColor(ar); tx.BorderColor = border; if (border != null) tx.BorderWidth = 1; ar = mk.GetAsArray(PdfName.BG); tx.BackgroundColor = GetMKColor(ar); PdfNumber rotation = mk.GetAsNumber(PdfName.R); if (rotation != null) tx.Rotation = rotation.IntValue; } //flags PdfNumber nfl = merged.GetAsNumber(PdfName.F); flags = 0; tx.Visibility = BaseField.VISIBLE_BUT_DOES_NOT_PRINT; if (nfl != null) { flags = nfl.IntValue; if ((flags & PdfFormField.FLAGS_PRINT) != 0 && (flags & PdfFormField.FLAGS_HIDDEN) != 0) tx.Visibility = BaseField.HIDDEN; else if ((flags & PdfFormField.FLAGS_PRINT) != 0 && (flags & PdfFormField.FLAGS_NOVIEW) != 0) tx.Visibility = BaseField.HIDDEN_BUT_PRINTABLE; else if ((flags & PdfFormField.FLAGS_PRINT) != 0) tx.Visibility = BaseField.VISIBLE; } //multiline nfl = merged.GetAsNumber(PdfName.FF); flags = 0; if (nfl != null) flags = nfl.IntValue; tx.Options = flags; if ((flags & PdfFormField.FF_COMB) != 0) { PdfNumber maxLen = merged.GetAsNumber(PdfName.MAXLEN); int len = 0; if (maxLen != null) len = maxLen.IntValue; tx.MaxCharacterLength = len; } //alignment nfl = merged.GetAsNumber(PdfName.Q); if (nfl != null) { if (nfl.IntValue == PdfFormField.Q_CENTER) tx.Alignment = Element.ALIGN_CENTER; else if (nfl.IntValue == PdfFormField.Q_RIGHT) tx.Alignment = Element.ALIGN_RIGHT; } //border styles PdfDictionary bs = merged.GetAsDict(PdfName.BS); if (bs != null) { PdfNumber w = bs.GetAsNumber(PdfName.W); if (w != null) tx.BorderWidth = w.FloatValue; PdfName s = bs.GetAsName(PdfName.S); if (PdfName.D.Equals(s)) tx.BorderStyle = PdfBorderDictionary.STYLE_DASHED; else if (PdfName.B.Equals(s)) tx.BorderStyle = PdfBorderDictionary.STYLE_BEVELED; else if (PdfName.I.Equals(s)) tx.BorderStyle = PdfBorderDictionary.STYLE_INSET; else if (PdfName.U.Equals(s)) tx.BorderStyle = PdfBorderDictionary.STYLE_UNDERLINE; } else { PdfArray bd = merged.GetAsArray(PdfName.BORDER); if (bd != null) { if (bd.Size >= 3) tx.BorderWidth = bd.GetAsNumber(2).FloatValue; if (bd.Size >= 4) tx.BorderStyle = PdfBorderDictionary.STYLE_DASHED; } } }
private void AddASEvent(PdfName eventa, PdfName category) { PdfArray arr = new PdfArray(); foreach (PdfLayer layer in documentOCG.Keys) { PdfDictionary usage = (PdfDictionary)layer.Get(PdfName.USAGE); if (usage != null && usage.Get(category) != null) arr.Add(layer.Ref); } if (arr.Size == 0) return; PdfDictionary d = (PdfDictionary)vOCProperties.Get(PdfName.D); PdfArray arras = (PdfArray)d.Get(PdfName.AS); if (arras == null) { arras = new PdfArray(); d.Put(PdfName.AS, arras); } PdfDictionary asa = new PdfDictionary(); asa.Put(PdfName.EVENT, eventa); asa.Put(PdfName.CATEGORY, new PdfArray(category)); asa.Put(PdfName.OCGS, arr); arras.Add(asa); }
private static String GetNameString(PdfDictionary dic, PdfName key) { PdfObject obj = PdfReader.GetPdfObject(dic.Get(key)); if (obj == null || !obj.IsString()) return null; return ((PdfString)obj).ToUnicodeString(); }
// PDF Catalog /* * The Catalog is also called the root object of the document. * Whereas the Cross-Reference maps the objects number with the * byte offset so that the viewer can find the objects, the * Catalog tells the viewer the numbers of the objects needed * to render the document. */ protected virtual PdfDictionary GetCatalog(PdfIndirectReference rootObj) { PdfDictionary catalog = pdf.GetCatalog(rootObj); // [F12] tagged PDF if (tagged) { this.StructureTreeRoot.BuildTree(); catalog.Put(PdfName.STRUCTTREEROOT, structureTreeRoot.Reference); 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.Count != 0) { FillOCProperties(false); catalog.Put(PdfName.OCPROPERTIES, vOCProperties); } return catalog; }
protected void FillOCProperties(bool erase) { if (vOCProperties == null) vOCProperties = new PdfOCProperties(); if (erase) { vOCProperties.Remove(PdfName.OCGS); vOCProperties.Remove(PdfName.D); } if (vOCProperties.Get(PdfName.OCGS) == null) { PdfArray gr = new PdfArray(); foreach (PdfLayer layer in documentOCG.Keys) { gr.Add(layer.Ref); } vOCProperties.Put(PdfName.OCGS, gr); } if (vOCProperties.Get(PdfName.D) != null) return; ArrayList docOrder = new ArrayList(documentOCGorder); for (ListIterator it = new ListIterator(docOrder); it.HasNext();) { PdfLayer layer = (PdfLayer)it.Next(); if (layer.Parent != null) it.Remove(); } PdfArray order = new PdfArray(); foreach (PdfLayer layer in docOrder) { GetOCGOrder(order, layer); } PdfDictionary d = new PdfDictionary(); vOCProperties.Put(PdfName.D, d); d.Put(PdfName.ORDER, order); PdfArray grx = new PdfArray(); foreach (PdfLayer layer in documentOCG.Keys) { if (!layer.On) grx.Add(layer.Ref); } if (grx.Size > 0) d.Put(PdfName.OFF, grx); 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); }
protected internal void WriteOutlines(PdfDictionary catalog, bool namedAsNames) { if (newBookmarks == null || newBookmarks.Count == 0) return; PdfDictionary top = new PdfDictionary(); PdfIndirectReference topRef = this.PdfIndirectReference; 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((int)kids[2])); AddToBody(top, topRef); catalog.Put(PdfName.OUTLINES, topRef); }
/** * Gets the button appearance. * @throws IOException on error * @throws DocumentException on error * @return the button appearance */ public PdfAppearance GetAppearance() { PdfAppearance app = GetBorderAppearance(); Rectangle box = new Rectangle(app.BoundingBox); if ((text == null || text.Length == 0) && (layout == LAYOUT_LABEL_ONLY || (image == null && template == null && iconReference == null))) { return(app); } if (layout == LAYOUT_ICON_ONLY && image == null && template == null && iconReference == null) { return(app); } BaseFont ufont = RealFont; bool borderExtra = borderStyle == PdfBorderDictionary.STYLE_BEVELED || borderStyle == PdfBorderDictionary.STYLE_INSET; float h = box.Height - borderWidth * 2; float bw2 = borderWidth; if (borderExtra) { h -= borderWidth * 2; bw2 *= 2; } float offsetX = (borderExtra ? 2 * borderWidth : borderWidth); offsetX = Math.Max(offsetX, 1); float offX = Math.Min(bw2, offsetX); tp = null; float textX = float.NaN; float textY = 0; float fsize = fontSize; float wt = box.Width - 2 * offX - 2; float ht = box.Height - 2 * offX; float adj = (iconFitToBounds ? 0 : offX + 1); int nlayout = layout; if (image == null && template == null && iconReference == null) { nlayout = LAYOUT_LABEL_ONLY; } Rectangle iconBox = null; while (true) { switch (nlayout) { case LAYOUT_LABEL_ONLY: case LAYOUT_LABEL_OVER_ICON: if (text != null && text.Length > 0 && wt > 0 && ht > 0) { fsize = CalculateFontSize(wt, ht); textX = (box.Width - ufont.GetWidthPoint(text, fsize)) / 2; textY = (box.Height - ufont.GetFontDescriptor(BaseFont.ASCENT, fsize)) / 2; } goto case LAYOUT_ICON_ONLY; case LAYOUT_ICON_ONLY: if (nlayout == LAYOUT_LABEL_OVER_ICON || nlayout == LAYOUT_ICON_ONLY) { iconBox = new Rectangle(box.Left + adj, box.Bottom + adj, box.Right - adj, box.Top - adj); } break; case LAYOUT_ICON_TOP_LABEL_BOTTOM: if (text == null || text.Length == 0 || wt <= 0 || ht <= 0) { nlayout = LAYOUT_ICON_ONLY; continue; } float nht = box.Height * 0.35f - offX; if (nht > 0) { fsize = CalculateFontSize(wt, nht); } else { fsize = 4; } textX = (box.Width - ufont.GetWidthPoint(text, fsize)) / 2; textY = offX - ufont.GetFontDescriptor(BaseFont.DESCENT, fsize); iconBox = new Rectangle(box.Left + adj, textY + fsize, box.Right - adj, box.Top - adj); break; case LAYOUT_LABEL_TOP_ICON_BOTTOM: if (text == null || text.Length == 0 || wt <= 0 || ht <= 0) { nlayout = LAYOUT_ICON_ONLY; continue; } nht = box.Height * 0.35f - offX; if (nht > 0) { fsize = CalculateFontSize(wt, nht); } else { fsize = 4; } textX = (box.Width - ufont.GetWidthPoint(text, fsize)) / 2; textY = box.Height - offX - fsize; if (textY < offX) { textY = offX; } iconBox = new Rectangle(box.Left + adj, box.Bottom + adj, box.Right - adj, textY + ufont.GetFontDescriptor(BaseFont.DESCENT, fsize)); break; case LAYOUT_LABEL_LEFT_ICON_RIGHT: if (text == null || text.Length == 0 || wt <= 0 || ht <= 0) { nlayout = LAYOUT_ICON_ONLY; continue; } float nw = box.Width * 0.35f - offX; if (nw > 0) { fsize = CalculateFontSize(wt, nw); } else { fsize = 4; } if (ufont.GetWidthPoint(text, fsize) >= wt) { nlayout = LAYOUT_LABEL_ONLY; fsize = fontSize; continue; } textX = offX + 1; textY = (box.Height - ufont.GetFontDescriptor(BaseFont.ASCENT, fsize)) / 2; iconBox = new Rectangle(textX + ufont.GetWidthPoint(text, fsize), box.Bottom + adj, box.Right - adj, box.Top - adj); break; case LAYOUT_ICON_LEFT_LABEL_RIGHT: if (text == null || text.Length == 0 || wt <= 0 || ht <= 0) { nlayout = LAYOUT_ICON_ONLY; continue; } nw = box.Width * 0.35f - offX; if (nw > 0) { fsize = CalculateFontSize(wt, nw); } else { fsize = 4; } if (ufont.GetWidthPoint(text, fsize) >= wt) { nlayout = LAYOUT_LABEL_ONLY; fsize = fontSize; continue; } textX = box.Width - ufont.GetWidthPoint(text, fsize) - offX - 1; textY = (box.Height - ufont.GetFontDescriptor(BaseFont.ASCENT, fsize)) / 2; iconBox = new Rectangle(box.Left + adj, box.Bottom + adj, textX - 1, box.Top - adj); break; } break; } if (textY < box.Bottom + offX) { textY = box.Bottom + offX; } if (iconBox != null && (iconBox.Width <= 0 || iconBox.Height <= 0)) { iconBox = null; } bool haveIcon = false; float boundingBoxWidth = 0; float boundingBoxHeight = 0; PdfArray matrix = null; if (iconBox != null) { if (image != null) { tp = new PdfTemplate(writer); tp.BoundingBox = new Rectangle(image); writer.AddDirectTemplateSimple(tp, PdfName.FRM); tp.AddImage(image, image.Width, 0, 0, image.Height, 0, 0); haveIcon = true; boundingBoxWidth = tp.BoundingBox.Width; boundingBoxHeight = tp.BoundingBox.Height; } else if (template != null) { tp = new PdfTemplate(writer); tp.BoundingBox = new Rectangle(template.Width, template.Height); writer.AddDirectTemplateSimple(tp, PdfName.FRM); tp.AddTemplate(template, template.BoundingBox.Left, template.BoundingBox.Bottom); haveIcon = true; boundingBoxWidth = tp.BoundingBox.Width; boundingBoxHeight = tp.BoundingBox.Height; } else if (iconReference != null) { PdfDictionary dic = (PdfDictionary)PdfReader.GetPdfObject(iconReference); if (dic != null) { Rectangle r2 = PdfReader.GetNormalizedRectangle(dic.GetAsArray(PdfName.BBOX)); matrix = dic.GetAsArray(PdfName.MATRIX); haveIcon = true; boundingBoxWidth = r2.Width; boundingBoxHeight = r2.Height; } } } if (haveIcon) { float icx = iconBox.Width / boundingBoxWidth; float icy = iconBox.Height / boundingBoxHeight; if (proportionalIcon) { switch (scaleIcon) { case SCALE_ICON_IS_TOO_BIG: icx = Math.Min(icx, icy); icx = Math.Min(icx, 1); break; case SCALE_ICON_IS_TOO_SMALL: icx = Math.Min(icx, icy); icx = Math.Max(icx, 1); break; case SCALE_ICON_NEVER: icx = 1; break; default: icx = Math.Min(icx, icy); break; } icy = icx; } else { switch (scaleIcon) { case SCALE_ICON_IS_TOO_BIG: icx = Math.Min(icx, 1); icy = Math.Min(icy, 1); break; case SCALE_ICON_IS_TOO_SMALL: icx = Math.Max(icx, 1); icy = Math.Max(icy, 1); break; case SCALE_ICON_NEVER: icx = icy = 1; break; default: break; } } float xpos = iconBox.Left + (iconBox.Width - (boundingBoxWidth * icx)) * iconHorizontalAdjustment; float ypos = iconBox.Bottom + (iconBox.Height - (boundingBoxHeight * icy)) * iconVerticalAdjustment; app.SaveState(); app.Rectangle(iconBox.Left, iconBox.Bottom, iconBox.Width, iconBox.Height); app.Clip(); app.NewPath(); if (tp != null) { app.AddTemplate(tp, icx, 0, 0, icy, xpos, ypos); } else { float cox = 0; float coy = 0; if (matrix != null && matrix.Size == 6) { PdfNumber nm = matrix.GetAsNumber(4); if (nm != null) { cox = nm.FloatValue; } nm = matrix.GetAsNumber(5); if (nm != null) { coy = nm.FloatValue; } } app.AddTemplateReference(iconReference, PdfName.FRM, icx, 0, 0, icy, xpos - cox * icx, ypos - coy * icy); } app.RestoreState(); } if (!float.IsNaN(textX)) { app.SaveState(); app.Rectangle(offX, offX, box.Width - 2 * offX, box.Height - 2 * offX); app.Clip(); app.NewPath(); if (textColor == null) { app.ResetGrayFill(); } else { app.SetColorFill(textColor); } app.BeginText(); app.SetFontAndSize(ufont, fsize); app.SetTextMatrix(textX, textY); app.ShowText(text); app.EndText(); app.RestoreState(); } return(app); }
/** * Add a value dict to this Item * * @since 2.1.5 * @param value new value dictionary */ internal void AddValue(PdfDictionary value) { values.Add(value); }
/** * Add a widget dict to this Item * * @since 2.1.5 * @param widget */ internal void AddWidget(PdfDictionary widget) { widgets.Add(widget); }
/** Sets the field value and the display string. The display string * is used to build the appearance in the cases where the value * is modified by Acrobat with JavaScript and the algorithm is * known. * @param name the fully qualified field name or the partial name in the case of XFA forms * @param value the field value * @param display the string that is used for the appearance. If <CODE>null</CODE> * the <CODE>value</CODE> parameter will be used * @return <CODE>true</CODE> if the field was found and changed, * <CODE>false</CODE> otherwise * @throws IOException on error * @throws DocumentException on error */ public bool SetField(String name, String value, String display) { if (writer == null) throw new DocumentException("This AcroFields instance is read-only."); if (xfa.XfaPresent) { name = xfa.FindFieldName(name, this); if (name == null) return false; String shortName = XfaForm.Xml2Som.GetShortName(name); XmlNode xn = xfa.FindDatasetsNode(shortName); if (xn == null) { xn = xfa.DatasetsSom.InsertNode(xfa.DatasetsNode, shortName); } xfa.SetNodeText(xn, value); } Item item = (Item)fields[name]; if (item == null) return false; PdfDictionary merged = item.GetMerged( 0 ); PdfName type = merged.GetAsName(PdfName.FT); if (PdfName.TX.Equals(type)) { PdfNumber maxLen = merged.GetAsNumber(PdfName.MAXLEN); int len = 0; if (maxLen != null) len = maxLen.IntValue; if (len > 0) value = value.Substring(0, Math.Min(len, value.Length)); } if (display == null) display = value; if (PdfName.TX.Equals(type) || PdfName.CH.Equals(type)) { PdfString v = new PdfString(value, PdfObject.TEXT_UNICODE); for (int idx = 0; idx < item.Size; ++idx) { PdfDictionary valueDic = item.GetValue(idx); valueDic.Put(PdfName.V, v); valueDic.Remove(PdfName.I); MarkUsed(valueDic); merged = item.GetMerged(idx); merged.Remove(PdfName.I); merged.Put(PdfName.V, v); PdfDictionary widget = item.GetWidget(idx); if (generateAppearances) { PdfAppearance app = GetAppearance(merged, display, name); if (PdfName.CH.Equals(type)) { PdfNumber n = new PdfNumber(topFirst); widget.Put(PdfName.TI, n); merged.Put(PdfName.TI, n); } PdfDictionary appDic = widget.GetAsDict(PdfName.AP); if (appDic == null) { appDic = new PdfDictionary(); widget.Put(PdfName.AP, appDic); merged.Put(PdfName.AP, appDic); } appDic.Put(PdfName.N, app.IndirectReference); writer.ReleaseTemplate(app); } else { widget.Remove(PdfName.AP); merged.Remove(PdfName.AP); } MarkUsed(widget); } return true; } else if (PdfName.BTN.Equals(type)) { PdfNumber ff = item.GetMerged(0).GetAsNumber(PdfName.FF); int flags = 0; if (ff != null) flags = ff.IntValue; if ((flags & PdfFormField.FF_PUSHBUTTON) != 0) { //we'll assume that the value is an image in base64 Image img; try { img = Image.GetInstance(Convert.FromBase64String(value)); } catch { return false; } PushbuttonField pb = GetNewPushbuttonFromField(name); pb.Image = img; ReplacePushbuttonField(name, pb.Field); return true; } PdfName v = new PdfName(value); ArrayList lopt = new ArrayList(); PdfArray opts = item.GetValue(0).GetAsArray(PdfName.OPT); if (opts != null) { for (int k = 0; k < opts.Size; ++k) { PdfString valStr = opts.GetAsString(k); if (valStr != null) lopt.Add(valStr.ToUnicodeString()); else lopt.Add(null); } } int vidx = lopt.IndexOf(value); PdfName valt = null; PdfName vt; if (vidx >= 0) { vt = valt = new PdfName(vidx.ToString()); } else vt = v; for (int idx = 0; idx < item.Size; ++idx) { merged = item.GetMerged(idx); PdfDictionary widget = item.GetWidget(idx); PdfDictionary valDict = item.GetValue(idx); MarkUsed(item.GetValue(idx)); if (valt != null) { PdfString ps = new PdfString(value, PdfObject.TEXT_UNICODE); valDict.Put(PdfName.V, ps); merged.Put(PdfName.V, ps); } else { valDict.Put(PdfName.V, v); merged.Put(PdfName.V, v); } MarkUsed(widget); if (IsInAP(widget, vt)) { merged.Put(PdfName.AS, vt); widget.Put(PdfName.AS, vt); } else { merged.Put(PdfName.AS, PdfName.Off_); widget.Put(PdfName.AS, PdfName.Off_); } } return true; } return false; }
/** Adds or replaces a page label. * @param page the real page to start the numbering. First page is 1 * @param numberStyle the numbering style such as LOWERCASE_ROMAN_NUMERALS * @param text the text to prefix the number. Can be <CODE>null</CODE> or empty * @param firstPage the first logical page number */ public void AddPageLabel(int page, int numberStyle, string text, int firstPage) { if (page < 1 || firstPage < 1) throw new ArgumentException("In a page label the page numbers must be greater or equal to 1."); PdfDictionary dic = new PdfDictionary(); if (numberStyle >= 0 && numberStyle < numberingStyle.Length) dic.Put(PdfName.S, numberingStyle[numberStyle]); if (text != null) dic.Put(PdfName.P, new PdfString(text, PdfObject.TEXT_UNICODE)); if (firstPage != 1) dic.Put(PdfName.ST, new PdfNumber(firstPage)); map[page - 1] = dic; }
/** * Sets a field property. Valid property names are: * <p> * <ul> * <li>textfont - sets the text font. The value for this entry is a <CODE>BaseFont</CODE>.<br> * <li>textcolor - sets the text color. The value for this entry is a <CODE>java.awt.Color</CODE>.<br> * <li>textsize - sets the text size. The value for this entry is a <CODE>Float</CODE>. * <li>bgcolor - sets the background color. The value for this entry is a <CODE>java.awt.Color</CODE>. * If <code>null</code> removes the background.<br> * <li>bordercolor - sets the border color. The value for this entry is a <CODE>java.awt.Color</CODE>. * If <code>null</code> removes the border.<br> * </ul> * @param field the field name * @param name the property name * @param value the property value * @param inst an array of <CODE>int</CODE> indexing into <CODE>AcroField.Item.merged</CODE> elements to process. * Set to <CODE>null</CODE> to process all * @return <CODE>true</CODE> if the property exists, <CODE>false</CODE> otherwise */ public bool SetFieldProperty(String field, String name, Object value, int[] inst) { if (writer == null) throw new Exception("This AcroFields instance is read-only."); Item item = (Item)fields[field]; if (item == null) return false; InstHit hit = new InstHit(inst); PdfDictionary merged; PdfString da; if (Util.EqualsIgnoreCase(name, "textfont")) { for (int k = 0; k < item.Size; ++k) { if (hit.IsHit(k)) { merged = item.GetMerged( k ); da = merged.GetAsString(PdfName.DA); PdfDictionary dr = merged.GetAsDict(PdfName.DR); if (da != null && dr != null) { Object[] dao = SplitDAelements(da.ToUnicodeString()); PdfAppearance cb = new PdfAppearance(); if (dao[DA_FONT] != null) { BaseFont bf = (BaseFont)value; PdfName psn = (PdfName)PdfAppearance.stdFieldFontNames[bf.PostscriptFontName]; if (psn == null) { psn = new PdfName(bf.PostscriptFontName); } PdfDictionary fonts = dr.GetAsDict(PdfName.FONT); if (fonts == null) { fonts = new PdfDictionary(); dr.Put(PdfName.FONT, fonts); } PdfIndirectReference fref = (PdfIndirectReference)fonts.Get(psn); PdfDictionary top = reader.Catalog.GetAsDict(PdfName.ACROFORM); MarkUsed(top); dr = top.GetAsDict(PdfName.DR); if (dr == null) { dr = new PdfDictionary(); top.Put(PdfName.DR, dr); } MarkUsed(dr); PdfDictionary fontsTop = dr.GetAsDict(PdfName.FONT); if (fontsTop == null) { fontsTop = new PdfDictionary(); dr.Put(PdfName.FONT, fontsTop); } MarkUsed(fontsTop); PdfIndirectReference frefTop = (PdfIndirectReference)fontsTop.Get(psn); if (frefTop != null) { if (fref == null) fonts.Put(psn, frefTop); } else if (fref == null) { FontDetails fd; if (bf.FontType == BaseFont.FONT_TYPE_DOCUMENT) { fd = new FontDetails(null, ((DocumentFont)bf).IndirectReference, bf); } else { bf.Subset = false; fd = writer.AddSimple(bf); localFonts[psn.ToString().Substring(1)] = bf; } fontsTop.Put(psn, fd.IndirectReference); fonts.Put(psn, fd.IndirectReference); } ByteBuffer buf = cb.InternalBuffer; buf.Append(psn.GetBytes()).Append(' ').Append((float)dao[DA_SIZE]).Append(" Tf "); if (dao[DA_COLOR] != null) cb.SetColorFill((Color)dao[DA_COLOR]); PdfString s = new PdfString(cb.ToString()); item.GetMerged(k).Put(PdfName.DA, s); item.GetWidget(k).Put(PdfName.DA, s); MarkUsed(item.GetWidget(k)); } } } } } else if (Util.EqualsIgnoreCase(name, "textcolor")) { for (int k = 0; k < item.Size; ++k) { if (hit.IsHit(k)) { merged = item.GetMerged( k ); da = merged.GetAsString(PdfName.DA); if (da != null) { Object[] dao = SplitDAelements(da.ToUnicodeString()); PdfAppearance cb = new PdfAppearance(); if (dao[DA_FONT] != null) { ByteBuffer buf = cb.InternalBuffer; buf.Append(new PdfName((String)dao[DA_FONT]).GetBytes()).Append(' ').Append((float)dao[DA_SIZE]).Append(" Tf "); cb.SetColorFill((Color)value); PdfString s = new PdfString(cb.ToString()); item.GetMerged(k).Put(PdfName.DA, s); item.GetWidget(k).Put(PdfName.DA, s); MarkUsed(item.GetWidget(k)); } } } } } else if (Util.EqualsIgnoreCase(name, "textsize")) { for (int k = 0; k < item.Size; ++k) { if (hit.IsHit(k)) { merged = item.GetMerged( k ); da = merged.GetAsString(PdfName.DA); if (da != null) { Object[] dao = SplitDAelements(da.ToUnicodeString()); PdfAppearance cb = new PdfAppearance(); if (dao[DA_FONT] != null) { ByteBuffer buf = cb.InternalBuffer; buf.Append(new PdfName((String)dao[DA_FONT]).GetBytes()).Append(' ').Append((float)value).Append(" Tf "); if (dao[DA_COLOR] != null) cb.SetColorFill((Color)dao[DA_COLOR]); PdfString s = new PdfString(cb.ToString()); item.GetMerged(k).Put(PdfName.DA, s); item.GetWidget(k).Put(PdfName.DA, s); MarkUsed(item.GetWidget(k)); } } } } } else if (Util.EqualsIgnoreCase(name, "bgcolor") || Util.EqualsIgnoreCase(name, "bordercolor")) { PdfName dname = (Util.EqualsIgnoreCase(name, "bgcolor") ? PdfName.BG : PdfName.BC); for (int k = 0; k < item.Size; ++k) { if (hit.IsHit(k)) { merged = item.GetMerged( k ); PdfDictionary mk = merged.GetAsDict(PdfName.MK); if (mk == null) { if (value == null) return true; mk = new PdfDictionary(); item.GetMerged(k).Put(PdfName.MK, mk); item.GetWidget(k).Put(PdfName.MK, mk); MarkUsed(item.GetWidget(k)); } else { MarkUsed( mk ); } if (value == null) mk.Remove(dname); else mk.Put(dname, PdfFormField.GetMKColor((Color)value)); } } } else return false; return true; }
private PdfDictionary GetCIDFont(PdfIndirectReference fontDescriptor, IntHashtable cjkTag) { PdfDictionary dic = new PdfDictionary(PdfName.FONT); dic.Put(PdfName.SUBTYPE, PdfName.CIDFONTTYPE0); dic.Put(PdfName.BASEFONT, new PdfName(fontName + style)); dic.Put(PdfName.FONTDESCRIPTOR, fontDescriptor); int[] keys = cjkTag.ToOrderedKeys(); string w = ConvertToHCIDMetrics(keys, hMetrics); if (w != null) dic.Put(PdfName.W, new PdfLiteral(w)); if (vertical) { w = ConvertToVCIDMetrics(keys, vMetrics, hMetrics); if (w != null) dic.Put(PdfName.W2, new PdfLiteral(w)); } else dic.Put(PdfName.DW, new PdfNumber(1000)); PdfDictionary cdic = new PdfDictionary(); cdic.Put(PdfName.REGISTRY, new PdfString((string)fontDesc["Registry"], null)); cdic.Put(PdfName.ORDERING, new PdfString((string)fontDesc["Ordering"], null)); cdic.Put(PdfName.SUPPLEMENT, new PdfLiteral((string)fontDesc["Supplement"])); dic.Put(PdfName.CIDSYSTEMINFO, cdic); return dic; }
internal void Fill() { fields = new Hashtable(); PdfDictionary top = (PdfDictionary)PdfReader.GetPdfObjectRelease(reader.Catalog.Get(PdfName.ACROFORM)); if (top == null) return; PdfArray arrfds = (PdfArray)PdfReader.GetPdfObjectRelease(top.Get(PdfName.FIELDS)); if (arrfds == null || arrfds.Size == 0) return; for (int k = 1; k <= reader.NumberOfPages; ++k) { PdfDictionary page = reader.GetPageNRelease(k); PdfArray annots = (PdfArray)PdfReader.GetPdfObjectRelease(page.Get(PdfName.ANNOTS), page); if (annots == null) continue; for (int j = 0; j < annots.Size; ++j) { PdfDictionary annot = annots.GetAsDict(j); if (annot == null) { PdfReader.ReleaseLastXrefPartial(annots.GetAsIndirectObject(j)); continue; } if (!PdfName.WIDGET.Equals(annot.GetAsName(PdfName.SUBTYPE))) { PdfReader.ReleaseLastXrefPartial(annots.GetAsIndirectObject(j)); continue; } PdfDictionary widget = annot; PdfDictionary dic = new PdfDictionary(); dic.Merge(annot); String name = ""; PdfDictionary value = null; PdfObject lastV = null; while (annot != null) { dic.MergeDifferent(annot); PdfString t = annot.GetAsString(PdfName.T); if (t != null) name = t.ToUnicodeString() + "." + name; if (lastV == null && annot.Get(PdfName.V) != null) lastV = PdfReader.GetPdfObjectRelease(annot.Get(PdfName.V)); if (value == null && t != null) { value = annot; if (annot.Get(PdfName.V) == null && lastV != null) value.Put(PdfName.V, lastV); } annot = annot.GetAsDict(PdfName.PARENT); } if (name.Length > 0) name = name.Substring(0, name.Length - 1); Item item = (Item)fields[name]; if (item == null) { item = new Item(); fields[name] = item; } if (value == null) item.AddValue(widget); else item.AddValue(value); item.AddWidget(widget); item.AddWidgetRef(annots.GetAsIndirectObject(j)); // must be a reference if (top != null) dic.MergeDifferent(top); item.AddMerged(dic); item.AddPage(k); item.AddTabOrder(j); } } // some tools produce invisible signatures without an entry in the page annotation array // look for a single level annotation PdfNumber sigFlags = top.GetAsNumber(PdfName.SIGFLAGS); if (sigFlags == null || (sigFlags.IntValue & 1) != 1) return; for (int j = 0; j < arrfds.Size; ++j) { PdfDictionary annot = arrfds.GetAsDict(j); if (annot == null) { PdfReader.ReleaseLastXrefPartial(arrfds.GetAsIndirectObject(j)); continue; } if (!PdfName.WIDGET.Equals(annot.GetAsName(PdfName.SUBTYPE))) { PdfReader.ReleaseLastXrefPartial(arrfds.GetAsIndirectObject(j)); continue; } PdfArray kids = (PdfArray)PdfReader.GetPdfObjectRelease(annot.Get(PdfName.KIDS)); if (kids != null) continue; PdfDictionary dic = new PdfDictionary(); dic.Merge(annot); PdfString t = annot.GetAsString(PdfName.T); if (t == null) continue; String name = t.ToUnicodeString(); if (fields.ContainsKey(name)) continue; Item item = new Item(); fields[name] = item; item.AddValue(dic); item.AddWidget(dic); item.AddWidgetRef(arrfds.GetAsIndirectObject(j)); // must be a reference item.AddMerged(dic); item.AddPage(-1); item.AddTabOrder(-1); } }
private PdfDictionary GetFontDescriptor() { PdfDictionary dic = new PdfDictionary(PdfName.FONTDESCRIPTOR); dic.Put(PdfName.ASCENT, new PdfLiteral((String)fontDesc["Ascent"])); dic.Put(PdfName.CAPHEIGHT, new PdfLiteral((String)fontDesc["CapHeight"])); dic.Put(PdfName.DESCENT, new PdfLiteral((String)fontDesc["Descent"])); dic.Put(PdfName.FLAGS, new PdfLiteral((String)fontDesc["Flags"])); dic.Put(PdfName.FONTBBOX, new PdfLiteral((String)fontDesc["FontBBox"])); dic.Put(PdfName.FONTNAME, new PdfName(fontName + style)); dic.Put(PdfName.ITALICANGLE, new PdfLiteral((String)fontDesc["ItalicAngle"])); dic.Put(PdfName.STEMV, new PdfLiteral((String)fontDesc["StemV"])); PdfDictionary pdic = new PdfDictionary(); pdic.Put(PdfName.PANOSE, new PdfString((String)fontDesc["Panose"], null)); dic.Put(PdfName.STYLE, pdic); return dic; }
internal PdfAppearance GetAppearance(PdfDictionary merged, String text, String fieldName) { topFirst = 0; TextField tx = null; if (fieldCache == null || !fieldCache.ContainsKey(fieldName)) { tx = new TextField(writer, null, null); tx.SetExtraMargin(extraMarginLeft, extraMarginTop); tx.BorderWidth = 0; tx.SubstitutionFonts = substitutionFonts; DecodeGenericDictionary(merged, tx); //rect PdfArray rect = merged.GetAsArray(PdfName.RECT); Rectangle box = PdfReader.GetNormalizedRectangle(rect); if (tx.Rotation == 90 || tx.Rotation == 270) box = box.Rotate(); tx.Box = box; if (fieldCache != null) fieldCache[fieldName] = tx; } else { tx = (TextField)fieldCache[fieldName]; tx.Writer = writer; } PdfName fieldType = merged.GetAsName(PdfName.FT); if (PdfName.TX.Equals(fieldType)) { tx.Text = text; return tx.GetAppearance(); } if (!PdfName.CH.Equals(fieldType)) throw new DocumentException("An appearance was requested without a variable text field."); PdfArray opt = merged.GetAsArray(PdfName.OPT); int flags = 0; PdfNumber nfl = merged.GetAsNumber(PdfName.FF); if (nfl != null) flags = nfl.IntValue; if ((flags & PdfFormField.FF_COMBO) != 0 && opt == null) { tx.Text = text; return tx.GetAppearance(); } if (opt != null) { String[] choices = new String[opt.Size]; String[] choicesExp = new String[opt.Size]; for (int k = 0; k < opt.Size; ++k) { PdfObject obj = opt[k]; if (obj.IsString()) { choices[k] = choicesExp[k] = ((PdfString)obj).ToUnicodeString(); } else { PdfArray a = (PdfArray) obj; choicesExp[k] = a.GetAsString(0).ToUnicodeString(); choices[k] = a.GetAsString(1).ToUnicodeString(); } } if ((flags & PdfFormField.FF_COMBO) != 0) { for (int k = 0; k < choices.Length; ++k) { if (text.Equals(choicesExp[k])) { text = choices[k]; break; } } tx.Text = text; return tx.GetAppearance(); } int idx = 0; for (int k = 0; k < choicesExp.Length; ++k) { if (text.Equals(choicesExp[k])) { idx = k; break; } } tx.Choices = choices; tx.ChoiceExports = choicesExp; tx.ChoiceSelection = idx; } PdfAppearance app = tx.GetListAppearance(); topFirst = tx.TopFirst; return app; }
/** Adds the version to the Catalog dictionary. */ public void AddToCatalog(PdfDictionary catalog) { if(catalog_version != null) { catalog.Put(PdfName.VERSION, catalog_version); } if (extensions != null) { catalog.Put(PdfName.EXTENSIONS, extensions); } }
/** * Creates a name tree. * @param items the item of the name tree. The key is a <CODE>String</CODE> * and the value is a <CODE>PdfObject</CODE>. Note that although the * keys are strings only the lower byte is used and no check is made for chars * with the same lower byte and different upper byte. This will generate a wrong * tree name. * @param writer the writer * @throws IOException on error * @return the dictionary with the name tree. This dictionary is the one * generally pointed to by the key /Dests, for example */ public static PdfDictionary WriteTree(Hashtable items, PdfWriter writer) { if (items.Count == 0) return null; String[] names = new String[items.Count]; items.Keys.CopyTo(names, 0); Array.Sort(names); if (names.Length <= leafSize) { PdfDictionary dic = new PdfDictionary(); PdfArray ar = new PdfArray(); for (int k = 0; k < names.Length; ++k) { ar.Add(new PdfString(names[k], null)); ar.Add((PdfObject)items[names[k]]); } dic.Put(PdfName.NAMES, ar); return dic; } int skip = leafSize; PdfIndirectReference[] kids = new PdfIndirectReference[(names.Length + leafSize - 1) / leafSize]; for (int k = 0; k < kids.Length; ++k) { int offset = k * leafSize; int end = Math.Min(offset + leafSize, names.Length); PdfDictionary dic = new PdfDictionary(); PdfArray arr = new PdfArray(); arr.Add(new PdfString(names[offset], null)); arr.Add(new PdfString(names[end - 1], null)); dic.Put(PdfName.LIMITS, arr); arr = new PdfArray(); for (; offset < end; ++offset) { arr.Add(new PdfString(names[offset], null)); arr.Add((PdfObject)items[names[offset]]); } dic.Put(PdfName.NAMES, arr); kids[k] = writer.AddToBody(dic).IndirectReference; } int top = kids.Length; while (true) { if (top <= leafSize) { PdfArray arr = new PdfArray(); for (int k = 0; k < top; ++k) arr.Add(kids[k]); PdfDictionary dic = new PdfDictionary(); dic.Put(PdfName.KIDS, arr); return dic; } skip *= leafSize; int tt = (names.Length + skip - 1 )/ skip; for (int k = 0; k < tt; ++k) { int offset = k * leafSize; int end = Math.Min(offset + leafSize, top); PdfDictionary dic = new PdfDictionary(); PdfArray arr = new PdfArray(); arr.Add(new PdfString(names[k * skip], null)); arr.Add(new PdfString(names[Math.Min((k + 1) * skip, names.Length) - 1], null)); dic.Put(PdfName.LIMITS, arr); arr = new PdfArray(); for (; offset < end; ++offset) { arr.Add(kids[offset]); } dic.Put(PdfName.KIDS, arr); kids[k] = writer.AddToBody(dic).IndirectReference; } top = tt; } }
internal bool IsInAP(PdfDictionary dic, PdfName check) { PdfDictionary appDic = dic.GetAsDict(PdfName.AP); if (appDic == null) return false; PdfDictionary NDic = appDic.GetAsDict(PdfName.N); return (NDic != null && NDic.Get(check) != null); }
/** * Closes the AcroForm. */ public bool IsValid() { if (documentFields.Size == 0) return false; Put(PdfName.FIELDS, documentFields); if (sigFlags != 0) Put(PdfName.SIGFLAGS, new PdfNumber(sigFlags)); if (calculationOrder.Size > 0) Put(PdfName.CO, calculationOrder); if (fieldTemplates.Count == 0) return true; PdfDictionary dic = new PdfDictionary(); foreach (PdfTemplate template in fieldTemplates.Keys) { PdfFormField.MergeResources(dic, (PdfDictionary)template.Resources); } Put(PdfName.DR, dic); Put(PdfName.DA, new PdfString("/Helv 0 Tf 0 g ")); PdfDictionary fonts = (PdfDictionary)dic.Get(PdfName.FONT); if (fonts != null) { writer.EliminateFontSubset(fonts); } return true; }
private void UpdateByteRange(PdfPKCS7 pkcs7, PdfDictionary v) { PdfArray b = v.GetAsArray(PdfName.BYTERANGE); RandomAccessFileOrArray rf = reader.SafeFile; try { rf.ReOpen(); byte[] buf = new byte[8192]; for (int k = 0; k < b.Size; ++k) { int start = b.GetAsNumber(k).IntValue; int length = b.GetAsNumber(++k).IntValue; rf.Seek(start); while (length > 0) { int rd = rf.Read(buf, 0, Math.Min(length, buf.Length)); if (rd <= 0) break; length -= rd; pkcs7.Update(buf, 0, rd); } } } finally { try{rf.Close();}catch{} } }
/** * Adds a merged dictionary to this Item. * * @since 2.1.5 * @param mergeDict */ internal void AddMerged(PdfDictionary mergeDict) { merged.Add(mergeDict); }
/** * @param os * @param info * @throws IOException */ public XmpWriter(Stream os, PdfDictionary info, int PdfXConformance) : this(os) { if (info != null) { DublinCoreSchema dc = new DublinCoreSchema(); PdfSchema p = new PdfSchema(); XmpBasicSchema basic = new XmpBasicSchema(); PdfObject obj; foreach (PdfName key in info.Keys) { obj = info.Get(key); if (obj == null) continue; if (PdfName.TITLE.Equals(key)) { dc.AddTitle(((PdfString)obj).ToUnicodeString()); } if (PdfName.AUTHOR.Equals(key)) { dc.AddAuthor(((PdfString)obj).ToUnicodeString()); } if (PdfName.SUBJECT.Equals(key)) { dc.AddSubject(((PdfString)obj).ToUnicodeString()); dc.AddDescription(((PdfString)obj).ToUnicodeString()); } if (PdfName.KEYWORDS.Equals(key)) { p.AddKeywords(((PdfString)obj).ToUnicodeString()); } if (PdfName.CREATOR.Equals(key)) { basic.AddCreatorTool(((PdfString)obj).ToUnicodeString()); } if (PdfName.PRODUCER.Equals(key)) { p.AddProducer(((PdfString)obj).ToUnicodeString()); } if (PdfName.CREATIONDATE.Equals(key)) { basic.AddCreateDate(((PdfDate)obj).GetW3CDate()); } if (PdfName.MODDATE.Equals(key)) { basic.AddModDate(((PdfDate)obj).GetW3CDate()); } } if (dc.Count > 0) AddRdfDescription(dc); if (p.Count > 0) AddRdfDescription(p); if (basic.Count > 0) AddRdfDescription(basic); if (PdfXConformance == PdfWriter.PDFA1A || PdfXConformance == PdfWriter.PDFA1B) { PdfA1Schema a1 = new PdfA1Schema(); if (PdfXConformance == PdfWriter.PDFA1A) a1.AddConformance("A"); else a1.AddConformance("B"); AddRdfDescription(a1); } } }
internal FieldInformation(String name, PdfDictionary info, PRIndirectReference refi) { this.name = name; this.info = info; this.refi = refi; }