本文整理匯總了C#中iTextSharp.text.pdf.PdfCopy.CreatePageStamp方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfCopy.CreatePageStamp方法的具體用法?C# PdfCopy.CreatePageStamp怎麽用?C# PdfCopy.CreatePageStamp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfCopy
的用法示例。
在下文中一共展示了PdfCopy.CreatePageStamp方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Write
// ---------------------------------------------------------------------------
public void Write(Stream stream) {
using (ZipFile zip = new ZipFile()) {
MovieLinks1 ml = new MovieLinks1();
byte[] r1 = Utility.PdfBytes(ml);
MovieHistory mh = new MovieHistory();
byte[] r2 = Utility.PdfBytes(mh);
using (MemoryStream ms = new MemoryStream()) {
// step 1
using (Document document = new Document()) {
// step 2
using (PdfCopy copy = new PdfCopy(document, ms)) {
// step 3
document.Open();
// step 4
// reader for document 1
PdfReader reader1 = new PdfReader(r1);
int n1 = reader1.NumberOfPages;
// reader for document 2
PdfReader reader2 = new PdfReader(r2);
int n2 = reader2.NumberOfPages;
// initializations
PdfImportedPage page;
PdfCopy.PageStamp stamp;
// Loop over the pages of document 1
for (int i = 0; i < n1; ) {
page = copy.GetImportedPage(reader1, ++i);
stamp = copy.CreatePageStamp(page);
// add page numbers
ColumnText.ShowTextAligned(
stamp.GetUnderContent(), Element.ALIGN_CENTER,
new Phrase(string.Format("page {0} of {1}", i, n1 + n2)),
297.5f, 28, 0
);
stamp.AlterContents();
copy.AddPage(page);
}
// Loop over the pages of document 2
for (int i = 0; i < n2; ) {
page = copy.GetImportedPage(reader2, ++i);
stamp = copy.CreatePageStamp(page);
// add page numbers
ColumnText.ShowTextAligned(
stamp.GetUnderContent(), Element.ALIGN_CENTER,
new Phrase(string.Format("page {0} of {1}", n1 + i, n1 + n2)),
297.5f, 28, 0
);
stamp.AlterContents();
copy.AddPage(page);
}
}
}
zip.AddEntry(RESULT, ms.ToArray());
zip.AddEntry(Utility.ResultFileName(ml.ToString() + ".pdf"), r1);
zip.AddEntry(Utility.ResultFileName(mh.ToString()+ ".pdf"), r2);
}
zip.Save(stream);
}
}
示例2: AddTextForPage
private void AddTextForPage(PdfCopy pdfCopyProvider, PdfImportedPage importedPage, TextForPage textForPage)
{
PdfCopy.PageStamp stamper = pdfCopyProvider.CreatePageStamp(importedPage);
ColumnText.ShowTextAligned(stamper.GetOverContent(), Element.ALIGN_CENTER, new Phrase(textForPage.PageNubmer,
new Font()), 820f, 15, 0);
stamper.AlterContents();
AddParagraph(stamper, textForPage.Header, importedPage.Width / 2,
importedPage.Height - 30, Element.ALIGN_CENTER, 1);
AddParagraph(stamper, textForPage.Footer, importedPage.Width / 2,
30, Element.ALIGN_CENTER, 1);
stamper.AlterContents();
}