本文整理匯總了C#中iTextSharp.text.pdf.PdfDestination.AddFirst方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfDestination.AddFirst方法的具體用法?C# PdfDestination.AddFirst怎麽用?C# PdfDestination.AddFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfDestination
的用法示例。
在下文中一共展示了PdfDestination.AddFirst方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateMoviePage
// ---------------------------------------------------------------------------
/**
* Creates the PDF.
* @return the bytes of a PDF file.
*/
public byte[] CreateMoviePage(Movie movie)
{
using (MemoryStream ms = new MemoryStream()) {
// step 1
using (Document document = new Document()) {
// step 2
PdfWriter.GetInstance(document, ms);
// step 3
document.Open();
// step 4
Paragraph p = new Paragraph(
movie.MovieTitle,
FontFactory.GetFont(
BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED, 16
)
);
document.Add(p);
document.Add(Chunk.NEWLINE);
PdfPTable table = new PdfPTable(WIDTHS);
table.AddCell(Image.GetInstance(
String.Format(RESOURCE, movie.Imdb)
));
PdfPCell cell = new PdfPCell();
cell.AddElement(new Paragraph("Year: " + movie.Year.ToString()));
cell.AddElement(new Paragraph("Duration: " + movie.Duration.ToString()));
table.AddCell(cell);
document.Add(table);
PdfDestination dest = new PdfDestination(PdfDestination.FIT);
dest.AddFirst(new PdfNumber(1));
PdfTargetDictionary target = new PdfTargetDictionary(false);
Chunk chunk = new Chunk("Go to original document");
PdfAction action = PdfAction.GotoEmbedded(null, target, dest, false);
chunk.SetAction(action);
document.Add(chunk);
}
return ms.ToArray();
}
}