• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# pdf.PdfArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中iTextSharp.text.pdf.PdfArray的典型用法代码示例。如果您正苦于以下问题:C# PdfArray类的具体用法?C# PdfArray怎么用?C# PdfArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PdfArray类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetOCGOrder

 private static void GetOCGOrder(PdfArray order, PdfLayer layer) {
     if (!layer.OnPanel)
         return;
     if (layer.Title == null)
         order.Add(layer.Ref);
     List<PdfLayer> children = layer.Children;
     if (children == null)
         return;
     PdfArray kids = new PdfArray();
     if (layer.Title != null)
         kids.Add(new PdfString(layer.Title, PdfObject.TEXT_UNICODE));
     for (int k = 0; k < children.Count; ++k) {
         GetOCGOrder(kids, children[k]);
     }
     if (kids.Size > 0)
         order.Add(kids);
 }
开发者ID:,项目名称:,代码行数:17,代码来源:


示例2: PdfCollectionSort

 /**
 * Constructs a PDF Collection Sort Dictionary.
 * @param keys  the keys of the fields that will be used to sort entries
 */
 public PdfCollectionSort(String[] keys) : base(PdfName.COLLECTIONSORT) {
     PdfArray array = new PdfArray();
     for (int i = 0; i < keys.Length; i++) {
         array.Add(new PdfName(keys[i]));
     }
     Put(PdfName.S, array);
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:11,代码来源:PdfCollectionSort.cs


示例3: GetSpotObject

 protected internal virtual PdfObject GetSpotObject(PdfWriter writer) {
     PdfArray array = new PdfArray(PdfName.SEPARATION);
     array.Add(name);
     PdfFunction func = null;
     if (altcs is ExtendedColor) {
         int type = ((ExtendedColor)altcs).Type;
         switch (type) {
             case ExtendedColor.TYPE_GRAY:
                 array.Add(PdfName.DEVICEGRAY);
                 func = PdfFunction.Type2(writer, new float[]{0, 1}, null, new float[]{0}, new float[]{((GrayColor)altcs).Gray}, 1);
                 break;
             case ExtendedColor.TYPE_CMYK:
                 array.Add(PdfName.DEVICECMYK);
                 CMYKColor cmyk = (CMYKColor)altcs;
                 func = PdfFunction.Type2(writer, new float[]{0, 1}, null, new float[]{0, 0, 0, 0},
                     new float[]{cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black}, 1);
                 break;
             default:
                 throw new Exception(MessageLocalization.GetComposedMessage("only.rgb.gray.and.cmyk.are.supported.as.alternative.color.spaces"));
         }
     }
     else {
         array.Add(PdfName.DEVICERGB);
         func = PdfFunction.Type2(writer, new float[]{0, 1}, null, new float[]{1, 1, 1},
             new float[]{(float)altcs.R / 255, (float)altcs.G / 255, (float)altcs.B / 255}, 1);
     }
     array.Add(func.Reference);
     return array;
 }
开发者ID:,项目名称:,代码行数:29,代码来源:


示例4: SetSortOrder

 /**
 * Defines the sort order of the field (ascending or descending).
 * @param ascending an array with every element corresponding with a name of a field.
 */
 public void SetSortOrder(bool[] ascending) {
     PdfObject o = (PdfObject)Get(PdfName.S);
     if (o is PdfArray) {
         if (((PdfArray)o).Size != ascending.Length) {
             throw new InvalidOperationException("The number of booleans in this array doesn't correspond with the number of fields.");
         }
         PdfArray array = new PdfArray();
         for (int i = 0; i < ascending.Length; i++) {
             array.Add(new PdfBoolean(ascending[i]));
         }
         Put(PdfName.A, array);
     }
     else {
         throw new InvalidOperationException("You need a single bool for this collection sort dictionary.");
     }
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:20,代码来源:PdfCollectionSort.cs


示例5: GetPdfObject

 public virtual PdfObject GetPdfObject(PdfWriter writer) {
     PdfArray array = new PdfArray(PdfName.LAB);
     PdfDictionary dictionary = new PdfDictionary();
     if (whitePoint == null
         || whitePoint.Length != 3
         || whitePoint[0] < 0.000001f || whitePoint[2] < 0.000001f
         || whitePoint[1] < 0.999999f || whitePoint[1] > 1.000001f)
         throw new Exception(MessageLocalization.GetComposedMessage("lab.cs.white.point"));
     dictionary.Put(PdfName.WHITEPOINT, new PdfArray(whitePoint));
     if (blackPoint != null) {
         if (blackPoint.Length != 3
             || blackPoint[0] < -0.000001f || blackPoint[1] < -0.000001f || blackPoint[2] < -0.000001f)
             throw new Exception(MessageLocalization.GetComposedMessage("lab.cs.black.point"));
         dictionary.Put(PdfName.BLACKPOINT, new PdfArray(blackPoint));
     }
     if (range != null) {
         if (range.Length != 4 || range[0] > range[1] || range[2] > range[3])
             throw new Exception(MessageLocalization.GetComposedMessage("lab.cs.range"));
         dictionary.Put(PdfName.RANGE, new PdfArray(range));
     }
     array.Add(dictionary);
     return array;
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:23,代码来源:PdfLabColor.cs


示例6: AddDirectImageSimple

 /**
 * Adds an image to the document but not to the page resources. It is used with
 * templates and <CODE>Document.Add(Image)</CODE>.
 * @param image the <CODE>Image</CODE> to add
 * @param fixedRef the reference to used. It may be <CODE>null</CODE>,
 * a <CODE>PdfIndirectReference</CODE> or a <CODE>PRIndirectReference</CODE>.
 * @return the name of the image added
 * @throws PdfException on error
 * @throws DocumentException on error
 */
 public PdfName AddDirectImageSimple(Image image, PdfIndirectReference fixedRef) {
     PdfName name;
     // if the images is already added, just retrieve the name
     if (images.ContainsKey(image.MySerialId)) {
         name = images[image.MySerialId];
     }
     // if it's a new image, add it to the document
     else {
         if (image.IsImgTemplate()) {
             name = new PdfName("img" + images.Count);
             if (image is ImgWMF){
                 ImgWMF wmf = (ImgWMF)image;
                 wmf.ReadWMF(PdfTemplate.CreateTemplate(this, 0, 0));
             }
         }
         else {
             PdfIndirectReference dref = image.DirectReference;
             if (dref != null) {
                 PdfName rname = new PdfName("img" + images.Count);
                 images[image.MySerialId] = rname;
                 imageDictionary.Put(rname, dref);
                 return rname;
             }
             Image maskImage = image.ImageMask;
             PdfIndirectReference maskRef = null;
             if (maskImage != null) {
                 PdfName mname = images[maskImage.MySerialId];
                 maskRef = GetImageReference(mname);
             }
             PdfImage i = new PdfImage(image, "img" + images.Count, maskRef);
             if (image is ImgJBIG2) {
                 byte[] globals = ((ImgJBIG2) image).GlobalBytes;
                 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.TagICC, image.CompressionLevel);
                 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[0]))
                         colorspace[1] = iccArray;
                     else
                         i.Put(PdfName.COLORSPACE, iccArray);
                 }
                 else
                     i.Put(PdfName.COLORSPACE, iccArray);
             }
             Add(i, fixedRef);
             name = i.Name;
         }
         images[image.MySerialId] = name;
     }
     return name;
 }
