나는 itextsharp를 사용하여 4 개의 pdf 템플릿 파일을 가지고 있습니다. 추가 된 값과 4 개의 pdf 파일을 단일 문서에 병합 했으므로 모든 4 페이지가 하나의 pdf 파일 이름 아래에 있습니다. 이제 pdf 파일에 북마크를 추가하고 싶습니다. 더 나은 이해를 위해, 이미지
PDF 파일에 북마크를 추가하는 방법은 무엇입니까?
안녕 아래를 참조하시기 바랍니다 C#으로 할 수있는 방법이 있나요?이 내가 할 노력하고 있어요, 내가 어떤 오류가 발생하고 있지 않다 그러나 아직도에는 북마크가없는 것입니다 내 pdf, 4 개의 섹션이있는 북마크를 image.after와 병합하여 추가하고 싶습니다. 최종 PDF에 북마크를 추가하고 싶습니다.
enter code herepublic string MergePDFs()
{
string outPutFilePath = @"D:\jeldsbre.pdf";
string genereatedpdfs = @"D:\genereatedpdfs";
using (FileStream stream = new FileStream(outPutFilePath, FileMode.Create))
{
Document pdfDoc = new Document(PageSize.A4);
PdfCopy pdf = new PdfCopy(pdfDoc, stream);
pdf.SetMergeFields();
pdfDoc.Open();
var files = Directory.GetFiles(genereatedpdfs);
Console.WriteLine("Merging files count: " + files.Length);
int i = 1;
foreach (string file in files)
{
Console.WriteLine(i + ". Adding: " + file);
pdf.AddDocument(new PdfReader(file));
i++;
}
List<Dictionary<string, object>> bookmarks = new List<Dictionary<string, object>>();
IList<Dictionary<string, object>> tempBookmarks = new List<Dictionary<string, object>>();
SimpleBookmark.ShiftPageNumbers(tempBookmarks, 1, null);
bookmarks.AddRange(tempBookmarks);
SimpleBookmark.ShiftPageNumbers(tempBookmarks, 3, null);
bookmarks.AddRange(tempBookmarks);
pdf.Outlines = bookmarks;
if (pdfDoc != null)
pdfDoc.Close();
string base64 = GetBase64(outPutFilePath);
return base64;
}
}
이 질문은 pdf를 병합하고 자바에서 iText를 사용하여 책갈피를 추가 할 수있는 것처럼 보입니다. (http://stackoverflow.com/questions/23688308/merge-pdfs-and-add-bookmark-with-itext-in- 자바) 유일한 차이점은이 질문에 대한 iTextSharp/C#입니다 (하지만 대답은 iText와 iTextSharp 사이에 거의 차이가 거의 동일합니다) –
고마워요 ... 나는 이것을 따라 내가 당신을 업데이 트됩니다. – kiransr
나는 또한 "본격적인"답변 (Java 및 C#)을 제공했지만 그 대답은 기존 문서에 이미 책갈피가 있다고 가정합니다. (이 경우 귀하의 질문에 명확하지 않다.) –