本文整理匯總了C#中iTextSharp.text.pdf.PdfCopy.AddNamedDestinations方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfCopy.AddNamedDestinations方法的具體用法?C# PdfCopy.AddNamedDestinations怎麽用?C# PdfCopy.AddNamedDestinations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfCopy
的用法示例。
在下文中一共展示了PdfCopy.AddNamedDestinations方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Write
// ---------------------------------------------------------------------------
public void Write(Stream stream) {
using (ZipFile zip = new ZipFile()) {
// Use previous examples to create PDF files
MovieLinks1 m = new MovieLinks1();
byte[] pdfM = Utility.PdfBytes(m);
LinkActions l = new LinkActions();
byte[] pdfL = l.CreatePdf();
// Create readers.
PdfReader[] readers = {
new PdfReader(pdfL),
new PdfReader(pdfM)
};
// step 1
//Document document = new Document();
// step 2
using (var ms = new MemoryStream()) {
// step 1
using (Document document = new Document()) {
using (PdfCopy copy = new PdfCopy(document, ms)) {
// step 3
document.Open();
// step 4
int n;
// copy the pages of the different PDFs into one document
for (int i = 0; i < readers.Length; i++) {
readers[i].ConsolidateNamedDestinations();
n = readers[i].NumberOfPages;
for (int page = 0; page < n; ) {
copy.AddPage(copy.GetImportedPage(readers[i], ++page));
}
}
// Add named destination
copy.AddNamedDestinations(
// from the second document
SimpleNamedDestination.GetNamedDestination(readers[1], false),
// using the page count of the first document as offset
readers[0].NumberOfPages
);
}
zip.AddEntry(RESULT1, ms.ToArray());
}
// Create a reader
PdfReader reader = new PdfReader(ms.ToArray());
// Convert the remote destinations into local destinations
reader.MakeRemoteNamedDestinationsLocal();
using (MemoryStream ms2 = new MemoryStream()) {
// Create a new PDF containing the local destinations
using (PdfStamper stamper = new PdfStamper(reader, ms2)) {
}
zip.AddEntry(RESULT2, ms2.ToArray());
}
}
zip.AddEntry(Utility.ResultFileName(m.ToString() + ".pdf"), pdfM);
zip.AddEntry(Utility.ResultFileName(l.ToString() + ".pdf"), pdfL);
zip.Save(stream);
}
}