문제 설명
iTextSharp(또는 iText 5)를 사용하여 다른 PdfImportedPage의 배경으로 전체 PdfImportedPage를 추가하는 방법 (How to add a full PdfImportedPage as background for another PdfImportedPage with iTextSharp (or iText 5))
이와 유사한 게시물(iText7을 사용하여 PDF 파일의 배경으로 전체 PDF 페이지를 추가하는 방법) 하지만 iText 5에 필요합니다(iTextSharp<에서 더 좋음). /strong>).
단순화: "페이지 오버 페이지"가 필요합니다.
참조 솔루션
방법 1:
I've got it! =)
The answer was on topic "Listing 6.7. Superimposing.java" of Chapter 6. Working with existing PDFs
PdfReader reader = new PdfReader(SOURCE);
Document document = new Document(PageSize.POSTCARD);
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
document.open();
PdfContentByte canvas = writer.getDirectContent();
PdfImportedPage page;
for (int i = 1; i <= reader.getNumberOfPages(); i++)
{
page = writer.getImportedPage(reader, i);
// You can invoke this command "n" times to create overlays, including with pages from other readers
canvas.addTemplate(page, 1f, 0, 0, 1, 0, 0);
}
document.close();
(by Renato Mestre、Renato Mestre)