本文整理汇总了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));
}
}
}
示例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));
}
}
}
示例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();
}
}
示例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));
}