开发者ID:,项目名称:,代码行数:71,代码来源:


示例7: FillOCProperties

 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;
     List<IPdfOCG> docOrder = new List<IPdfOCG>(documentOCGorder);
     for (ListIterator<IPdfOCG> it = new ListIterator<IPdfOCG>(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);
 }
开发者ID:,项目名称:,代码行数:46,代码来源:


示例8: Close

        /**
        * Signals that the <CODE>Document</CODE> was closed and that no other
        * <CODE>Elements</CODE> will be added.
        * <P>
        * The pages-tree is built and written to the outputstream.
        * A Catalog is constructed, as well as an Info-object,
        * the referencetable is composed and everything is written
        * to the outputstream embedded in a Trailer.
        */
        public override void Close() {
            if (open) {
                if ((currentPageNumber - 1) != pageReferences.Count)
                    throw new Exception("The page " + pageReferences.Count +
                    " was requested but the document has only " + (currentPageNumber - 1) + " pages.");
                pdf.Close();
                AddSharedObjectsToBody();
                foreach (IPdfOCG layer in documentOCG.Keys) {
                    AddToBody(layer.PdfObject, layer.Ref);
                }
                // 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).IndirectReference);
                }
                // [C10] make pdfx conformant
                if (IsPdfX()) {
                    CompleteInfoDictionary(Info);
                    CompleteExtraCatalog(ExtraCatalog);
                }
                // [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(Info, false);

                // [F1] encryption
                PdfIndirectReference encryption = null;
                PdfObject fileID = null;
                body.FlushObjStm();
                if (crypto != null) {
                    PdfIndirectObject encryptionObject = AddToBody(crypto.GetEncryptionDictionary(), false);
                    encryption = encryptionObject.IndirectReference;
                    fileID = crypto.FileID;
                }
                else
                    fileID = PdfEncryption.CreateInfoId(PdfEncryption.CreateDocumentId());
                
                // write the cross-reference table of the body
                body.WriteCrossReferenceTable(os, indirectCatalog.IndirectReference,
                    infoObj.IndirectReference, encryption,  fileID, prevxref);

                // make the trailer
                // [F2] full compression
                if (fullCompression) {
                    WriteKeyInfo(os);
                    byte[] tmp = GetISOBytes("startxref\n");
                    os.Write(tmp, 0, tmp.Length);
                    tmp = GetISOBytes(body.Offset.ToString());
                    os.Write(tmp, 0, tmp.Length);
                    tmp = GetISOBytes("\n%%EOF\n");
                    os.Write(tmp, 0, tmp.Length);
                }
                else {
                    PdfTrailer trailer = new PdfTrailer(body.Size,
                    body.Offset,
                    indirectCatalog.IndirectReference,
                    infoObj.IndirectReference,
                    encryption,
                    fileID, prevxref);
                    trailer.ToPdf(this, os);
                }
                base.Close();
            }
        }
