当前位置: 首页>>代码示例>>C#>>正文


C# pdf.PdfFileSpecification类代码示例

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


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

示例1: FileAttachmentEvent

 // ---------------------------------------------------------------------------
 /**
  * Creates a FileAttachmentEvent.
  *
  * @param writer      the writer to which the file attachment has to be added.
  * @param fs          the file specification.
  * @param description a description for the file attachment.
  */
 public FileAttachmentEvent(
 PdfWriter writer, PdfFileSpecification fs, String description)
 {
     this.writer = writer;
       this.fs = fs;
       this.description = description;
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:15,代码来源:FileAttachmentEvent.cs

示例2: Url

 /**
 * Creates a file specification of type URL.
 * @param writer the <CODE>PdfWriter</CODE>
 * @param url the URL
 * @return the file specification
 */    
 public static PdfFileSpecification Url(PdfWriter writer, String url) {
     PdfFileSpecification fs = new PdfFileSpecification();
     fs.writer = writer;
     fs.Put(PdfName.FS, PdfName.URL);
     fs.Put(PdfName.F, new PdfString(url));
     return fs;
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:13,代码来源:PdfFileSpecification.cs

示例3: PdfMediaClipData

 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);
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:10,代码来源:PdfMediaClipData.cs

示例4: Close

        public override void Close(PdfWriter writer) {
            base.Close(writer);
            bool ok = false;

            IXmpMeta xmpMeta = null;
            if (writer.XmpWriter == null) {
               if (writer is PdfAStamperImp) {
                xmpMeta = ((PdfAStamperImp) writer).GetXmpMeta();
                PdfReader pdfReader = ((PdfAStamperImp) writer).GetPdfReader();
                PdfArray pdfArray = pdfReader.Catalog.GetAsArray(PdfName.AF);
                    if (pdfArray != null) {
                        for (int i = 0; i < pdfArray.Size; i++) {
                            PdfFileSpecification pdfFileSpecification = new PdfFileSpecification();
                            pdfFileSpecification.PutAll((PdfDictionary) pdfArray.GetDirectObject(i));
                            attachments.Add(pdfFileSpecification);
                        }
                    }
                }
            } else {
                xmpMeta = writer.XmpWriter.XmpMeta;
            }

            if (xmpMeta == null) {
                writer.CreateXmpMetadata();
                xmpMeta = writer.XmpWriter.XmpMeta;
            }

            try {
                String docFileName = xmpMeta.GetPropertyString(PdfAXmpWriter.zugferdSchemaNS,
                    PdfAXmpWriter.zugferdDocumentFileName);
                foreach (PdfFileSpecification attachment in attachments) {
                    if ((attachment.GetAsString(PdfName.UF) != null && docFileName.Equals(attachment.GetAsString(PdfName.UF).ToString()))
                            || (attachment.GetAsString(PdfName.F) != null && docFileName.Equals(attachment.GetAsString(PdfName.F).ToString())))
                    {

                        PdfName relationship = attachment.GetAsName(PdfName.AFRELATIONSHIP);
                        if (!AFRelationshipValue.Alternative.Equals(relationship)) {
                            attachments.Clear();
                            throw new PdfAConformanceException(attachment,
                                MessageLocalization.GetComposedMessage("afrelationship.value.shall.be.alternative"));
                        }
                        ok = true;
                        break;
                    }
                }
            } catch (Exception e) {
                attachments.Clear();
                throw e;
            }
            attachments.Clear();
            if (!ok) {
                throw new PdfAConformanceException(xmpMeta,
                    MessageLocalization.GetComposedMessage("zugferd.xmp.schema.shall.contain.attachment.name"));
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:55,代码来源:ZugferdChecker.cs

示例5: AddFileAttachment

 /** Adds a file attachment at the document level.
 * @param fs the file specification
 */    
 public void AddFileAttachment(PdfFileSpecification fs) {
     pdf.AddFileAttachment(null, fs);
 }
开发者ID:,项目名称:,代码行数:6,代码来源:

示例6: AddFileAttachment

 internal void AddFileAttachment(String description, PdfFileSpecification fs) {
     if (description == null) {
         PdfString desc = (PdfString)fs.Get(PdfName.DESC);
         if (desc == null) {
             description = ""; 
         }
         else {
             description = PdfEncodings.ConvertToString(desc.GetBytes(), null);
         }
     }
     fs.AddDescription(description, true);
     if (description.Length == 0)
         description = "Unnamed";
     String fn = PdfEncodings.ConvertToString(new PdfString(description, PdfObject.TEXT_UNICODE).GetBytes(), null);
     int k = 0;
     while (documentFileAttachment.ContainsKey(fn)) {
         ++k;
         fn = PdfEncodings.ConvertToString(new PdfString(description + " " + k, PdfObject.TEXT_UNICODE).GetBytes(), null);
     }
     documentFileAttachment[fn] = fs.Reference;
 }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:21,代码来源:PdfDocument.cs

示例7: FileExtern

 /**
 * Creates a file specification for an external file.
 * @param writer the <CODE>PdfWriter</CODE>
 * @param filePath the file path
 * @return the file specification
 */
 public static PdfFileSpecification FileExtern(PdfWriter writer, String filePath) {
     PdfFileSpecification fs = new PdfFileSpecification();
     fs.writer = writer;
     fs.Put(PdfName.F, new PdfString(filePath));
     return fs;
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:12,代码来源:PdfFileSpecification.cs

示例8: FileEmbedded

 /**
 * Creates a file specification with the file embedded. The file may
 * come from the file system or from a byte array.
 * @param writer the <CODE>PdfWriter</CODE>
 * @param filePath the file path
 * @param fileDisplay the file information that is presented to the user
 * @param fileStore the byte array with the file. If it is not <CODE>null</CODE>
 * it takes precedence over <CODE>filePath</CODE>
 * @param mimeType the optional mimeType
 * @param fileParameter the optional extra file parameters such as the creation or modification date
 * @param compressionLevel the level of compression
 * @throws IOException on error
 * @return the file specification
 * @since   2.1.3
 */    
 public static PdfFileSpecification FileEmbedded(PdfWriter writer, String filePath, String fileDisplay, byte[] fileStore, String mimeType, PdfDictionary fileParameter, int compressionLevel) {
     PdfFileSpecification fs = new PdfFileSpecification();
     fs.writer = writer;
     fs.Put(PdfName.F, new PdfString(fileDisplay));
     PdfEFStream stream;
     Stream inp = null;
     PdfIndirectReference refi;
     PdfIndirectReference refFileLength;
     try {
         refFileLength = writer.PdfIndirectReference;
         if (fileStore == null) {
             if (File.Exists(filePath)) {
                 inp = new FileStream(filePath, FileMode.Open, FileAccess.Read);
             }
             else {
                 if (filePath.StartsWith("file:/") || filePath.StartsWith("http://") || filePath.StartsWith("https://")) {
                     WebRequest w = WebRequest.Create(filePath);
                     inp = w.GetResponse().GetResponseStream();
                 }
                 else {
                     inp = BaseFont.GetResourceStream(filePath);
                     if (inp == null)
                         throw new IOException(filePath + " not found as file or resource.");
                 }
             }
             stream = new PdfEFStream(inp, writer);
         }
         else
             stream = new PdfEFStream(fileStore);
         stream.Put(PdfName.TYPE, PdfName.EMBEDDEDFILE);
         stream.FlateCompress(compressionLevel);
         stream.Put(PdfName.PARAMS, refFileLength);
         if (mimeType != null)
             stream.Put(PdfName.SUBTYPE, new PdfName(mimeType));
         refi = writer.AddToBody(stream).IndirectReference;
         if (fileStore == null) {
             stream.WriteLength();
         }
         PdfDictionary param = new PdfDictionary();
         if (fileParameter != null)
             param.Merge(fileParameter);
         param.Put(PdfName.SIZE, new PdfNumber(stream.RawLength));
         writer.AddToBody(param, refFileLength);
     }
     finally {
         if (inp != null)
             try{inp.Close();}catch{}
     }
     PdfDictionary f = new PdfDictionary();
     f.Put(PdfName.F, refi);
     fs.Put(PdfName.EF, f);
     return fs;
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:68,代码来源:PdfFileSpecification.cs

示例9: PdfRendition

 public PdfRendition(String file, PdfFileSpecification fs, String mimeType) {
     Put(PdfName.S, new PdfName("MR"));
     Put(PdfName.N, new PdfString("Rendition for "+file));
     Put(PdfName.C, new PdfMediaClipData(file, fs, mimeType));
 }
开发者ID:pusp,项目名称:o2platform,代码行数:5,代码来源:PdfRendition.cs

示例10: FileEmbedded

        /**
        * Creates a file specification with the file embedded. The file may
        * come from the file system or from a byte array.
        * @param writer the <CODE>PdfWriter</CODE>
        * @param filePath the file path
        * @param fileDisplay the file information that is presented to the user
        * @param fileStore the byte array with the file. If it is not <CODE>null</CODE>
        * it takes precedence over <CODE>filePath</CODE>
        * @param mimeType the optional mimeType
        * @param fileParameter the optional extra file parameters such as the creation or modification date
        * @param compressionLevel the level of compression
        * @throws IOException on error
        * @return the file specification
        * @since   2.1.3
        */    
        public static PdfFileSpecification FileEmbedded(PdfWriter writer, String filePath, String fileDisplay, byte[] fileStore, String mimeType, PdfDictionary fileParameter, int compressionLevel) {
            PdfFileSpecification fs = new PdfFileSpecification();
            fs.writer = writer;
            fs.Put(PdfName.F, new PdfString(fileDisplay));
            fs.SetUnicodeFileName(fileDisplay, false);
            PdfEFStream stream;
            Stream inp = null;
            PdfIndirectReference refi;
            PdfIndirectReference refFileLength = null;
            try {
                if (fileStore == null) {
                    refFileLength = writer.PdfIndirectReference;
                    if (File.Exists(filePath)) {
                        inp = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                    }
                    else {
                        if (filePath.StartsWith("file:/") || filePath.StartsWith("http://") || filePath.StartsWith("https://")) {
                            WebRequest wr = WebRequest.Create(filePath);
                            wr.Credentials = CredentialCache.DefaultCredentials;
                            inp = wr.GetResponse().GetResponseStream();
                        }
                        else {
                            inp = StreamUtil.GetResourceStream(filePath);
                            if (inp == null)
                                throw new IOException(MessageLocalization.GetComposedMessage("1.not.found.as.file.or.resource", filePath));
                        }
                    }
                    stream = new PdfEFStream(inp, writer);
                }
                else
                    stream = new PdfEFStream(fileStore);
                stream.Put(PdfName.TYPE, PdfName.EMBEDDEDFILE);
                stream.FlateCompress(compressionLevel);

                PdfDictionary param = new PdfDictionary();
                if (fileParameter != null)
                    param.Merge(fileParameter);
                if (!param.Contains(PdfName.MODDATE)) {
                    param.Put(PdfName.MODDATE, new PdfDate());
                }
                if (fileStore != null) {
                    param.Put(PdfName.SIZE, new PdfNumber(stream.RawLength));
                    stream.Put(PdfName.PARAMS, param);
                }
                else {
                    stream.Put(PdfName.PARAMS, refFileLength);
                }

                if (mimeType != null)
                    stream.Put(PdfName.SUBTYPE, new PdfName(mimeType));

                refi = writer.AddToBody(stream).IndirectReference;
                if (fileStore == null) {
                    stream.WriteLength();
                    param.Put(PdfName.SIZE, new PdfNumber(stream.RawLength));
                    writer.AddToBody(param, refFileLength);
                }
            }
            finally {
                if (inp != null)
                    try{inp.Close();}catch{}
            }
            PdfDictionary f = new PdfDictionary();
            f.Put(PdfName.F, refi);
            f.Put(PdfName.UF, refi);
            fs.Put(PdfName.EF, f);
            return fs;
        }
开发者ID:,项目名称:,代码行数:83,代码来源:

示例11: AddAsset

 /**
  * Adds an embedded file.
  * (Part of the RichMediaContent.)
  * @param   name    a name for the name tree
  * @param   fs      a file specification for an embedded file.
  */
 virtual public PdfIndirectReference AddAsset(String name, PdfFileSpecification fs) {
     if (assetsmap == null)
         throw new IllegalPdfSyntaxException("You can't add assets to reused RichMediaContent.");
     PdfIndirectReference refi = writer.AddToBody(fs).IndirectReference;
     assetsmap[name] = refi;
     return refi;
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:13,代码来源:RichMediaAnnotation.cs

示例12: Rendition

 /**Creates a Rendition action
 * @param file
 * @param fs
 * @param mimeType
 * @param ref
 * @return a Media Clip action
 * @throws IOException
 */
 public static PdfAction Rendition(String file, PdfFileSpecification fs, String mimeType, PdfIndirectReference refi) {
     PdfAction js = new PdfAction();
     js.Put(PdfName.S, PdfName.RENDITION);
     js.Put(PdfName.R, new PdfRendition(file, fs, mimeType));
     js.Put(new PdfName("OP"), new PdfNumber(0));
     js.Put(new PdfName("AN"), refi);
     return js;
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:16,代码来源:PdfAction.cs

示例13: CreateScreen

 /**
 * Creates a screen PdfAnnotation
 * @param writer
 * @param rect
 * @param clipTitle
 * @param fs
 * @param mimeType
 * @param playOnDisplay
 * @return a screen PdfAnnotation
 * @throws IOException
 */
 public static PdfAnnotation CreateScreen(PdfWriter writer, Rectangle rect, String clipTitle, PdfFileSpecification fs,
                                         String mimeType, bool playOnDisplay)
 {
     PdfAnnotation ann = new PdfAnnotation(writer, rect);
     ann.Put(PdfName.SUBTYPE, PdfName.SCREEN);
     ann.Put (PdfName.F, new PdfNumber(FLAGS_PRINT));
     ann.Put(PdfName.TYPE, PdfName.ANNOT);
     ann.SetPage();
     PdfIndirectReference refi = ann.IndirectReference;
     PdfAction action = PdfAction.Rendition(clipTitle,fs,mimeType, refi);
     PdfIndirectReference actionRef = writer.AddToBody(action).IndirectReference;
     // for play on display add trigger event
     if (playOnDisplay)
     {
         PdfDictionary aa = new PdfDictionary();
         aa.Put(new PdfName("PV"), actionRef);
         ann.Put(PdfName.AA, aa);
     }
     ann.Put(PdfName.A, actionRef);
     return ann;
 }
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:32,代码来源:PdfAnnotation.cs

示例14: CreateFileAttachment

 /** Creates a file attachment annotation
 * @param writer
 * @param rect
 * @param contents
 * @param fs
 * @return the annotation
 * @throws IOException
 */
 public static PdfAnnotation CreateFileAttachment(PdfWriter writer, Rectangle rect, String contents, PdfFileSpecification fs)
 {
     PdfAnnotation annot = new PdfAnnotation(writer, rect);
     annot.Put(PdfName.SUBTYPE, PdfName.FILEATTACHMENT);
     if (contents != null)
         annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
     annot.Put(PdfName.FS, fs.Reference);
     return annot;
 }
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:17,代码来源:PdfAnnotation.cs


注:本文中的iTextSharp.text.pdf.PdfFileSpecification类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。