Hi all,
I face to a problem while adding bookmark to existing pdf file. I use
itextsharp.dll, the version is 5.0.2.0.
When I want to get root outline, content root outline is null and it gives me a
NullReferenceException.
So I cannot add subOutline objects to pdf.
Is it possible to create a new root outline object ? How can I create
PdfOutline object and add it to existinng pdf file?
I'm new with iText, so I need your help..
The code is as follows:
PdfReader reader = new PdfReader(sourceFile);
Document document = new Document(reader.GetPageSizeWithRotation(1));
PdfWriter writer = PdfWriter.GetInstance(document, new
FileStream(destinationFile, FileMode.Create));
document.Open();
PdfContentByte contentByte = writer.DirectContent;
PdfOutline pdfOutlineRoot = contentByte.RootOutline;
// Define the destination
PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH);
// Define the actions
PdfAction pdfAction1 = PdfAction.GotoLocalPage(1, pdfDest, writer);
PdfAction pdfAction2 = PdfAction.GotoLocalPage(2, pdfDest, writer);
// Define the outlines
PdfOutline pdfOutline1 = new PdfOutline(pdfOutlineRoot, pdfAction1, "Page
1");
PdfOutline pdfOutline2 = new PdfOutline(pdfOutline1, pdfAction2, "Page
2");
contentByte.AddOutline(pdfOutline1, pdfOutline1.Title);
contentByte.AddOutline(pdfOutline2, pdfOutline2.Title);
document.Close();
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5214 (20100621) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
________________________________
Bu e-posta sadece yukarıda isimleri belirtilen kişi/ler arasında özel
haberleşme amacını taşımaktadır. Size yanlışlıkla ulasmış ise lütfen bizi
bilgilendiriniz ve mesajı sisteminizden siliniz. Bu e-posta içeriği veya
ekindeki dosyalar kişisel ve yazarına aittir, bu nedenle Proline bu mesajin
içerigi ve ekleri ile ilgili olarak hiçbir hukuksal sorumluluk taşımaz ve kabul
etmez.
This e-mail is intended only for the use of the individual/s to whom it is
addressed. If you are not the intended recipient of the message, please
immediately inform us and delete it from your system. Any opinions contained in
this message belong to the author and do not constitute a commitment by Proline.
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/