开发者ID:,项目名称:,代码行数:91,代码来源:


示例9: SetPageViewport

 /**
  * Sets the Viewport for the next page.
  * @param viewport an array consisting of Viewport dictionaries.
  * @since 5.1.0
  */
 public void SetPageViewport(PdfArray vp) {
     AddPageDictEntry(PdfName.VP, vp);
 }
开发者ID:,项目名称:,代码行数:8,代码来源:


示例10: AlterContents

 virtual internal protected void AlterContents() {
     foreach (PageStamp ps in pagesToContent.Values) {
         PdfDictionary pageN = ps.pageN;
         MarkUsed(pageN);
         PdfArray ar = null;
         PdfObject content = PdfReader.GetPdfObject(pageN.Get(PdfName.CONTENTS), pageN);
         if (content == null) {
             ar = new PdfArray();
             pageN.Put(PdfName.CONTENTS, ar);
         }
         else if (content.IsArray()) {
             ar = new PdfArray((PdfArray)content);
             pageN.Put(PdfName.CONTENTS, ar);
         }
         else if (content.IsStream()) {
             ar = new PdfArray();
             ar.Add(pageN.Get(PdfName.CONTENTS));
             pageN.Put(PdfName.CONTENTS, ar);
         }
         else {
             ar = new PdfArray();
             pageN.Put(PdfName.CONTENTS, ar);
         }
         ByteBuffer out_p = new ByteBuffer();
         if (ps.under != null) {
             out_p.Append(PdfContents.SAVESTATE);
             ApplyRotation(pageN, out_p);
             out_p.Append(ps.under.InternalBuffer);
             out_p.Append(PdfContents.RESTORESTATE);
         }
         if (ps.over != null)
             out_p.Append(PdfContents.SAVESTATE);
         PdfStream stream = new PdfStream(out_p.ToByteArray());
         stream.FlateCompress(compressionLevel);
         ar.AddFirst(AddToBody(stream).IndirectReference);
         out_p.Reset();
         if (ps.over != null) {
             out_p.Append(' ');
             out_p.Append(PdfContents.RESTORESTATE);
             ByteBuffer buf = ps.over.InternalBuffer;
             out_p.Append(buf.Buffer, 0, ps.replacePoint);
             out_p.Append(PdfContents.SAVESTATE);
             ApplyRotation(pageN, out_p);
             out_p.Append(buf.Buffer, ps.replacePoint, buf.Size - ps.replacePoint);
             out_p.Append(PdfContents.RESTORESTATE);
             stream = new PdfStream(out_p.ToByteArray());
             stream.FlateCompress(compressionLevel);
             ar.Add(AddToBody(stream).IndirectReference);
         }
         AlterResources(ps);
     }
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:52,代码来源:PdfStamperImp.cs


示例11: AddAnnotation

 internal void AddAnnotation(PdfAnnotation annot, PdfDictionary pageN)
 {
     ArrayList allAnnots = new ArrayList();
     if (annot.IsForm()) {
         fieldsAdded = true;
         AcroFields afdummy = AcroFields;
         PdfFormField field = (PdfFormField)annot;
         if (field.Parent != null)
             return;
         ExpandFields(field, allAnnots);
     }
     else
         allAnnots.Add(annot);
     for (int k = 0; k < allAnnots.Count; ++k) {
         annot = (PdfAnnotation)allAnnots[k];
         if (annot.PlaceInPage > 0)
             pageN = reader.GetPageN(annot.PlaceInPage);
         if (annot.IsForm()) {
             if (!annot.IsUsed()) {
                 Hashtable templates = annot.Templates;
                 if (templates != null) {
                     foreach (object tpl in templates.Keys) {
                         fieldTemplates[tpl] = null;
                     }
                 }
             }
             PdfFormField field = (PdfFormField)annot;
             if (field.Parent == null)
                 AddDocumentField(field.IndirectReference);
         }
         if (annot.IsAnnotation()) {
             PdfArray annots = (PdfArray)PdfReader.GetPdfObject(pageN.Get(PdfName.ANNOTS), pageN);
             if (annots == null) {
                 annots = new PdfArray();
                 pageN.Put(PdfName.ANNOTS, annots);
                 MarkUsed(pageN);
             }
             annots.Add(annot.IndirectReference);
             MarkUsed(annots);
             if (!annot.IsUsed()) {
                 PdfRectangle rect = (PdfRectangle)annot.Get(PdfName.RECT);
                 if (rect != null && (rect.Left != 0 || rect.Right != 0 || rect.Top != 0 || rect.Bottom != 0)) {
                     int rotation = reader.GetPageRotation(pageN);
                     Rectangle pageSize = reader.GetPageSizeWithRotation(pageN);
                     switch (rotation) {
                         case 90:
                             annot.Put(PdfName.RECT, new PdfRectangle(
                                 pageSize.Top - rect.Bottom,
                                 rect.Left,
                                 pageSize.Top - rect.Top,
                                 rect.Right));
                             break;
                         case 180:
                             annot.Put(PdfName.RECT, new PdfRectangle(
                                 pageSize.Right - rect.Left,
                                 pageSize.Top - rect.Bottom,
                                 pageSize.Right - rect.Right,
                                 pageSize.Top - rect.Top));
                             break;
                         case 270:
                             annot.Put(PdfName.RECT, new PdfRectangle(
                                 rect.Bottom,
                                 pageSize.Right - rect.Left,
                                 rect.Top,
                                 pageSize.Right - rect.Right));
                             break;
                     }
                 }
             }
         }
         if (!annot.IsUsed()) {
             annot.SetUsed();
             AddToBody(annot, annot.IndirectReference);
         }
     }
 }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:76,代码来源:PdfStamperImp.cs


示例12: InsertPage

 internal void InsertPage(int pageNumber, Rectangle mediabox)
 {
     Rectangle media = new Rectangle(mediabox);
     int rotation = media.Rotation % 360;
     PdfDictionary page = new PdfDictionary(PdfName.PAGE);
     PdfDictionary resources = new PdfDictionary();
     PdfArray procset = new PdfArray();
     procset.Add(PdfName.PDF);
     procset.Add(PdfName.TEXT);
     procset.Add(PdfName.IMAGEB);
     procset.Add(PdfName.IMAGEC);
     procset.Add(PdfName.IMAGEI);
     resources.Put(PdfName.PROCSET, procset);
     page.Put(PdfName.RESOURCES, resources);
     page.Put(PdfName.ROTATE, new PdfNumber(rotation));
     page.Put(PdfName.MEDIABOX, new PdfRectangle(media, rotation));
     PRIndirectReference pref = reader.AddPdfObject(page);
     PdfDictionary parent;
     PRIndirectReference parentRef;
     if (pageNumber > reader.NumberOfPages) {
         PdfDictionary lastPage = reader.GetPageNRelease(reader.NumberOfPages);
         parentRef = (PRIndirectReference)lastPage.Get(PdfName.PARENT);
         parentRef = new PRIndirectReference(reader, parentRef.Number);
         parent = (PdfDictionary)PdfReader.GetPdfObject(parentRef);
         PdfArray kids = (PdfArray)PdfReader.GetPdfObject(parent.Get(PdfName.KIDS), parent);
         kids.Add(pref);
         MarkUsed(kids);
         reader.pageRefs.InsertPage(pageNumber, pref);
     }
     else {
         if (pageNumber < 1)
             pageNumber = 1;
         PdfDictionary firstPage = reader.GetPageN(pageNumber);
         PRIndirectReference firstPageRef = reader.GetPageOrigRef(pageNumber);
         reader.ReleasePage(pageNumber);
         parentRef = (PRIndirectReference)firstPage.Get(PdfName.PARENT);
         parentRef = new PRIndirectReference(reader, parentRef.Number);
         parent = (PdfDictionary)PdfReader.GetPdfObject(parentRef);
         PdfArray kids = (PdfArray)PdfReader.GetPdfObject(parent.Get(PdfName.KIDS), parent);
         ArrayList ar = kids.ArrayList;
         int len = ar.Count;
         int num = firstPageRef.Number;
         for (int k = 0; k < len; ++k) {
             PRIndirectReference cur = (PRIndirectReference)ar[k];
             if (num == cur.Number) {
                 ar.Insert(k, pref);
                 break;
             }
         }
         if (len == ar.Count)
             throw new Exception("Internal inconsistence.");
         MarkUsed(kids);
         reader.pageRefs.InsertPage(pageNumber, pref);
         CorrectAcroFieldPages(pageNumber);
     }
     page.Put(PdfName.PARENT, parentRef);
     while (parent != null) {
         MarkUsed(parent);
         PdfNumber count = (PdfNumber)PdfReader.GetPdfObjectRelease(parent.Get(PdfName.COUNT));
         parent.Put(PdfName.COUNT, new PdfNumber(count.IntValue + 1));
         parent = (PdfDictionary)PdfReader.GetPdfObject(parent.Get(PdfName.PARENT));
     }
 }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:63,代码来源:PdfStamperImp.cs


示例13: IterateFields

 /**
 * After reading, we index all of the fields. Recursive.
 * @param fieldlist An array of fields
 * @param fieldDict the last field dictionary we encountered (recursively)
 * @param parentPath the pathname of the field, up to this point or null
 */
 virtual protected void IterateFields(PdfArray fieldlist, PRIndirectReference fieldDict, String parentPath) {
     foreach (PRIndirectReference refi in fieldlist.ArrayList) {
         PdfDictionary dict = (PdfDictionary) PdfReader.GetPdfObjectRelease(refi);
         
         // if we are not a field dictionary, pass our parent's values
         PRIndirectReference myFieldDict = fieldDict;
         String fullPath = parentPath;
         PdfString tField = (PdfString)dict.Get(PdfName.T);
         bool isFieldDict = tField != null;
         
         if (isFieldDict) {
             myFieldDict = refi;
             if (parentPath == null) {
                 fullPath = tField.ToString();
             } else {
                 fullPath = parentPath + '.' + tField.ToString();
             }
         }
         
         PdfArray kids = (PdfArray)dict.Get(PdfName.KIDS);
         if (kids != null) {
             PushAttrib(dict);
             IterateFields(kids, myFieldDict, fullPath);
             stack.RemoveAt(stack.Count - 1);   // pop
         }
         else {          // leaf node
             if (myFieldDict != null) {
                 PdfDictionary mergedDict = (PdfDictionary)stack[stack.Count - 1];
                 if (isFieldDict)
                     mergedDict = MergeAttrib(mergedDict, dict);
                 
                 mergedDict.Put(PdfName.T, new PdfString(fullPath));
                 FieldInformation fi = new FieldInformation(fullPath, mergedDict, myFieldDict);
                 fields.Add(fi);
                 fieldByName[fullPath] = fi;
             }
         }
     }
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:45,代码来源:PRAcroForm.cs


示例14: SerArray

 private void SerArray(PdfArray array, int level, ByteBuffer bb)
 {
     bb.Append("$A");
     if (level <= 0)
         return;
     for (int k = 0; k < array.Size; ++k) {
         SerObject(array[k], level, bb);
     }
 }
开发者ID:jomamorales,项目名称:createPDF,代码行数:9,代码来源:PdfSmartCopy.cs


示例15: PdfArray

 /**
  * Constructs an <CODE>PdfArray</CODE>-object, containing all the <CODE>PdfObject</CODE>s in a given <CODE>PdfArray</CODE>.
  *
  * @param    array        a <CODE>PdfArray</CODE> that has to be added to the array
  */
 public PdfArray(PdfArray array)
     : base(ARRAY)
 {
     arrayList = new ArrayList(array.arrayList);
 }
开发者ID:bmictech,项目名称:iTextSharp,代码行数:10,代码来源:PdfArray.cs


示例16: AddOrder

 /**
 * Recursive method to reconstruct the documentOCGorder variable in the writer.
 * @param    parent  a parent PdfLayer (can be null)
 * @param    arr     an array possibly containing children for the parent PdfLayer
 * @param    ocgmap  a Hashtable with indirect reference Strings as keys and PdfLayer objects as values.
 * @since    2.1.2
 */
 private void AddOrder(PdfLayer parent, PdfArray arr, Dictionary<string,PdfLayer> ocgmap) {
     PdfObject obj;
     PdfLayer layer;
     for (int i = 0; i < arr.Size; i++) {
         obj = arr[i];
         if (obj.IsIndirect()) {
             layer = ocgmap[obj.ToString()];
             if (layer != null) {
                 layer.OnPanel = true;
                 RegisterLayer(layer);
                 if (parent != null) {
                     parent.AddChild(layer);
                 }
                 if (arr.Size > i + 1 && arr[i + 1].IsArray()) {
                     i++;
                     AddOrder(layer, (PdfArray)arr[i], ocgmap);
                 }
             }
         }
         else if (obj.IsArray()) {
             PdfArray sub = (PdfArray)obj;
             if (sub.IsEmpty()) return;
             obj = sub[0];
             if (obj.IsString()) {
                 layer = new PdfLayer(obj.ToString());
                 layer.OnPanel = true;
                 RegisterLayer(layer);
                 if (parent != null) {
                     parent.AddChild(layer);
                 }
                 PdfArray array = new PdfArray();
                 for (ListIterator<PdfObject> j = sub.GetListIterator(); j.HasNext(); ) {
                     array.Add(j.Next());
                 }
                 AddOrder(layer, array, ocgmap);
             }
             else {
                 AddOrder(parent, (PdfArray)obj, ocgmap);
             }
         }
     }
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:49,代码来源:PdfStamperImp.cs


示例17: Close


//.........这里部分代码省略.........
                    buf = new StringBuilder(producer.Substring(0, idx));
                buf.Append("; modified using ");
                buf.Append(version.GetVersion);
                producer = buf.ToString();
            }
            PdfIndirectReference info = null;
            PdfDictionary newInfo = new PdfDictionary();
            if (oldInfo != null) {
                foreach (PdfName key in oldInfo.Keys) {
                    PdfObject value = PdfReader.GetPdfObject(oldInfo.Get(key));
                    newInfo.Put(key, value);
                }
            }
            if (moreInfo != null) {
                foreach (KeyValuePair<string,string> entry in moreInfo) {
                    PdfName keyName = new PdfName(entry.Key);
                    String value = entry.Value;
                    if (value == null)
                        newInfo.Remove(keyName);
                    else
                        newInfo.Put(keyName, new PdfString(value, PdfObject.TEXT_UNICODE));
                }
            }
            PdfDate date = new PdfDate();
            newInfo.Put(PdfName.MODDATE, date);
            newInfo.Put(PdfName.PRODUCER, new PdfString(producer, PdfObject.TEXT_UNICODE));
            if (append) {
                if (iInfo == null) {
                    info = AddToBody(newInfo, false).IndirectReference;
                } else {
                    info = AddToBody(newInfo, iInfo.Number, false).IndirectReference;
                }
            } else {
                info = AddToBody(newInfo, false).IndirectReference;
            }
            // XMP
            byte[] altMetadata = null;
            PdfObject xmpo = PdfReader.GetPdfObject(catalog.Get(PdfName.METADATA));
            if (xmpo != null && xmpo.IsStream()) {
                altMetadata = PdfReader.GetStreamBytesRaw((PRStream)xmpo);
                PdfReader.KillIndirect(catalog.Get(PdfName.METADATA));
            }
            PdfStream xmp = null;
            if (xmpMetadata != null) {
                altMetadata = xmpMetadata;
            } else if (xmpWriter != null) {
                try {
                    MemoryStream baos = new MemoryStream();
                    PdfProperties.SetProducer(xmpWriter.XmpMeta, producer);
                    XmpBasicProperties.SetModDate(xmpWriter.XmpMeta, date.GetW3CDate());
                    XmpBasicProperties.SetMetaDataDate(xmpWriter.XmpMeta, date.GetW3CDate());
                    xmpWriter.Serialize(baos);
                    xmpWriter.Close();
                    xmp = new PdfStream(baos.ToArray());
                } catch (XmpException) {
                    xmpWriter = null;
                }
            }
            if (xmp == null && altMetadata != null) {
                try {
                    MemoryStream baos = new MemoryStream();
                    if (moreInfo == null || xmpMetadata != null) {
                        IXmpMeta xmpMeta = XmpMetaFactory.ParseFromBuffer(altMetadata);

                        PdfProperties.SetProducer(xmpMeta, producer);
                        XmpBasicProperties.SetModDate(xmpMeta, date.GetW3CDate());
                        XmpBasicProperties.SetMetaDataDate(xmpMeta, date.GetW3CDate());

                        SerializeOptions serializeOptions = new SerializeOptions();
                        serializeOptions.Padding = 2000;
                        XmpMetaFactory.Serialize(xmpMeta, baos, serializeOptions);
                    } else {
                        XmpWriter xmpw = CreateXmpWriter(baos, newInfo);
                        xmpw.Close();
                    }
                    xmp = new PdfStream(baos.ToArray());
                } catch (XmpException) {
                    xmp = new PdfStream(altMetadata);
                } catch (IOException) {
                    xmp = new PdfStream(altMetadata);
                }
            }
            if (xmp != null) {
                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);
                }
                if (append && xmpo != null) {
                    body.Add(xmp, xmpo.IndRef);
                }
                else {
                    catalog.Put(PdfName.METADATA, body.Add(xmp).IndirectReference);
                    MarkUsed(catalog);
                }
            }
            Close(info, skipInfo);
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:101,代码来源:PdfStamperImp.cs


