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


C# Chunk.SetLocalDestination方法代码示例

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


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

示例1: GetChunk

        public static Chunk GetChunk(Properties attributes)
        {
            Chunk chunk = new Chunk();

            chunk.Font = FontFactory.GetFont(attributes);
            String value;

            value = attributes[ElementTags.ITEXT];
            if (value != null) {
                chunk.Append(value);
            }
            value = attributes[ElementTags.LOCALGOTO];
            if (value != null) {
                chunk.SetLocalGoto(value);
            }
            value = attributes[ElementTags.REMOTEGOTO];
            if (value != null) {
                String page = attributes[ElementTags.PAGE];
                if (page != null) {
                    chunk.SetRemoteGoto(value, int.Parse(page));
                }
                else {
                    String destination = attributes[ElementTags.DESTINATION];
                    if (destination != null) {
                        chunk.SetRemoteGoto(value, destination);
                    }
                }
            }
            value = attributes[ElementTags.LOCALDESTINATION];
            if (value != null) {
                chunk.SetLocalDestination(value);
            }
            value = attributes[ElementTags.SUBSUPSCRIPT];
            if (value != null) {
                chunk.SetTextRise(float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            value = attributes[Markup.CSS_KEY_VERTICALALIGN];
            if (value != null && value.EndsWith("%")) {
                float p = float.Parse(value.Substring(0, value.Length - 1), System.Globalization.NumberFormatInfo.InvariantInfo) / 100f;
                chunk.SetTextRise(p * chunk.Font.Size);
            }
            value = attributes[ElementTags.GENERICTAG];
            if (value != null) {
                chunk.SetGenericTag(value);
            }
            value = attributes[ElementTags.BACKGROUNDCOLOR];
            if (value != null) {
                chunk.SetBackground(Markup.DecodeColor(value));
            }
            return chunk;
        }
开发者ID:bmictech,项目名称:iTextSharp,代码行数:51,代码来源:ElementFactory.cs

示例2: ApplyAnchor

 /**
  * Applies the properties of the Anchor to a Chunk.
  * @param chunk			the Chunk (part of the Anchor)
  * @param notGotoOK		if true, this chunk will determine the local destination
  * @param localDestination	true if the chunk is a local goto and the reference a local destination
  * @return	the value of notGotoOK or false, if a previous Chunk was used to determine the local destination
  */
 protected bool ApplyAnchor(Chunk chunk, bool notGotoOK, bool localDestination) {
     if (name != null && notGotoOK && !chunk.IsEmpty()) {
         chunk.SetLocalDestination(name);
         notGotoOK = false;
     }
     if (localDestination) {
         chunk.SetLocalGoto(reference.Substring(1));
     } else if (reference != null)
         chunk.SetAnchor(reference);
     return notGotoOK;
 }
开发者ID:,项目名称:,代码行数:18,代码来源:

示例3: Write

// ===========================================================================
    public void Write(Stream stream) {
      // step 1
      using (Document document = new Document()) {
        // step 2
        PdfWriter.GetInstance(document, stream);
        // step 3
        document.Open();
        // step 4
        // Create a local destination at the top of the page
        Paragraph p = new Paragraph();
        Chunk top = new Chunk("Country List", FilmFonts.BOLD);
        top.SetLocalDestination("top");
        p.Add(top);
        document.Add(p);
        // create an external link
        Chunk imdb = new Chunk("Internet Movie Database", FilmFonts.ITALIC);
        imdb.SetAnchor(new Uri("http://www.imdb.com/"));
        p = new Paragraph(
          "Click on a country, and you'll get a list of movies, containing links to the "
        );
        p.Add(imdb);
        p.Add(".");
        document.Add(p);
        // Create a remote goto
        p = new Paragraph("This list can be found in a ");
        Chunk page1 = new Chunk("separate document");
        page1.SetRemoteGoto("movie_links_1.pdf", 1);
        p.Add(page1);
        p.Add(".");
        document.Add(p);
        document.Add(Chunk.NEWLINE);
        
        var SQL =
@"SELECT DISTINCT mc.country_id, c.country, count(*) AS c 
FROM film_country c, film_movie_country mc
WHERE c.id = mc.country_id 
GROUP BY mc.country_id, country ORDER BY c DESC";        
        // Create a database connection and statement
        using (var c =  AdoDB.Provider.CreateConnection()) {
          c.ConnectionString = AdoDB.CS;
          using (DbCommand cmd = c.CreateCommand()) {
            cmd.CommandText = SQL;        
            c.Open();            
            using (var r = cmd.ExecuteReader()) {
              while (r.Read()) {
              // add country with remote goto
                Paragraph country = new Paragraph(r["country"].ToString());
                country.Add(": ");
                Chunk link = new Chunk(string.Format(
                  "{0} movies", Convert.ToInt32(r["c"])
                ));
                link.SetRemoteGoto(
                  "movie_links_1.pdf", r["country_id"].ToString()
                );
                country.Add(link);
                document.Add(country);
              }
            }
          }
        }      
        document.Add(Chunk.NEWLINE);
        // Create local goto to top
        p = new Paragraph("Go to ");
        top = new Chunk("top");
        top.SetLocalGoto("top");
        p.Add(top);
        p.Add(".");
        document.Add(p);        
      }
    }
开发者ID:,项目名称:,代码行数:71,代码来源:

示例4: Create

 /**
 * Create an index entry.
 *
 * @param text  The text for the Chunk.
 * @param in1   The first level.
 * @param in2   The second level.
 * @param in3   The third level.
 * @return Returns the Chunk.
 */
 public Chunk Create(String text, String in1, String in2,
         String in3)
 {
     Chunk chunk = new Chunk(text);
     String tag = "idx_" + (indexcounter++);
     chunk.SetGenericTag(tag);
     chunk.SetLocalDestination(tag);
     Entry entry = new Entry(in1, in2, in3, tag, this);
     indexentry.Add(entry);
     return chunk;
 }
开发者ID:bmictech,项目名称:iTextSharp,代码行数:20,代码来源:IndexEvents.cs

示例5: MergePDFs

        private static void MergePDFs(IList fileList, string destinationfile)
        {
            var document = new Document();
            try {
                var writer = PdfWriter.GetInstance(document, new FileStream(destinationfile, FileMode.Create));
                document.Open();

                foreach (string filename in fileList) {
                    var reader = new PdfReader(filename);
                    for (int i = 0; i++ < reader.NumberOfPages; ) {
                        document.SetPageSize(reader.GetPageSizeWithRotation(1));
                        document.NewPage();

                        if (i == 1) {
                            var fileRef = new Chunk(" ");
                            fileRef.SetLocalDestination(filename);
                            document.Add(fileRef);
                        }

                        if (reader.GetPageRotation(i) == 90 || reader.GetPageRotation(i) == 270) {
                            writer.DirectContent.AddTemplate(writer.GetImportedPage(reader, i), 0, -1f, 1f, 0, 0,
                            reader.GetPageSizeWithRotation(i).Height);
                        }
                        else
                            writer.DirectContent.AddTemplate(writer.GetImportedPage(reader, i), 1f, 0, 0, 1f, 0, 0);
                    }
                }
            }
            catch (Exception e) { throw e; }
            finally { document.Close(); }
        }
开发者ID:istambuk,项目名称:public,代码行数:31,代码来源:I3E_downloader.cs

示例6: CreatePdf

        // ---------------------------------------------------------------------------    
        /**
         * Creates a PDF document.
         */
        public byte[] CreatePdf()
        {
            using (MemoryStream ms = new MemoryStream())
            {
                // step 1
                using (Document document = new Document())
                {
                    // step 2
                    PdfWriter.GetInstance(document, ms);
                    // step 3
                    document.Open();
                    // step 4
                    // Add text with a local destination
                    Paragraph p = new Paragraph();
                    Chunk top = new Chunk("Country List", FilmFonts.BOLD);
                    top.SetLocalDestination("top");
                    p.Add(top);
                    document.Add(p);
                    // Add text with a link to an external URL
                    Chunk imdb = new Chunk("Internet Movie Database", FilmFonts.ITALIC);
                    imdb.SetAction(new PdfAction(new Uri("http://www.imdb.com/")));
                    p = new Paragraph(
                      @"Click on a country, and you'll get a list of movies, 
            containing links to the "
                    );
                    p.Add(imdb);
                    p.Add(".");
                    document.Add(p);
                    // Add text with a remote goto
                    p = new Paragraph("This list can be found in a ");
                    Chunk page1 = new Chunk("separate document");
                    page1.SetAction(new PdfAction(RESULT1, 1));

                    p.Add(page1);
                    p.Add(".");
                    document.Add(p);
                    document.Add(Chunk.NEWLINE);
                    // Get a list with countries from the database      
                    var SQL =
          @"SELECT DISTINCT mc.country_id, c.country, count(*) AS c 
FROM film_country c, film_movie_country mc 
WHERE c.id = mc.country_id
GROUP BY mc.country_id, country 
ORDER BY c DESC";
                    using (var c = AdoDB.Provider.CreateConnection())
                    {
                        c.ConnectionString = AdoDB.CS;
                        using (DbCommand cmd = c.CreateCommand())
                        {
                            cmd.CommandText = SQL;
                            c.Open();
                            using (var r = cmd.ExecuteReader())
                            {
                                while (r.Read())
                                {
                                    Paragraph country = new Paragraph(r["country"].ToString());
                                    country.Add(": ");
                                    Chunk link = new Chunk(string.Format(
                                      "{0} movies", r["c"].ToString()
                                    ));
                                    link.SetAction(PdfAction.GotoRemotePage(
                                      RESULT1,
                                      r["country_id"].ToString(),
                                      false,
                                      true
                                    ));
                                    country.Add(link);
                                    document.Add(country);
                                }
                            }
                        }
                    }
                    document.Add(Chunk.NEWLINE);
                    // Add text with a local goto
                    p = new Paragraph("Go to ");
                    top = new Chunk("top");
                    top.SetAction(PdfAction.GotoLocalPage("top", false));
                    p.Add(top);
                    p.Add(".");
                    document.Add(p);
                }
                return ms.ToArray();
            }
        }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:88,代码来源:LinkActions.cs

示例7: WriteWorkItems

        private void WriteWorkItems(string chapterText, ref int chapterNumber, IEnumerable<ReleaseNoteWorkItem> workItems)
        {
            if (!workItems.Any())
                return;

            _document.NewPage();

            string chapterTitle = string.Format(CultureInfo.InvariantCulture, "{0}. {1}", chapterNumber++, chapterText);

            var chapter = new Chunk(chapterTitle, _chapterFont);
            var paragraph = new Paragraph(20f, chapter);
            chapter.SetLocalDestination(_writer.PageNumber.ToString(CultureInfo.InvariantCulture));

            Bookmarks.Add(new Bookmark(chapterTitle, _writer.PageNumber));

            _document.Add(paragraph);

            _table = new PdfPTable(4);
            _table.SpacingBefore = 10f;
            _table.WidthPercentage = 100;

            _table.DefaultCell.BorderColor = _headerColor;
            _table.DefaultCell.BorderWidth = 100;
            _table.DefaultCell.Padding = 100;

            _table.SetWidths(new[] { 18f, 35f, 35f, 12f });
            _table.DefaultCell.VerticalAlignment = Element.ALIGN_TOP;

            WriteTableHeader();

            foreach (var grouping in workItems.OrderBy(x => x.Area).GroupBy(x => x.Area))
            {
                foreach (var workItem in grouping.OrderBy(x => x.WorkItemId))
                {
                    WriteTableRow(workItem);
                }
            }

            _document.Add(_table);
        }
开发者ID:marcostomazini,项目名称:ReleaseNotes,代码行数:40,代码来源:ReleaseNotesPdfWriter.cs


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