SetAnchor() публичный Метод

Sets an anchor for this Chunk.
public SetAnchor ( Uri url ) : Chunk
url System.Uri the Uri to link to
Результат Chunk
Пример #1
0
 /**
  * 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
  */
 virtual 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);
 }
Пример #2
0
// ===========================================================================
    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);        
      }
    }
Пример #3
0
/*
 * end inner class
*/
// ---------------------------------------------------------------------------
    public void Write(Stream stream) {
      // step 1
      using (Document document = new Document()) {
      // step 2
        PdfWriter writer = PdfWriter.GetInstance(document, stream);
        GenericTags gevent = new GenericTags();
        writer.PageEvent = gevent;
        writer.PageEvent = new ParagraphPositions();       
        // step 3
        document.Open();
        // step 4
        Font bold = new Font(Font.FontFamily.HELVETICA, 11, Font.BOLD);
        Font italic = new Font(Font.FontFamily.HELVETICA, 11, Font.ITALIC);
        Font white = new Font(
          Font.FontFamily.HELVETICA, 12, 
          Font.BOLD | Font.ITALIC, 
          BaseColor.WHITE
        );
        Paragraph p;
        Chunk c;        
        foreach (Movie movie in PojoFactory.GetMovies(true)) {
            p = new Paragraph(22);
            c = new Chunk(String.Format("{0} ", movie.Year), bold);
            c.SetGenericTag("strip");
            p.Add(c);
            c = new Chunk(movie.MovieTitle);
            c.SetGenericTag(movie.Year.ToString());
            p.Add(c);
            c = new Chunk(
              String.Format(" ({0} minutes)  ", movie.Duration), 
              italic
            );
            p.Add(c);
            c = new Chunk("IMDB", white);
            c.SetAnchor("http://www.imdb.com/title/tt" + movie.Imdb);
            c.SetGenericTag("ellipse");
            p.Add(c);
            document.Add(p);
        }
        document.NewPage();
        writer.PageEvent = null;
        foreach (string entry in gevent.years.Keys) {
          p = new Paragraph(String.Format(
            "{0}: {1} movie(s)", entry, gevent.years[entry]
          ));
          document.Add(p);
        }
      }
    }
Пример #4
0
 /**
  * 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;
 }
        private PdfPCell WriteClientRef(ReleaseNoteWorkItem workItem)
        {
            var cell = new PdfPCell
                       {
                           BorderWidth = BorderWidth,
                           BorderColor = _headerColor,
                           PaddingTop = CellPadding,
                           PaddingBottom = CellPadding
                       };

            cell.AddElement(new Phrase(workItem.ClientRef.Trim(), _cellFont));
            if (Settings.LinkWorkItems)
            {
                var idText = new Chunk(string.Format(CultureInfo.InvariantCulture, "TFS{0}", workItem.WorkItemId.ToString(CultureInfo.InvariantCulture)), _urlFont);
                idText.SetAnchor(workItem.WorkItemAnchor);
                cell.AddElement(idText);
            }

            return cell;
        }