示例18: Close

 internal void Close(Hashtable moreInfo)
 {
     if (closed)
         return;
     if (useVp) {
         reader.SetViewerPreferences(viewerPreferences);
         MarkUsed(reader.Trailer.Get(PdfName.ROOT));
     }
     if (flat)
         FlatFields();
     if (flatFreeText)
         FlatFreeTextFields();
     AddFieldResources();
     PdfDictionary acroForm = (PdfDictionary)PdfReader.GetPdfObject(reader.Catalog.Get(PdfName.ACROFORM), reader.Catalog);
     if (acroFields != null && acroFields.Xfa.Changed) {
         MarkUsed(acroForm);
         if (!flat)
             acroFields.Xfa.SetXfa(this);
     }
     if (sigFlags != 0) {
         if (acroForm != null) {
             acroForm.Put(PdfName.SIGFLAGS, new PdfNumber(sigFlags));
             MarkUsed(acroForm);
         }
     }
     closed = true;
     AddSharedObjectsToBody();
     SetOutlines();
     SetJavaScript();
     AddFileAttachments();
     PdfDictionary catalog = reader.Catalog;
     if (openAction != null) {
         catalog.Put(PdfName.OPENACTION, openAction);
     }
     byte[] altMetadata = xmpMetadata;
     if (altMetadata == null) {
         PdfObject xmpo = PdfReader.GetPdfObject(catalog.Get(PdfName.METADATA));
         if (xmpo != null && xmpo.IsStream()) {
             altMetadata = PdfReader.GetStreamBytesRaw((PRStream)xmpo);
             PdfReader.KillIndirect(xmpo);
         }
     }
     // if there is XMP data to add: add it
     if (altMetadata != null) {
         PdfStream xmp = new PdfStream(altMetadata);
         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).IndirectReference);
         MarkUsed(catalog);
     }
     PRIndirectReference iInfo = null;
     try {
         file.ReOpen();
         AlterContents();
         iInfo = (PRIndirectReference)reader.trailer.Get(PdfName.INFO);
         int skip = -1;
         if (iInfo != null)
             skip = iInfo.Number;
         int rootN = ((PRIndirectReference)reader.trailer.Get(PdfName.ROOT)).Number;
         if (append) {
             int[] keys = marked.GetKeys();
             for (int k = 0; k < keys.Length; ++k) {
                 int j = keys[k];
                 PdfObject obj = reader.GetPdfObjectRelease(j);
                 if (obj != null && skip != j && j < initialXrefSize) {
                     AddToBody(obj, j, j != rootN);
                 }
             }
             for (int k = initialXrefSize; k < reader.XrefSize; ++k) {
                 PdfObject obj = reader.GetPdfObject(k);
                 if (obj != null) {
                     AddToBody(obj, GetNewObjectNumber(reader, k, 0));
                 }
             }
         }
         else {
             for (int k = 1; k < reader.XrefSize; ++k) {
                 PdfObject obj = reader.GetPdfObjectRelease(k);
                 if (obj != null && skip != k) {
                     AddToBody(obj, GetNewObjectNumber(reader, k, 0), k != rootN);
                 }
             }
         }
     }
     finally {
         try {
             file.Close();
         }
         catch  {
             // empty on purpose
         }
     }
     PdfIndirectReference encryption = null;
     PdfObject fileID = null;
     if (crypto != null) {
//.........这里部分代码省略.........
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:101,代码来源:PdfStamperImp.cs


示例19: AddComments

 /**
 * @param fdf
 * @throws IOException
 */
 virtual public void AddComments(FdfReader fdf) {
     if (readers2intrefs.ContainsKey(fdf))
         return;
     PdfDictionary catalog = fdf.Catalog;
     catalog = catalog.GetAsDict(PdfName.FDF);
     if (catalog == null)
         return;
     PdfArray annots = catalog.GetAsArray(PdfName.ANNOTS);
     if (annots == null || annots.Size == 0)
         return;
     RegisterReader(fdf, false);
     IntHashtable hits = new IntHashtable();
     Dictionary<String, PdfObject> irt = new Dictionary<string,PdfObject>();
     List<PdfObject> an = new List<PdfObject>();
     for (int k = 0; k < annots.Size; ++k) {
         PdfObject obj = annots[k];
         PdfDictionary annot = (PdfDictionary)PdfReader.GetPdfObject(obj);
         PdfNumber page = annot.GetAsNumber(PdfName.PAGE);
         if (page == null || page.IntValue >= reader.NumberOfPages)
             continue;
         FindAllObjects(fdf, obj, hits);
         an.Add(obj);
         if (obj.Type == PdfObject.INDIRECT) {
             PdfObject nm = PdfReader.GetPdfObject(annot.Get(PdfName.NM));
             if (nm != null && nm.Type == PdfObject.STRING)
                 irt[nm.ToString()] = obj;
         }
     }
     int[] arhits = hits.GetKeys();
     for (int k = 0; k < arhits.Length; ++k) {
         int n = arhits[k];
         PdfObject obj = fdf.GetPdfObject(n);
         if (obj.Type == PdfObject.DICTIONARY) {
             PdfObject str = PdfReader.GetPdfObject(((PdfDictionary)obj).Get(PdfName.IRT));
             if (str != null && str.Type == PdfObject.STRING) {
                 PdfObject i;
                 irt.TryGetValue(str.ToString(), out i);
                 if (i != null) {
                     PdfDictionary dic2 = new PdfDictionary();
                     dic2.Merge((PdfDictionary)obj);
                     dic2.Put(PdfName.IRT, i);
                     obj = dic2;
                 }
             }
         }
         AddToBody(obj, GetNewObjectNumber(fdf, n, 0));
     }
     for (int k = 0; k < an.Count; ++k) {
         PdfObject obj = an[k];
         PdfDictionary annot = (PdfDictionary)PdfReader.GetPdfObject(obj);
         PdfNumber page = annot.GetAsNumber(PdfName.PAGE);
         PdfDictionary dic = reader.GetPageN(page.IntValue + 1);
         PdfArray annotsp = (PdfArray)PdfReader.GetPdfObject(dic.Get(PdfName.ANNOTS), dic);
         if (annotsp == null) {
             annotsp = new PdfArray();
             dic.Put(PdfName.ANNOTS, annotsp);
             MarkUsed(dic);
         }
         MarkUsed(annotsp);
         annotsp.Add(obj);
     }
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:66,代码来源:PdfStamperImp.cs


示例20: ReadImage

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# pdf.PdfChunk类代码示例发布时间:2022-05-26
下一篇:
C# pdf.PdfAnnotation类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap