itextsharp pdf 파일의 바닥 글에 페이지 번호를 추가하고 싶습니다 .html (asp.net repeater)에서 pdf를 생성하고 있습니다. 그리고 XML 내용을 구문 분석하기 위해 XMLWorkerHelper를 사용하여 Im 많이 찾았으나 이것에 도움이되는 것을 찾을 수 없습니다.pdf 문서 (itextsharp)에 페이지 번호 추가
3
A
답변
11
iTextSharp
으로 PDF를 열고 페이지 번호를 직접 입력해야합니다. 나는 잠시 뒤로 이런 일을했는데, 여기에 내가 시작할 수있는 기능이있다. 이 기능은 왼쪽 하단에 현재 페이지를 추가하므로 필요에 맞게 다른 페이지를 배치해야 할 수 있습니다. 이 같은
public static byte[] AddPageNumbers(byte[] pdf)
{
MemoryStream ms = new MemoryStream();
// we create a reader for a certain document
PdfReader reader = new PdfReader(pdf);
// we retrieve the total number of pages
int n = reader.NumberOfPages;
// we retrieve the size of the first page
Rectangle psize = reader.GetPageSize(1);
// step 1: creation of a document-object
Document document = new Document(psize, 50, 50, 50, 50);
// step 2: we create a writer that listens to the document
PdfWriter writer = PdfWriter.GetInstance(document, ms);
// step 3: we open the document
document.Open();
// step 4: we add content
PdfContentByte cb = writer.DirectContent;
int p = 0;
Console.WriteLine("There are " + n + " pages in the document.");
for (int page = 1; page <= reader.NumberOfPages; page++)
{
document.NewPage();
p++;
PdfImportedPage importedPage = writer.GetImportedPage(reader, page);
cb.AddTemplate(importedPage, 0, 0);
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb.BeginText();
cb.SetFontAndSize(bf, 10);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, +p + "/" + n, 7, 44, 0);
cb.EndText();
}
// step 5: we close the document
document.Close();
return ms.ToArray();
}
1
뭔가 작업을해야합니다 :
var sourceFileList = new List<string>();
//add files to merge
int sourceIndex = 0;
PdfReader reader = new PdfReader(sourceFileList[sourceIndex]);
int sourceFilePageCount = reader.NumberOfPages;
Document doc = new Document(reader.GetPageSizeWithRotation(1));
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(destinationFileName, FileMode.Create));
doc.Open();
PdfImportedPage page;
PdfContentByte contentByte = writer.DirectContent;
int rotation;
while (sourceIndex < sourceFileList.Count)
{
int pageIndex = 0;
while (pageIndex < sourceFilePageCount)
{
pageIndex++;
doc.SetPageSize(reader.GetPageSizeWithRotation(pageIndex));
doc.NewPage();
page = writer.GetImportedPage(reader, pageIndex);
rotation = reader.GetPageRotation(pageIndex);
if (rotation.Equals(90 | 270))
contentByte.AddTemplate(page, 0, -1f, 1f, 0, 0, reader.GetPageSizeWithRotation(pageIndex).Height);
else
contentByte.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);
}
sourceIndex++;
if (sourceIndex < sourceFileList.Count)
{
reader = new PdfReader(sourceFileList[sourceIndex]);
sourceFilePageCount = reader.NumberOfPages;
}
}
doc.Close();
관련 문제
- 1. PdfPTable, iTextSharp에 열 추가
- 2. PDF 문서 - 문서를 다시로드하지 않고 열린 페이지 번호
- 3. 바코드에 페이지 번호 추가
- 4. Java에서 Solr에 PDF 문서 추가
- 5. iTextSharp를 사용하여 PDF 페이지 번호 가져 오기
- 6. PDF "페이지 번호"를 UISlider와 연결하는 방법?
- 7. 페이지 가져 오기 Adobe Reader의 ActiveX 컨트롤에서 PDF 문서 수
- 8. 페이지 번호 추가 및 itext로 스트림에서 가로 A4 만들기
- 9. PDF 문서 개요 얻기
- 10. ItextSharp에 일본어 글꼴이 표시되지 않습니다.
- 11. dompdf 페이지 번호
- 12. 문서 번호 매기기 요청 목록 자동 번호
- 13. 이미지가있는 PDF 문서 리더
- 14. 웹 페이지가있는 PDF 페이지
- 15. Mongodb - 부분적인 문서 번호
- 16. PDF 텍스트 추가 및 병합
- 17. PDFBox, BBox, 페이지 번호?
- 18. MongoDB에 페이지 번호 붙이기
- 19. Powershell을 사용하여 추가 열 데이터를 사용하여 문서 라이브러리에 문서 추가
- 20. MigraDoc PDFSharp 페이지 테두리 추가
- 21. 묻힌 PDF 문서 제공
- 22. 블록 복사 PDF 문서
- 23. PDF 문서 언어 감지
- 24. PDF 문서 작성자 검색
- 25. 다운로드에서 PDF 문서 오류
- 26. Delphi에서 PDF 문서 편집
- 27. 보안 PDF 문서 스캔
- 28. PDF Google 문서 뷰어
- 29. 메모리에서 PDF 문서 열기
- 30. asp.net 2.0의 PDF 문서 작성
흠, 이상한. 얼마나 정확히 검색 했습니까? 내가 [다음 링크] (http://www.google.com/#hl=en&sclient=psy-ab&q=itextsharp+add+page+number&oq=itextsharp+add+page+numbers&aq=f&aqi=g1&aql=&gs_l)를 방문했을 때 = hp.3..0.438.7461.0.7578.27.15.0.12.12.0.158.1445.11j4.15.0 ... 0.0.xJrtHtJSBd0 & pbx = 1 & bav = on.2 또는 .r_gc.r_pw.r_qf., cf.osb & fp = d0f8cd49a0fc8cd2 & biw = 1440 & bih = 795) 꽤 합리적인 양의 포인터가 있습니다. –
즉석에서 문서를 만드는 경우 페이지 번호 추가에 대한 예가 있습니다. 그러나 페이지의 HTML에서 PDF 문서를 만드는 중입니다. 아무 것도하지 않고이 repeater.RenderControl 속성에 의해 반복기의 html 출력을 얻습니다. xhtmlworkerp class.Shortly pdf 문서는 xhtmlworkerhelp에 의해 만들어지고 있습니다. 문서의 세부 사항에 관여하지 않습니다. 나는 무엇을하고 있는지 말할 수 있기를 바랍니다. – slayer35