I have been working on this for awhile and haven't quite figured it out. If anyone has any input, it would be greatly appreciated.
This is the obj line in the PDF file I wish to duplicate. /P is the key that sets the prefix of the page label name to SK1.
4 0 obj<</Type/Catalog/Pages 2 0 R/PageLabels<</Nums[0<</P(SK1)>>]>>>>endobj
The line I am able to create is this:
2 0 obj<</Type/Catalog/Pages 3 0 R/PageLabels<</Nums[<</P(SK1)>>]>>>>endobj
The only difference in the line I am creating is that after Nums[ there is no 0.
This is the code I am using to produce it.
// Get access to the Catalog of the document PdfCatalog catalog = document.Internals.Catalog;
// Create a dictionary that will contain the page label name for each page. // since only a one page document, create one dictionary
PdfDictionary LabelItem1 = new PdfDictionary();
// Add the /P as the prefix Key and the name as a PdfItem to the LabelItem1 PdfDictionary. LabelItem1.Elements.Add("/P", new PdfString("SK1"));
// Create an array to hold the page label dictionary. PdfArray pageLabel = new PdfArray();
// Add the LabelItem1 to the pageLable array pageLabel.Elements.Add(LabelItem1);
// Create a page number tree (as a dictionary) to hold the PdfDictionary pageNumberTree = new PdfDictionary();
// Add the pageLabel array to pageNumberTree as a /Nums key. pageNumberTree.Elements.Add("/Nums", pageLabel); // I add pageNumberTree to the catalog elements. catalog.Elements.Add("/PageLabels", pageNumberTree);
The 0 that I am missing is the page index of where the dictionary starts applying the /P to. If I open the file and add it manually, it messes up all of the PDF display but it does give me the page number.
I will keep trying and post the final code when I figure it out but any help would be appreciated.
Thank! Todd
|