-2

I have a pdf , where page 1 is having page number as roman 1 i.e. "i"

Now how to get this information. I know using catalogues i can get page label dictionary

    CGPDFDictionaryRef catalog = CGPDFDocumentGetCatalog(document);

            if (CGPDFDictionaryGetDictionary(catalog, "PageLabels", &PageLabels) == true)
        {

        }

and by accessing page label dictionary i have to find range of pages and corresponding operators to actually know the label. i.e.: "D" for arabic decimal, "r" for roman...

Is there a way to directly access this label from CGPDFPageRef

Satyam Raikar
  • 465
  • 6
  • 20

2 Answers2

1

have you tried CGPDFDocumentGetPage

Return the PDF page corresponding to the specified page number, or NULL if no such page exists in the document. Pages are numbered starting at 1.

You can then do whatever conversions necessary after

Jteve Sobs
  • 244
  • 1
  • 14
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). – rsenna Aug 15 '15 at 17:55
  • 2
    it absolutely provides an answer @rsenn , maybe just not phrased the way you would like. It's just an answer phrased in the form of a question. i'll elaborate. – Jteve Sobs Aug 15 '15 at 18:08
1

The short answer is no, you cannot get that information from a CGPDFPageRef.
First you have to determine the page number (zero based) of your CGPDFPageRef object. Then you search the page labels array and determine in which label your page number fits. Based on the page label properties (numbering style, start page number, etc) you build the visual page number (the page number displayed by Acrobat as a roman numberal).

Update: The /PageLabels entry is a dictionary. Its /Nums entry is an array with the format: number dictionary number dictionary ... number dictionary.
The number is the start page index (zero based) in the document, the dictionary describes the page label. All the pages starting from the page index till the next page index or the document end will use the label defined next to the index. The page label dictionary is described in PDF specification section 12.4. The /S entry in the page label dictionary specifies the numbering type and the values /r or /R specify the roman numbering type.

Since you mention that your document specifies the /D value (decimal numbering) but in Adobe Reader you see roman numerals in the page number box please provide the PDF file for investigation.

Mihai Iancu
  • 1,818
  • 2
  • 11
  • 10
  • I tried accessing the PageLabels dictionary, inside it is having an array object for key Nums. Now Nums array has a item with value 0( int) and dictionary with key s and value d. thats it. But no other items in Nums array that define the roman part. – Satyam Raikar Aug 16 '15 at 11:34
  • Is there a way to get page number of TOC and Index page of that pdf. – Satyam Raikar Aug 17 '15 at 06:25