What you want is indeed called page labels and can easily be added directly in the PDF's source code. Rename the file extension from pdf
to txt
and open the file in a text editor (this can be slow, depending on the file size, be patient). The information about page labels is stored in a node called the document catalog which looks something like this:
3 0 obj
<< /Type /Catalog
/Pages 1 0 R
>>
endobj
It may contain more confusing stuff, but this is the basic structure. There is only one catalog, so in a large file you can search for the node that contains /Catalog
. Now you can make your desired changes by inserting the /PageLabels
entry:
3 0 obj
<< /Type /Catalog
/Pages 1 0 R
/PageLabels << /Nums [ 0 << /P (cover) >>
% labels 1st page with the string "cover"
1 << /S /r >>
% numbers pages 2-6 in small roman numerals
6 << /S /D >>
% numbers pages 7-x in decimal arabic numerals
]
>>
>>
endobj
There are 3 lines starting with numbers, called page indices. Page 1 has the index 0
, page 2 the index 1
and so forth. They always describe ranges, so the line with 1 <<...>>
applies to all pages from index 1 to 5 and the line with 6 <<...>>
applies to all pages from 6 up to the last page. A label for 0 <<...>>
must always be defined.
You can find more information about page labels and PDF source code in the PDF standard or in a wiki on PDF standards.
I've also run into this issue, where Word would suddenly stop saving PDF files using the Save As function.
As I had a large and complex document I needed to compile into PDF on a strict deadline, and as Word didn't tell me which page it became stuck on (a tip mentioned elsewhere in this stack), the following helped me quickly find which page the Word was failing on:
Export the document to PDF in 'blocks'
Note: before you do this, ensure you save a backup (in .docx) somewhere safe first.
Just before pressing Save to transform a Word document into a PDF document using Save As, select Options...
Use the Page range setting to export 'blocks' of the document to see if it works. That will help you narrow down which page Word is failing on.
For example, if you have a 100 page document export pages 1-50 first, then pages 51-100 second. Ensure you try to export the 51-100 'block' even if Word fails on the 1-50 'block' straight up, to exclude any issues in the second half of your document.
If Word fails in the 51-100 'block' but not the 1-50 'block' you know that it's the second half of your document causing the issue.
Keep doing this with increasingly smaller 'blocks' (e.g. 51-70, 71-100 and so on...) until you've narrowed it down to two or three pages.
In my situation I was able to export Page 1, and Pages 7-100 successfully but not the whole document. So I knew the problem existed between Pages 2-6.
Then start removing sections (text, images, tables, headings, hidden formatting), without saving the document to .docx, then try exporting the whole document as PDF again. If it works and Word exports the document successfully, the corruption was in the section you've just deleted.
If Word fails to export to PDF, go back to the document, hit Ctrl + Z to undo the section you've just deleted then repeat by removing another section and exporting the whole document as PDF again.
Rinse and repeat until you can export the document successfully.
Turns out the issue with the document I was working on either was a table, an image, or a section break as the issue seemed to be between two pages.
Also consider Headers and Footers as well, they may become corrupted too. Also found a large image pushed off at the very top of the first page, that wouldn't show when exporting the document to PDF normally, but would show up when exporting the document to PDF with revision comments. Somehow an image got in the revision comments section... shrugs.
Best Answer
I know you would prefer to do this directly from within Word, but lacking a real solution to do it that way I would like to suggest PDFsam (PDF Split and Merge) which, so long as Java is available on the machine, does not need to be installed in order to be used.
You can effectively split, re-order, merge and generally shuffle documents around quite easily using PDFsam
Get it from http://www.pdfsam.org/