/**
 * 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;
 }
 // ---------------------------------------------------------------------------
 /**
  * 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;
 }
示例#3
0
        /**
         * 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);
        }
示例#4
0
        /**
         * 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);
        }
 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);
 }
示例#6
0
        /**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);
        }
示例#7
0
        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"));
            }
        }
示例#8
0
        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);
        }
示例#9
0
        /**
         * Use this method to add a file attachment at the document level.
         * @param description the file description
         * @param fileStore an array with the file. If it's <CODE>null</CODE>
         * the file will be read from the disk
         * @param file the path to the file. It will only be used if
         * <CODE>fileStore</CODE> is not <CODE>null</CODE>
         * @param fileDisplay the actual file name stored in the pdf
         * @param mimeType mime type of the file
         * @param afRelationshipValue AFRelationship key value, @see AFRelationshipValue. If <CODE>null</CODE>, @see AFRelationshipValue.Unspecified will be added.
         *
         * @throws IOException on error
         */
        public void AddFileAttachment(String description, byte[] fileStore, String file, String fileDisplay,
                                      String mimeType, PdfName afRelationshipValue)
        {
            PdfFileSpecification pdfFileSpecification = PdfFileSpecification.FileEmbedded(this, file, fileDisplay,
                                                                                          fileStore, mimeType, null, PdfStream.BEST_COMPRESSION);

            if (afRelationshipValue != null)
            {
                pdfFileSpecification.Put(PdfName.AFRELATIONSHIP, afRelationshipValue);
            }
            else
            {
                pdfFileSpecification.Put(PdfName.AFRELATIONSHIP, AFRelationshipValue.Unspecified);
            }

            AddFileAttachment(description, pdfFileSpecification);
        }
示例#10
0
 /** Adds a file attachment at the document level. Existing attachments will be kept.
  * @param description the file description
  * @param fs the file specification
  */
 public void AddFileAttachment(String description, PdfFileSpecification fs)
 {
     stamper.AddFileAttachment(description, fs);
 }
示例#11
0
 /** Adds a file attachment at the document level. Existing attachments will be kept.
  * @param description the file description
  * @param fileStore an array with the file. If it's <CODE>null</CODE>
  * the file will be read from the disk
  * @param file the path to the file. It will only be used if
  * <CODE>fileStore</CODE> is not <CODE>null</CODE>
  * @param fileDisplay the actual file name stored in the pdf
  * @throws IOException on error
  */
 public void AddFileAttachment(String description, byte[] fileStore, String file, String fileDisplay)
 {
     AddFileAttachment(description, PdfFileSpecification.FileEmbedded(stamper, file, fileDisplay, fileStore));
 }
 /**
 * 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;
 }
 /**
 * 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;
 }
 /**
 * 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;
 }
示例#15
0
        /** 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 = writer.CreateAnnotation(rect, PdfName.FILEATTACHMENT);

            if (contents != null)
            {
                annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
            }
            annot.Put(PdfName.FS, fs.Reference);
            return(annot);
        }
 /** 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;
 }
示例#17
0
        /**
         * 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);
        }
示例#18
0
 public void AddFileAttachment(string description, PdfFileSpecification fs);
示例#19
0
        /**
        * 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;
        }
示例#20
0
 /**
  * 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;
 }
示例#21
0
        /**
         * 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)
                {
                    stream.Put(PdfName.PARAMS, refFileLength);
                }
                else
                {
                    param.Put(PdfName.SIZE, new PdfNumber(stream.RawLength));
                    stream.Put(PdfName.PARAMS, param);
                }

                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);
        }
示例#22
0
 /**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;
 }
示例#23
0
 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));
 }
示例#24
0
 /** Adds a file attachment at the document level. Existing attachments will be kept.
 * @param description the file description
 * @param fs the file specification
 */    
 virtual public void AddFileAttachment(String description, PdfFileSpecification fs) {
     stamper.AddFileAttachment(description, fs);
 }
示例#25
0
 /** Adds a file attachment at the document level.
 * @param description the file description
 * @param fs the file specification
 */    
 public virtual void AddFileAttachment(String description, PdfFileSpecification fs) {
     pdf.AddFileAttachment(description, fs);
 }
示例#26
0
 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));
 }
示例#27
0
        /// <summary>
        /// Creates a file attachment annotation
        /// @throws IOException
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="rect"></param>
        /// <param name="contents"></param>
        /// <param name="fs"></param>
        /// <returns>the annotation</returns>
        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, TEXT_UNICODE));
            }
            annot.Put(PdfName.Fs, fs.Reference);
            return(annot);
        }
 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;
 }
示例#29
0
        /**
         * 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 = writer.CreateAnnotation(rect, 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);
        }
示例#30
0
 /** Adds a file attachment at the document level.
 * @param fs the file specification
 */    
 public void AddFileAttachment(PdfFileSpecification fs) {
     pdf.AddFileAttachment(null, fs);
 }
示例#31
0
 /** Creates a file attachment annotation.
  * @param writer the <CODE>PdfWriter</CODE>
  * @param rect the dimensions in the page of the annotation
  * @param contents the file description
  * @param fileStore an array with the file. If it's <CODE>null</CODE>
  * the file will be read from the disk
  * @param file the path to the file. It will only be used if
  * <CODE>fileStore</CODE> is not <CODE>null</CODE>
  * @param fileDisplay the actual file name stored in the pdf
  * @throws IOException on error
  * @return the annotation
  */
 public static PdfAnnotation CreateFileAttachment(PdfWriter writer, Rectangle rect, String contents, byte[] fileStore, String file, String fileDisplay)
 {
     return(CreateFileAttachment(writer, rect, contents, PdfFileSpecification.FileEmbedded(writer, file, fileDisplay, fileStore)));
 }