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


C# Chunk.SetAnnotation方法代码示例

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


在下文中一共展示了Chunk.SetAnnotation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePdf

// ---------------------------------------------------------------------------    
    /**
     * Creates a PDF document.
     * @param stream Stream for the new PDF document
     */
    public void CreatePdf(Stream stream) {
      string RESOURCE = Utility.ResourcePosters;
      // step 1
      using (Document document = new Document()) {
        // step 2
        PdfWriter writer = PdfWriter.GetInstance(document, stream);
        // step 3
        document.Open();
        // step 4
        Phrase phrase;
        Chunk chunk;
        PdfAnnotation annotation;
        foreach (Movie movie in PojoFactory.GetMovies()) {
          phrase = new Phrase(movie.MovieTitle);
          chunk = new Chunk("\u00a0\u00a0");
          annotation = PdfAnnotation.CreateFileAttachment(
            writer, null,
            movie.MovieTitle, null,
            Path.Combine(RESOURCE, movie.Imdb + ".jpg"),
            string.Format("img_{0}.jpg", movie.Imdb)
          );
          annotation.Put(PdfName.NAME, new PdfString("Paperclip"));
          chunk.SetAnnotation(annotation);
          phrase.Add(chunk);
          document.Add(phrase);
          document.Add(PojoToElementFactory.GetDirectorList(movie));
          document.Add(PojoToElementFactory.GetCountryList(movie));
        }
      }
    }
开发者ID:,项目名称:,代码行数:35,代码来源:

示例2: Write

 // ---------------------------------------------------------------------------          
 public void Write(Stream stream)
 {
     // step 1
     using (Document document = new Document())
     {
         // step 2
         PdfWriter writer = PdfWriter.GetInstance(document, stream);
         // step 3
         document.Open();
         // step 4
         Phrase phrase;
         Chunk chunk;
         foreach (Movie movie in PojoFactory.GetMovies())
         {
             phrase = new Phrase(movie.MovieTitle);
             chunk = new Chunk("\u00a0");
             chunk.SetAnnotation(PdfAnnotation.CreateText(
               writer, null, movie.MovieTitle,
               string.Format(INFO, movie.Year, movie.Duration),
               false, "Comment"
             ));
             phrase.Add(chunk);
             document.Add(phrase);
             document.Add(PojoToElementFactory.GetDirectorList(movie));
             document.Add(PojoToElementFactory.GetCountryList(movie));
         }
     }
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:29,代码来源:MovieAnnotations2.cs

示例3: CreatePdf

 // ---------------------------------------------------------------------------
 /**
  * Creates the PDF.
  * @return the bytes of a PDF file.
  */
 public byte[] CreatePdf()
 {
     using (MemoryStream ms = new MemoryStream())
     {
         using (Document document = new Document())
         {
             PdfWriter writer = PdfWriter.GetInstance(document, ms);
             document.Open();
             document.Add(new Paragraph(
               "This is a list of Kubrick movies available in DVD stores."
             ));
             IEnumerable<Movie> movies = PojoFactory.GetMovies(1)
               .Concat(PojoFactory.GetMovies(4))
             ;
             List list = new List();
             string RESOURCE = Utility.ResourcePosters;
             foreach (Movie movie in movies)
             {
                 PdfAnnotation annot = PdfAnnotation.CreateFileAttachment(
                   writer, null,
                   movie.GetMovieTitle(false), null,
                   Path.Combine(RESOURCE, movie.Imdb + ".jpg"),
                   string.Format("{0}.jpg", movie.Imdb)
                 );
                 ListItem item = new ListItem(movie.GetMovieTitle(false));
                 item.Add("\u00a0\u00a0");
                 Chunk chunk = new Chunk("\u00a0\u00a0\u00a0\u00a0");
                 chunk.SetAnnotation(annot);
                 item.Add(chunk);
                 list.Add(item);
             }
             document.Add(list);
         }
         return ms.ToArray();
     }
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:41,代码来源:KubrickDvds.cs

示例4: RenderingCell

        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            if (OnPrintAnnotation == null)
                throw new InvalidOperationException("Please set the OnPrintAnnotation formula.");

            var data = OnPrintAnnotation.Invoke(attributes.RowData.TableRowData);
            if (data == null) return new PdfPCell();

            var defaultFont = attributes.BasicProperties.PdfFont.Fonts[0];
            var chunk = new Chunk(".", defaultFont);
            chunk.SetAnnotation(
                    PdfAnnotation.CreateText(
                           attributes.SharedData.PdfWriter,
                           new Rectangle(100, 100),
                           data.Title,
                           data.Text,
                           false,
                           _annotationIcon[data.Icon]));

            return new PdfPCell(new Phrase(chunk));
        }
开发者ID:VahidN,项目名称:PdfReport,代码行数:25,代码来源:AnnotationField.cs


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