How to change internal page numbers in the meta data of a PDF?
I have a pdf document I created through non-Acrobat means (printing to pdf, then merging a bunch of pdfs), but I'd like to manually change the page numbers (i.e. the first several pages are simply title pages, the page that is labeled "page 1" is really the 7th sheet of the pdf). What's the simplest (and ideally, free) way to do this?
To be clear, I am not trying to change the numbers on the pages themselves, but the page numbers in the "metadata" that the pdf stores (the pages themselves are already numbered correctly; I just want "go to page 1" to go to the page labeled 1, which could be sheet 7).
For what it's worth, I'm on Windows, though I have access to Macs as well.
pdf metadata
add a comment |
I have a pdf document I created through non-Acrobat means (printing to pdf, then merging a bunch of pdfs), but I'd like to manually change the page numbers (i.e. the first several pages are simply title pages, the page that is labeled "page 1" is really the 7th sheet of the pdf). What's the simplest (and ideally, free) way to do this?
To be clear, I am not trying to change the numbers on the pages themselves, but the page numbers in the "metadata" that the pdf stores (the pages themselves are already numbered correctly; I just want "go to page 1" to go to the page labeled 1, which could be sheet 7).
For what it's worth, I'm on Windows, though I have access to Macs as well.
pdf metadata
I'm not sure if I understand your description+requirement fully. Can you provide a link to a sample PDF you want to modify?
– Kurt Pfeifle
Jan 14 '11 at 14:17
is there a command line tool to do that, e.g. on a big pdf file without actually opening the txt file?
– jj_p
Sep 20 '13 at 13:50
like e.g. pdftk?
– jj_p
Sep 23 '13 at 7:01
add a comment |
I have a pdf document I created through non-Acrobat means (printing to pdf, then merging a bunch of pdfs), but I'd like to manually change the page numbers (i.e. the first several pages are simply title pages, the page that is labeled "page 1" is really the 7th sheet of the pdf). What's the simplest (and ideally, free) way to do this?
To be clear, I am not trying to change the numbers on the pages themselves, but the page numbers in the "metadata" that the pdf stores (the pages themselves are already numbered correctly; I just want "go to page 1" to go to the page labeled 1, which could be sheet 7).
For what it's worth, I'm on Windows, though I have access to Macs as well.
pdf metadata
I have a pdf document I created through non-Acrobat means (printing to pdf, then merging a bunch of pdfs), but I'd like to manually change the page numbers (i.e. the first several pages are simply title pages, the page that is labeled "page 1" is really the 7th sheet of the pdf). What's the simplest (and ideally, free) way to do this?
To be clear, I am not trying to change the numbers on the pages themselves, but the page numbers in the "metadata" that the pdf stores (the pages themselves are already numbered correctly; I just want "go to page 1" to go to the page labeled 1, which could be sheet 7).
For what it's worth, I'm on Windows, though I have access to Macs as well.
pdf metadata
pdf metadata
edited Jan 13 '11 at 10:22
Arjan
26.9k1065107
26.9k1065107
asked Jan 13 '11 at 3:31
YGAYGA
68961322
68961322
I'm not sure if I understand your description+requirement fully. Can you provide a link to a sample PDF you want to modify?
– Kurt Pfeifle
Jan 14 '11 at 14:17
is there a command line tool to do that, e.g. on a big pdf file without actually opening the txt file?
– jj_p
Sep 20 '13 at 13:50
like e.g. pdftk?
– jj_p
Sep 23 '13 at 7:01
add a comment |
I'm not sure if I understand your description+requirement fully. Can you provide a link to a sample PDF you want to modify?
– Kurt Pfeifle
Jan 14 '11 at 14:17
is there a command line tool to do that, e.g. on a big pdf file without actually opening the txt file?
– jj_p
Sep 20 '13 at 13:50
like e.g. pdftk?
– jj_p
Sep 23 '13 at 7:01
I'm not sure if I understand your description+requirement fully. Can you provide a link to a sample PDF you want to modify?
– Kurt Pfeifle
Jan 14 '11 at 14:17
I'm not sure if I understand your description+requirement fully. Can you provide a link to a sample PDF you want to modify?
– Kurt Pfeifle
Jan 14 '11 at 14:17
is there a command line tool to do that, e.g. on a big pdf file without actually opening the txt file?
– jj_p
Sep 20 '13 at 13:50
is there a command line tool to do that, e.g. on a big pdf file without actually opening the txt file?
– jj_p
Sep 20 '13 at 13:50
like e.g. pdftk?
– jj_p
Sep 23 '13 at 7:01
like e.g. pdftk?
– jj_p
Sep 23 '13 at 7:01
add a comment |
10 Answers
10
active
oldest
votes
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.
4
Marvellous! This is the only place on the web I have found such direct and useful information. We don't all have Acrobat Reader, after all.
– Noldorin
Jul 22 '12 at 0:23
3
With example/St 8
or/St 2
, you set a start point for the displayed label; but choose any number in place of 8 (or 2), which must be >= 1. For example,1 << /S /r /St 12 >>
will number pages from (actually) 2-6 as (displayed) xii-xvii - because '12' corresponds 'xii'.
– n611x007
Jun 23 '13 at 17:30
1
thanks for the answer, but in my experience this method sometimes works and sometimes doesn't; also, I happened to find more than one Catalog: how do you explain that?
– jj_p
Sep 28 '13 at 17:45
1
Great information. Here is a link to another useful source: Specifying consistent page numbering for PDF documents from the W3C.
– Adam Mackler
Mar 18 '15 at 14:52
2
Are you sure it works just like this? From looking at the raw content of some PDF files it seemed like some index numbers that point to positions in the file after the catalog would have to be updated if the length of the preceding content changes..
– O. R. Mapper
Oct 14 '15 at 23:02
|
show 5 more comments
If I understand you correctly, here is how it should work:
gs
-o modified-pagelabels-50pages.pdf
-sDEVICE=pdfwrite
-c "[ /Page 1 /Label (i) /PAGELABEL pdfmark"
-c "[ /Page 2 /Label (ii) /PAGELABEL pdfmark"
-c "[ /Page 3 /Label (III) /PAGELABEL pdfmark"
-c "[ /Page 4 /Label (four) /PAGELABEL pdfmark"
-c "[ /Page 5 /Label (v) /PAGELABEL pdfmark"
-c "[ /Page 6 /Label (|||||) /PAGELABEL pdfmark"
-f 50pages.pdf
However, I seem to remember, that this didn't reliably or fully work last time I tried this (about 2 years ago).
UPDATE: My memory wasn't failing me. I now tried again and filed a bug report for Ghostscript (bug 691889) concerning this. Follow the link to the bug report to see the details.
add a comment |
For removing the old ones, probably the easiest cross-platform way is just to crop the old ones off. You could to this, for example, with BRISS.
Adding the new ones using free tools is more tricky. Personally I'd probably do it with pdflatex, as in this StackExchange answer, though that might be a rather involved solution unless you have other uses for pdflatex.
I think it can be done, however with jPdfTweak instead.
add a comment |
jPdf Tweak is an Open Source graphical utility that lets you edit page labels in PDF files. The documentation page provides step-by-step instructions.
I used this to add my custom page labels as "empty" format with text as prefix. Worked well!
– Matt Sephton
Aug 10 '17 at 21:53
add a comment |
NOTE: The accepted answer is still mostly correct, but has some gaps. It is lacking in that many PDF files are not directly editable as text. Even when they are, such editing can sometimes damage the PDF making it unreadable. One solution, that will work for both Unix and Microsoft Windows is qpdf which can translate PDF files into "QDF", a text-editable form which is still a valid PDF file. The
qpdf
package comes withfix-qdf
that recalculates offsets after a QDF file has been edited to correct any damage.
HOW TO Edit PDF Page Numbers Using Qpdf
Summary:
qpdf -qdf foo.pdf foo.qdf
edit foo.qdf
0 << >> % No label on first pages
6 << /S /D >> % Start numbering from 7th page.
fix-qdf foo.qdf >bar.qdf
- test bar.qdf
qpdf bar.qdf bar.pdf
Step 1.
Convert the document to the easily editable QDF format. Run qpdf from the command line like so:
qpdf -qdf foo.pdf foo.qdf
Note: If you do not have qpdf installed already, Microsoft Windows executables can be downloaded from https://github.com/qpdf/qpdf/releases Unix systems, such as Ubuntu and Debian GNU/Linux can install it by typing
apt install qpdf
.
Step 2.
Edit the QDF document using a text editor such as notepad++, emacs, or gedit. Search for the word /Catalog
and note the <<angle brackets>> it is inside. Nearby, you'll find the current /PageLabels
(if any).
We'll be adding each section that should be differently numbered to the /PageLabels
. The format is start-page
<< style
>>. Note that white-space does not matter and that the first page of the document is 0
. Unless otherwise specified, a new section always starts out numbering pages from 1.
Here is a full example of what PageLabels may look like, with comments added:
/Type /Catalog
/PageLabels <<
/Nums [
0 % From the first page of the document,
<<
/S /r % ...use the lowercase roman numeral style.
>>
6 % From seventh page onward,
<<
/S /D % ...use ordinary digits (arabic numerals)
>>
]
>>
If the file has no PageLabels, add them after /Type /Catalog
. For example, one might change,
1 0 obj
<<
…
/Type /Catalog
>>
endobj
into,
1 0 obj
<<
…
/Type /Catalog
/PageLabels
<< /Nums [
0 << >> % No label for cover
1 << /S /r >> % i, ii for index
3 << /S /D /St 15 >> % 15, 16, 17, ... for article
31 << /S /D /P (A-) >> % A-1, A-2, A-3... for appendix
]
>>
>>
endobj
STARTING FROM A DIFFERENT NUMBER WITH /St
Each section restarts numbering at 1 unless you tell it otherwise using /St
. Notice how in the above example, the fourth page starts at 15.
USING A DIFFERENT STYLE WITH /S
The /S
operator takes an argument that lets you pick the numbering style,
- /D digits (1, 2, 3...)
- /R uppercase Roman (I, II, III...)
- /r lowercase Roman (i, ii, iii...)
- /A uppercase alphabetical (A, B, C, ...., X, Y, Z, AA, AB, AC,...)
- /a lowercase alphabetical (a, b, c, ...., x, y, z, aa, ab, ac,...)
If one omits the /S
operator, then that section of pages will have no numbering. For example:
0 << >> % No label for cover
ADDING A PREFIX TO EACH PAGE WITH /P
You can show any string of text before the page number by specifying a word in parentheses after /P
:
31
<<
/S /D
/P (A-) % label appendix pages A-1, A-2, A-3
>>
Specifying a prefix without a style (/S
), will give you pages that have only the word without any number. This can be useful, for example, if you'd like a cover page to simply have the label "Cover".
0 << /P (Cover) >> % No number, just "Cover"
Step 3.
Run fix-qdf
to make your edits valid PDF and put the output in bar.qdf.
fix-qdf foo.qdf > bar.qdf
Step 4.
Open bar.qdf in your PDF viewing program and check that it is numbered correctly.
Step 5.
Convert the QDF file back into a normal PDF, like so:
qpdf bar.qdf bar.pdf
Ta da. You're done. You now have a document with correctly labeled page numbers in bar.pdf.
add a comment |
BeCyPDFMetaEdit
http://www.becyhome.de/becypdfmetaedit/description_eng.htm
You can add/remove/change internal page numbers scheme in the "pages" tab of this freeware tool.
And be caution, PDF xchange viewer doesn't show the page number scheme, and foxitreader have a right result. I have not test the Acrobat reader.
add a comment |
The method given by Dane H. does work with Acrobat Reader (or, to be precise, the current version of Adobe Reader). One minor point to note: the field at the top will only accept 8 characters so you can't enter something like 'subject index' into it if such a label has been used. But you can instead use menu item View > Page Navigation > Go to..., or the key equivalent.
Another tip: pdf specification always assigns page numbers consecutively, so in the case of a document produced by scanning pairs of pages the two sets of numbers get out of step (unless you laboriously number each page individually). But you can with little effort set up your document so the convention 'go to page n gets you to pages 2n and 2n+1' applies.
add a comment |
Danes answer is the best, the formats changed a little now, this might be helpful:
%PDF-1.6
29241 0 obj
<</Metadata 1685 0 R/Outlines 29461 0 R/PageLabels<</Nums[0<</S/D>>3<</S/D/St 6>>4<</S/D/St 10>>5<</S/D/St 12>>15<</S/D/St 70>>16<</S/D/St 72>>17<</S/D/St 80>>18<</S/D/St 82>>19<</S/D/St 90>>23<</S/D/St 96>>25<</S/D/St 99>>29<</S/D/St 110>>31<</S/D/St 130>>32<</S/D/St 133>>35<</S/D/St 137>>36<</S/D/St 140>>37<</S/D/St 145>>39<</S/D/St 150>>40<</S/D/St 152>>42<</S/D/St 155>>43<</S/D/St 160>>46<</S/D/St 165>>47<</S/D/St 167>>48<</S/D/St 170>>49<</S/D/St 180>>50<</S/D/St 190>>52<</S/D/St 300>>53<</S/D/St 305>>54<</S/D/St 319>>56<</S/D/St 380>>57<</S/D/St 390>>58<</S/D/St 500>>67<</S/D/St 515>>68<</S/D/St 525>>70<</S/D/St 550>>71<</S/D/St 553>>72<</S/D/St 560>>73<</S/D/St 600>>76<</S/D/St 620>>78<</S/D/St 650>>82<</S/D/St 670>>85<</S/D/St 700>>95<</S/D/St 714>>117<</S/D/St 900>>162<</S/D/St 1000>>178<</S/D/St 1200>>209<</S/D/St 1500>>263<</S/D/St 1555>>270<</S/D/St 1563>>389<</S/D/St 1681>>522<</S/D/St 1813>>]>> /PageMode/UseOutlines/Pages 29177 0 R/Type/Catalog>>
endobj
add a comment |
I found direct editing of the file (as uncompressed by pdftk) not to work if there are already '/titles' set in the '/outlines' region.
The direct-editing technique described in a post above is demonstrated on Youtube:
https://www.youtube.com/watch?v=zoH1Z_hSpak
But the 'update' feature of pdftk may be more intuitive (and more reliable when '/titles' already exist in the '/outlines' region of the PDF file) via editing the 'doc_data.txt' file used here:
https://www.pdflabs.com/blog/export-and-import-pdf-bookmarks/
1
Hi @Bob, Link-only answers are low quality. They will be useless if the target site moves or disappears. Please edit your answer and quote the relevant part of the solution here.
– C0deDaedalus
May 27 '18 at 19:18
add a comment |
There is a little python script, that can do the job: https://github.com/lovasoa/pagelabels-py
In your case call something like:
./addpagelabels.py --delete file.pdf
./addpagelabels.py --startpage 1 --type 'roman lowercase' file.pdf
./addpagelabels.py --startpage 7 --type arabic file.pdf
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f232553%2fhow-to-change-internal-page-numbers-in-the-meta-data-of-a-pdf%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
10 Answers
10
active
oldest
votes
10 Answers
10
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
4
Marvellous! This is the only place on the web I have found such direct and useful information. We don't all have Acrobat Reader, after all.
– Noldorin
Jul 22 '12 at 0:23
3
With example/St 8
or/St 2
, you set a start point for the displayed label; but choose any number in place of 8 (or 2), which must be >= 1. For example,1 << /S /r /St 12 >>
will number pages from (actually) 2-6 as (displayed) xii-xvii - because '12' corresponds 'xii'.
– n611x007
Jun 23 '13 at 17:30
1
thanks for the answer, but in my experience this method sometimes works and sometimes doesn't; also, I happened to find more than one Catalog: how do you explain that?
– jj_p
Sep 28 '13 at 17:45
1
Great information. Here is a link to another useful source: Specifying consistent page numbering for PDF documents from the W3C.
– Adam Mackler
Mar 18 '15 at 14:52
2
Are you sure it works just like this? From looking at the raw content of some PDF files it seemed like some index numbers that point to positions in the file after the catalog would have to be updated if the length of the preceding content changes..
– O. R. Mapper
Oct 14 '15 at 23:02
|
show 5 more comments
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.
4
Marvellous! This is the only place on the web I have found such direct and useful information. We don't all have Acrobat Reader, after all.
– Noldorin
Jul 22 '12 at 0:23
3
With example/St 8
or/St 2
, you set a start point for the displayed label; but choose any number in place of 8 (or 2), which must be >= 1. For example,1 << /S /r /St 12 >>
will number pages from (actually) 2-6 as (displayed) xii-xvii - because '12' corresponds 'xii'.
– n611x007
Jun 23 '13 at 17:30
1
thanks for the answer, but in my experience this method sometimes works and sometimes doesn't; also, I happened to find more than one Catalog: how do you explain that?
– jj_p
Sep 28 '13 at 17:45
1
Great information. Here is a link to another useful source: Specifying consistent page numbering for PDF documents from the W3C.
– Adam Mackler
Mar 18 '15 at 14:52
2
Are you sure it works just like this? From looking at the raw content of some PDF files it seemed like some index numbers that point to positions in the file after the catalog would have to be updated if the length of the preceding content changes..
– O. R. Mapper
Oct 14 '15 at 23:02
|
show 5 more comments
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.
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.
edited Oct 26 '13 at 12:42
answered May 30 '12 at 16:08
Dane Jacob HamptonDane Jacob Hampton
44347
44347
4
Marvellous! This is the only place on the web I have found such direct and useful information. We don't all have Acrobat Reader, after all.
– Noldorin
Jul 22 '12 at 0:23
3
With example/St 8
or/St 2
, you set a start point for the displayed label; but choose any number in place of 8 (or 2), which must be >= 1. For example,1 << /S /r /St 12 >>
will number pages from (actually) 2-6 as (displayed) xii-xvii - because '12' corresponds 'xii'.
– n611x007
Jun 23 '13 at 17:30
1
thanks for the answer, but in my experience this method sometimes works and sometimes doesn't; also, I happened to find more than one Catalog: how do you explain that?
– jj_p
Sep 28 '13 at 17:45
1
Great information. Here is a link to another useful source: Specifying consistent page numbering for PDF documents from the W3C.
– Adam Mackler
Mar 18 '15 at 14:52
2
Are you sure it works just like this? From looking at the raw content of some PDF files it seemed like some index numbers that point to positions in the file after the catalog would have to be updated if the length of the preceding content changes..
– O. R. Mapper
Oct 14 '15 at 23:02
|
show 5 more comments
4
Marvellous! This is the only place on the web I have found such direct and useful information. We don't all have Acrobat Reader, after all.
– Noldorin
Jul 22 '12 at 0:23
3
With example/St 8
or/St 2
, you set a start point for the displayed label; but choose any number in place of 8 (or 2), which must be >= 1. For example,1 << /S /r /St 12 >>
will number pages from (actually) 2-6 as (displayed) xii-xvii - because '12' corresponds 'xii'.
– n611x007
Jun 23 '13 at 17:30
1
thanks for the answer, but in my experience this method sometimes works and sometimes doesn't; also, I happened to find more than one Catalog: how do you explain that?
– jj_p
Sep 28 '13 at 17:45
1
Great information. Here is a link to another useful source: Specifying consistent page numbering for PDF documents from the W3C.
– Adam Mackler
Mar 18 '15 at 14:52
2
Are you sure it works just like this? From looking at the raw content of some PDF files it seemed like some index numbers that point to positions in the file after the catalog would have to be updated if the length of the preceding content changes..
– O. R. Mapper
Oct 14 '15 at 23:02
4
4
Marvellous! This is the only place on the web I have found such direct and useful information. We don't all have Acrobat Reader, after all.
– Noldorin
Jul 22 '12 at 0:23
Marvellous! This is the only place on the web I have found such direct and useful information. We don't all have Acrobat Reader, after all.
– Noldorin
Jul 22 '12 at 0:23
3
3
With example
/St 8
or /St 2
, you set a start point for the displayed label; but choose any number in place of 8 (or 2), which must be >= 1. For example, 1 << /S /r /St 12 >>
will number pages from (actually) 2-6 as (displayed) xii-xvii - because '12' corresponds 'xii'.– n611x007
Jun 23 '13 at 17:30
With example
/St 8
or /St 2
, you set a start point for the displayed label; but choose any number in place of 8 (or 2), which must be >= 1. For example, 1 << /S /r /St 12 >>
will number pages from (actually) 2-6 as (displayed) xii-xvii - because '12' corresponds 'xii'.– n611x007
Jun 23 '13 at 17:30
1
1
thanks for the answer, but in my experience this method sometimes works and sometimes doesn't; also, I happened to find more than one Catalog: how do you explain that?
– jj_p
Sep 28 '13 at 17:45
thanks for the answer, but in my experience this method sometimes works and sometimes doesn't; also, I happened to find more than one Catalog: how do you explain that?
– jj_p
Sep 28 '13 at 17:45
1
1
Great information. Here is a link to another useful source: Specifying consistent page numbering for PDF documents from the W3C.
– Adam Mackler
Mar 18 '15 at 14:52
Great information. Here is a link to another useful source: Specifying consistent page numbering for PDF documents from the W3C.
– Adam Mackler
Mar 18 '15 at 14:52
2
2
Are you sure it works just like this? From looking at the raw content of some PDF files it seemed like some index numbers that point to positions in the file after the catalog would have to be updated if the length of the preceding content changes..
– O. R. Mapper
Oct 14 '15 at 23:02
Are you sure it works just like this? From looking at the raw content of some PDF files it seemed like some index numbers that point to positions in the file after the catalog would have to be updated if the length of the preceding content changes..
– O. R. Mapper
Oct 14 '15 at 23:02
|
show 5 more comments
If I understand you correctly, here is how it should work:
gs
-o modified-pagelabels-50pages.pdf
-sDEVICE=pdfwrite
-c "[ /Page 1 /Label (i) /PAGELABEL pdfmark"
-c "[ /Page 2 /Label (ii) /PAGELABEL pdfmark"
-c "[ /Page 3 /Label (III) /PAGELABEL pdfmark"
-c "[ /Page 4 /Label (four) /PAGELABEL pdfmark"
-c "[ /Page 5 /Label (v) /PAGELABEL pdfmark"
-c "[ /Page 6 /Label (|||||) /PAGELABEL pdfmark"
-f 50pages.pdf
However, I seem to remember, that this didn't reliably or fully work last time I tried this (about 2 years ago).
UPDATE: My memory wasn't failing me. I now tried again and filed a bug report for Ghostscript (bug 691889) concerning this. Follow the link to the bug report to see the details.
add a comment |
If I understand you correctly, here is how it should work:
gs
-o modified-pagelabels-50pages.pdf
-sDEVICE=pdfwrite
-c "[ /Page 1 /Label (i) /PAGELABEL pdfmark"
-c "[ /Page 2 /Label (ii) /PAGELABEL pdfmark"
-c "[ /Page 3 /Label (III) /PAGELABEL pdfmark"
-c "[ /Page 4 /Label (four) /PAGELABEL pdfmark"
-c "[ /Page 5 /Label (v) /PAGELABEL pdfmark"
-c "[ /Page 6 /Label (|||||) /PAGELABEL pdfmark"
-f 50pages.pdf
However, I seem to remember, that this didn't reliably or fully work last time I tried this (about 2 years ago).
UPDATE: My memory wasn't failing me. I now tried again and filed a bug report for Ghostscript (bug 691889) concerning this. Follow the link to the bug report to see the details.
add a comment |
If I understand you correctly, here is how it should work:
gs
-o modified-pagelabels-50pages.pdf
-sDEVICE=pdfwrite
-c "[ /Page 1 /Label (i) /PAGELABEL pdfmark"
-c "[ /Page 2 /Label (ii) /PAGELABEL pdfmark"
-c "[ /Page 3 /Label (III) /PAGELABEL pdfmark"
-c "[ /Page 4 /Label (four) /PAGELABEL pdfmark"
-c "[ /Page 5 /Label (v) /PAGELABEL pdfmark"
-c "[ /Page 6 /Label (|||||) /PAGELABEL pdfmark"
-f 50pages.pdf
However, I seem to remember, that this didn't reliably or fully work last time I tried this (about 2 years ago).
UPDATE: My memory wasn't failing me. I now tried again and filed a bug report for Ghostscript (bug 691889) concerning this. Follow the link to the bug report to see the details.
If I understand you correctly, here is how it should work:
gs
-o modified-pagelabels-50pages.pdf
-sDEVICE=pdfwrite
-c "[ /Page 1 /Label (i) /PAGELABEL pdfmark"
-c "[ /Page 2 /Label (ii) /PAGELABEL pdfmark"
-c "[ /Page 3 /Label (III) /PAGELABEL pdfmark"
-c "[ /Page 4 /Label (four) /PAGELABEL pdfmark"
-c "[ /Page 5 /Label (v) /PAGELABEL pdfmark"
-c "[ /Page 6 /Label (|||||) /PAGELABEL pdfmark"
-f 50pages.pdf
However, I seem to remember, that this didn't reliably or fully work last time I tried this (about 2 years ago).
UPDATE: My memory wasn't failing me. I now tried again and filed a bug report for Ghostscript (bug 691889) concerning this. Follow the link to the bug report to see the details.
edited Jan 15 '11 at 11:08
answered Jan 14 '11 at 17:22
Kurt PfeifleKurt Pfeifle
9,33713555
9,33713555
add a comment |
add a comment |
For removing the old ones, probably the easiest cross-platform way is just to crop the old ones off. You could to this, for example, with BRISS.
Adding the new ones using free tools is more tricky. Personally I'd probably do it with pdflatex, as in this StackExchange answer, though that might be a rather involved solution unless you have other uses for pdflatex.
I think it can be done, however with jPdfTweak instead.
add a comment |
For removing the old ones, probably the easiest cross-platform way is just to crop the old ones off. You could to this, for example, with BRISS.
Adding the new ones using free tools is more tricky. Personally I'd probably do it with pdflatex, as in this StackExchange answer, though that might be a rather involved solution unless you have other uses for pdflatex.
I think it can be done, however with jPdfTweak instead.
add a comment |
For removing the old ones, probably the easiest cross-platform way is just to crop the old ones off. You could to this, for example, with BRISS.
Adding the new ones using free tools is more tricky. Personally I'd probably do it with pdflatex, as in this StackExchange answer, though that might be a rather involved solution unless you have other uses for pdflatex.
I think it can be done, however with jPdfTweak instead.
For removing the old ones, probably the easiest cross-platform way is just to crop the old ones off. You could to this, for example, with BRISS.
Adding the new ones using free tools is more tricky. Personally I'd probably do it with pdflatex, as in this StackExchange answer, though that might be a rather involved solution unless you have other uses for pdflatex.
I think it can be done, however with jPdfTweak instead.
edited May 23 '17 at 12:41
Community♦
1
1
answered Jan 13 '11 at 4:07
frabjousfrabjous
8,60822726
8,60822726
add a comment |
add a comment |
jPdf Tweak is an Open Source graphical utility that lets you edit page labels in PDF files. The documentation page provides step-by-step instructions.
I used this to add my custom page labels as "empty" format with text as prefix. Worked well!
– Matt Sephton
Aug 10 '17 at 21:53
add a comment |
jPdf Tweak is an Open Source graphical utility that lets you edit page labels in PDF files. The documentation page provides step-by-step instructions.
I used this to add my custom page labels as "empty" format with text as prefix. Worked well!
– Matt Sephton
Aug 10 '17 at 21:53
add a comment |
jPdf Tweak is an Open Source graphical utility that lets you edit page labels in PDF files. The documentation page provides step-by-step instructions.
jPdf Tweak is an Open Source graphical utility that lets you edit page labels in PDF files. The documentation page provides step-by-step instructions.
answered Aug 15 '14 at 7:23
CherryBerryCherryBerry
111
111
I used this to add my custom page labels as "empty" format with text as prefix. Worked well!
– Matt Sephton
Aug 10 '17 at 21:53
add a comment |
I used this to add my custom page labels as "empty" format with text as prefix. Worked well!
– Matt Sephton
Aug 10 '17 at 21:53
I used this to add my custom page labels as "empty" format with text as prefix. Worked well!
– Matt Sephton
Aug 10 '17 at 21:53
I used this to add my custom page labels as "empty" format with text as prefix. Worked well!
– Matt Sephton
Aug 10 '17 at 21:53
add a comment |
NOTE: The accepted answer is still mostly correct, but has some gaps. It is lacking in that many PDF files are not directly editable as text. Even when they are, such editing can sometimes damage the PDF making it unreadable. One solution, that will work for both Unix and Microsoft Windows is qpdf which can translate PDF files into "QDF", a text-editable form which is still a valid PDF file. The
qpdf
package comes withfix-qdf
that recalculates offsets after a QDF file has been edited to correct any damage.
HOW TO Edit PDF Page Numbers Using Qpdf
Summary:
qpdf -qdf foo.pdf foo.qdf
edit foo.qdf
0 << >> % No label on first pages
6 << /S /D >> % Start numbering from 7th page.
fix-qdf foo.qdf >bar.qdf
- test bar.qdf
qpdf bar.qdf bar.pdf
Step 1.
Convert the document to the easily editable QDF format. Run qpdf from the command line like so:
qpdf -qdf foo.pdf foo.qdf
Note: If you do not have qpdf installed already, Microsoft Windows executables can be downloaded from https://github.com/qpdf/qpdf/releases Unix systems, such as Ubuntu and Debian GNU/Linux can install it by typing
apt install qpdf
.
Step 2.
Edit the QDF document using a text editor such as notepad++, emacs, or gedit. Search for the word /Catalog
and note the <<angle brackets>> it is inside. Nearby, you'll find the current /PageLabels
(if any).
We'll be adding each section that should be differently numbered to the /PageLabels
. The format is start-page
<< style
>>. Note that white-space does not matter and that the first page of the document is 0
. Unless otherwise specified, a new section always starts out numbering pages from 1.
Here is a full example of what PageLabels may look like, with comments added:
/Type /Catalog
/PageLabels <<
/Nums [
0 % From the first page of the document,
<<
/S /r % ...use the lowercase roman numeral style.
>>
6 % From seventh page onward,
<<
/S /D % ...use ordinary digits (arabic numerals)
>>
]
>>
If the file has no PageLabels, add them after /Type /Catalog
. For example, one might change,
1 0 obj
<<
…
/Type /Catalog
>>
endobj
into,
1 0 obj
<<
…
/Type /Catalog
/PageLabels
<< /Nums [
0 << >> % No label for cover
1 << /S /r >> % i, ii for index
3 << /S /D /St 15 >> % 15, 16, 17, ... for article
31 << /S /D /P (A-) >> % A-1, A-2, A-3... for appendix
]
>>
>>
endobj
STARTING FROM A DIFFERENT NUMBER WITH /St
Each section restarts numbering at 1 unless you tell it otherwise using /St
. Notice how in the above example, the fourth page starts at 15.
USING A DIFFERENT STYLE WITH /S
The /S
operator takes an argument that lets you pick the numbering style,
- /D digits (1, 2, 3...)
- /R uppercase Roman (I, II, III...)
- /r lowercase Roman (i, ii, iii...)
- /A uppercase alphabetical (A, B, C, ...., X, Y, Z, AA, AB, AC,...)
- /a lowercase alphabetical (a, b, c, ...., x, y, z, aa, ab, ac,...)
If one omits the /S
operator, then that section of pages will have no numbering. For example:
0 << >> % No label for cover
ADDING A PREFIX TO EACH PAGE WITH /P
You can show any string of text before the page number by specifying a word in parentheses after /P
:
31
<<
/S /D
/P (A-) % label appendix pages A-1, A-2, A-3
>>
Specifying a prefix without a style (/S
), will give you pages that have only the word without any number. This can be useful, for example, if you'd like a cover page to simply have the label "Cover".
0 << /P (Cover) >> % No number, just "Cover"
Step 3.
Run fix-qdf
to make your edits valid PDF and put the output in bar.qdf.
fix-qdf foo.qdf > bar.qdf
Step 4.
Open bar.qdf in your PDF viewing program and check that it is numbered correctly.
Step 5.
Convert the QDF file back into a normal PDF, like so:
qpdf bar.qdf bar.pdf
Ta da. You're done. You now have a document with correctly labeled page numbers in bar.pdf.
add a comment |
NOTE: The accepted answer is still mostly correct, but has some gaps. It is lacking in that many PDF files are not directly editable as text. Even when they are, such editing can sometimes damage the PDF making it unreadable. One solution, that will work for both Unix and Microsoft Windows is qpdf which can translate PDF files into "QDF", a text-editable form which is still a valid PDF file. The
qpdf
package comes withfix-qdf
that recalculates offsets after a QDF file has been edited to correct any damage.
HOW TO Edit PDF Page Numbers Using Qpdf
Summary:
qpdf -qdf foo.pdf foo.qdf
edit foo.qdf
0 << >> % No label on first pages
6 << /S /D >> % Start numbering from 7th page.
fix-qdf foo.qdf >bar.qdf
- test bar.qdf
qpdf bar.qdf bar.pdf
Step 1.
Convert the document to the easily editable QDF format. Run qpdf from the command line like so:
qpdf -qdf foo.pdf foo.qdf
Note: If you do not have qpdf installed already, Microsoft Windows executables can be downloaded from https://github.com/qpdf/qpdf/releases Unix systems, such as Ubuntu and Debian GNU/Linux can install it by typing
apt install qpdf
.
Step 2.
Edit the QDF document using a text editor such as notepad++, emacs, or gedit. Search for the word /Catalog
and note the <<angle brackets>> it is inside. Nearby, you'll find the current /PageLabels
(if any).
We'll be adding each section that should be differently numbered to the /PageLabels
. The format is start-page
<< style
>>. Note that white-space does not matter and that the first page of the document is 0
. Unless otherwise specified, a new section always starts out numbering pages from 1.
Here is a full example of what PageLabels may look like, with comments added:
/Type /Catalog
/PageLabels <<
/Nums [
0 % From the first page of the document,
<<
/S /r % ...use the lowercase roman numeral style.
>>
6 % From seventh page onward,
<<
/S /D % ...use ordinary digits (arabic numerals)
>>
]
>>
If the file has no PageLabels, add them after /Type /Catalog
. For example, one might change,
1 0 obj
<<
…
/Type /Catalog
>>
endobj
into,
1 0 obj
<<
…
/Type /Catalog
/PageLabels
<< /Nums [
0 << >> % No label for cover
1 << /S /r >> % i, ii for index
3 << /S /D /St 15 >> % 15, 16, 17, ... for article
31 << /S /D /P (A-) >> % A-1, A-2, A-3... for appendix
]
>>
>>
endobj
STARTING FROM A DIFFERENT NUMBER WITH /St
Each section restarts numbering at 1 unless you tell it otherwise using /St
. Notice how in the above example, the fourth page starts at 15.
USING A DIFFERENT STYLE WITH /S
The /S
operator takes an argument that lets you pick the numbering style,
- /D digits (1, 2, 3...)
- /R uppercase Roman (I, II, III...)
- /r lowercase Roman (i, ii, iii...)
- /A uppercase alphabetical (A, B, C, ...., X, Y, Z, AA, AB, AC,...)
- /a lowercase alphabetical (a, b, c, ...., x, y, z, aa, ab, ac,...)
If one omits the /S
operator, then that section of pages will have no numbering. For example:
0 << >> % No label for cover
ADDING A PREFIX TO EACH PAGE WITH /P
You can show any string of text before the page number by specifying a word in parentheses after /P
:
31
<<
/S /D
/P (A-) % label appendix pages A-1, A-2, A-3
>>
Specifying a prefix without a style (/S
), will give you pages that have only the word without any number. This can be useful, for example, if you'd like a cover page to simply have the label "Cover".
0 << /P (Cover) >> % No number, just "Cover"
Step 3.
Run fix-qdf
to make your edits valid PDF and put the output in bar.qdf.
fix-qdf foo.qdf > bar.qdf
Step 4.
Open bar.qdf in your PDF viewing program and check that it is numbered correctly.
Step 5.
Convert the QDF file back into a normal PDF, like so:
qpdf bar.qdf bar.pdf
Ta da. You're done. You now have a document with correctly labeled page numbers in bar.pdf.
add a comment |
NOTE: The accepted answer is still mostly correct, but has some gaps. It is lacking in that many PDF files are not directly editable as text. Even when they are, such editing can sometimes damage the PDF making it unreadable. One solution, that will work for both Unix and Microsoft Windows is qpdf which can translate PDF files into "QDF", a text-editable form which is still a valid PDF file. The
qpdf
package comes withfix-qdf
that recalculates offsets after a QDF file has been edited to correct any damage.
HOW TO Edit PDF Page Numbers Using Qpdf
Summary:
qpdf -qdf foo.pdf foo.qdf
edit foo.qdf
0 << >> % No label on first pages
6 << /S /D >> % Start numbering from 7th page.
fix-qdf foo.qdf >bar.qdf
- test bar.qdf
qpdf bar.qdf bar.pdf
Step 1.
Convert the document to the easily editable QDF format. Run qpdf from the command line like so:
qpdf -qdf foo.pdf foo.qdf
Note: If you do not have qpdf installed already, Microsoft Windows executables can be downloaded from https://github.com/qpdf/qpdf/releases Unix systems, such as Ubuntu and Debian GNU/Linux can install it by typing
apt install qpdf
.
Step 2.
Edit the QDF document using a text editor such as notepad++, emacs, or gedit. Search for the word /Catalog
and note the <<angle brackets>> it is inside. Nearby, you'll find the current /PageLabels
(if any).
We'll be adding each section that should be differently numbered to the /PageLabels
. The format is start-page
<< style
>>. Note that white-space does not matter and that the first page of the document is 0
. Unless otherwise specified, a new section always starts out numbering pages from 1.
Here is a full example of what PageLabels may look like, with comments added:
/Type /Catalog
/PageLabels <<
/Nums [
0 % From the first page of the document,
<<
/S /r % ...use the lowercase roman numeral style.
>>
6 % From seventh page onward,
<<
/S /D % ...use ordinary digits (arabic numerals)
>>
]
>>
If the file has no PageLabels, add them after /Type /Catalog
. For example, one might change,
1 0 obj
<<
…
/Type /Catalog
>>
endobj
into,
1 0 obj
<<
…
/Type /Catalog
/PageLabels
<< /Nums [
0 << >> % No label for cover
1 << /S /r >> % i, ii for index
3 << /S /D /St 15 >> % 15, 16, 17, ... for article
31 << /S /D /P (A-) >> % A-1, A-2, A-3... for appendix
]
>>
>>
endobj
STARTING FROM A DIFFERENT NUMBER WITH /St
Each section restarts numbering at 1 unless you tell it otherwise using /St
. Notice how in the above example, the fourth page starts at 15.
USING A DIFFERENT STYLE WITH /S
The /S
operator takes an argument that lets you pick the numbering style,
- /D digits (1, 2, 3...)
- /R uppercase Roman (I, II, III...)
- /r lowercase Roman (i, ii, iii...)
- /A uppercase alphabetical (A, B, C, ...., X, Y, Z, AA, AB, AC,...)
- /a lowercase alphabetical (a, b, c, ...., x, y, z, aa, ab, ac,...)
If one omits the /S
operator, then that section of pages will have no numbering. For example:
0 << >> % No label for cover
ADDING A PREFIX TO EACH PAGE WITH /P
You can show any string of text before the page number by specifying a word in parentheses after /P
:
31
<<
/S /D
/P (A-) % label appendix pages A-1, A-2, A-3
>>
Specifying a prefix without a style (/S
), will give you pages that have only the word without any number. This can be useful, for example, if you'd like a cover page to simply have the label "Cover".
0 << /P (Cover) >> % No number, just "Cover"
Step 3.
Run fix-qdf
to make your edits valid PDF and put the output in bar.qdf.
fix-qdf foo.qdf > bar.qdf
Step 4.
Open bar.qdf in your PDF viewing program and check that it is numbered correctly.
Step 5.
Convert the QDF file back into a normal PDF, like so:
qpdf bar.qdf bar.pdf
Ta da. You're done. You now have a document with correctly labeled page numbers in bar.pdf.
NOTE: The accepted answer is still mostly correct, but has some gaps. It is lacking in that many PDF files are not directly editable as text. Even when they are, such editing can sometimes damage the PDF making it unreadable. One solution, that will work for both Unix and Microsoft Windows is qpdf which can translate PDF files into "QDF", a text-editable form which is still a valid PDF file. The
qpdf
package comes withfix-qdf
that recalculates offsets after a QDF file has been edited to correct any damage.
HOW TO Edit PDF Page Numbers Using Qpdf
Summary:
qpdf -qdf foo.pdf foo.qdf
edit foo.qdf
0 << >> % No label on first pages
6 << /S /D >> % Start numbering from 7th page.
fix-qdf foo.qdf >bar.qdf
- test bar.qdf
qpdf bar.qdf bar.pdf
Step 1.
Convert the document to the easily editable QDF format. Run qpdf from the command line like so:
qpdf -qdf foo.pdf foo.qdf
Note: If you do not have qpdf installed already, Microsoft Windows executables can be downloaded from https://github.com/qpdf/qpdf/releases Unix systems, such as Ubuntu and Debian GNU/Linux can install it by typing
apt install qpdf
.
Step 2.
Edit the QDF document using a text editor such as notepad++, emacs, or gedit. Search for the word /Catalog
and note the <<angle brackets>> it is inside. Nearby, you'll find the current /PageLabels
(if any).
We'll be adding each section that should be differently numbered to the /PageLabels
. The format is start-page
<< style
>>. Note that white-space does not matter and that the first page of the document is 0
. Unless otherwise specified, a new section always starts out numbering pages from 1.
Here is a full example of what PageLabels may look like, with comments added:
/Type /Catalog
/PageLabels <<
/Nums [
0 % From the first page of the document,
<<
/S /r % ...use the lowercase roman numeral style.
>>
6 % From seventh page onward,
<<
/S /D % ...use ordinary digits (arabic numerals)
>>
]
>>
If the file has no PageLabels, add them after /Type /Catalog
. For example, one might change,
1 0 obj
<<
…
/Type /Catalog
>>
endobj
into,
1 0 obj
<<
…
/Type /Catalog
/PageLabels
<< /Nums [
0 << >> % No label for cover
1 << /S /r >> % i, ii for index
3 << /S /D /St 15 >> % 15, 16, 17, ... for article
31 << /S /D /P (A-) >> % A-1, A-2, A-3... for appendix
]
>>
>>
endobj
STARTING FROM A DIFFERENT NUMBER WITH /St
Each section restarts numbering at 1 unless you tell it otherwise using /St
. Notice how in the above example, the fourth page starts at 15.
USING A DIFFERENT STYLE WITH /S
The /S
operator takes an argument that lets you pick the numbering style,
- /D digits (1, 2, 3...)
- /R uppercase Roman (I, II, III...)
- /r lowercase Roman (i, ii, iii...)
- /A uppercase alphabetical (A, B, C, ...., X, Y, Z, AA, AB, AC,...)
- /a lowercase alphabetical (a, b, c, ...., x, y, z, aa, ab, ac,...)
If one omits the /S
operator, then that section of pages will have no numbering. For example:
0 << >> % No label for cover
ADDING A PREFIX TO EACH PAGE WITH /P
You can show any string of text before the page number by specifying a word in parentheses after /P
:
31
<<
/S /D
/P (A-) % label appendix pages A-1, A-2, A-3
>>
Specifying a prefix without a style (/S
), will give you pages that have only the word without any number. This can be useful, for example, if you'd like a cover page to simply have the label "Cover".
0 << /P (Cover) >> % No number, just "Cover"
Step 3.
Run fix-qdf
to make your edits valid PDF and put the output in bar.qdf.
fix-qdf foo.qdf > bar.qdf
Step 4.
Open bar.qdf in your PDF viewing program and check that it is numbered correctly.
Step 5.
Convert the QDF file back into a normal PDF, like so:
qpdf bar.qdf bar.pdf
Ta da. You're done. You now have a document with correctly labeled page numbers in bar.pdf.
answered Oct 17 '18 at 13:41
hackerb9hackerb9
45156
45156
add a comment |
add a comment |
BeCyPDFMetaEdit
http://www.becyhome.de/becypdfmetaedit/description_eng.htm
You can add/remove/change internal page numbers scheme in the "pages" tab of this freeware tool.
And be caution, PDF xchange viewer doesn't show the page number scheme, and foxitreader have a right result. I have not test the Acrobat reader.
add a comment |
BeCyPDFMetaEdit
http://www.becyhome.de/becypdfmetaedit/description_eng.htm
You can add/remove/change internal page numbers scheme in the "pages" tab of this freeware tool.
And be caution, PDF xchange viewer doesn't show the page number scheme, and foxitreader have a right result. I have not test the Acrobat reader.
add a comment |
BeCyPDFMetaEdit
http://www.becyhome.de/becypdfmetaedit/description_eng.htm
You can add/remove/change internal page numbers scheme in the "pages" tab of this freeware tool.
And be caution, PDF xchange viewer doesn't show the page number scheme, and foxitreader have a right result. I have not test the Acrobat reader.
BeCyPDFMetaEdit
http://www.becyhome.de/becypdfmetaedit/description_eng.htm
You can add/remove/change internal page numbers scheme in the "pages" tab of this freeware tool.
And be caution, PDF xchange viewer doesn't show the page number scheme, and foxitreader have a right result. I have not test the Acrobat reader.
edited Feb 16 '14 at 9:14
answered Feb 16 '14 at 9:06
SulisuSulisu
515
515
add a comment |
add a comment |
The method given by Dane H. does work with Acrobat Reader (or, to be precise, the current version of Adobe Reader). One minor point to note: the field at the top will only accept 8 characters so you can't enter something like 'subject index' into it if such a label has been used. But you can instead use menu item View > Page Navigation > Go to..., or the key equivalent.
Another tip: pdf specification always assigns page numbers consecutively, so in the case of a document produced by scanning pairs of pages the two sets of numbers get out of step (unless you laboriously number each page individually). But you can with little effort set up your document so the convention 'go to page n gets you to pages 2n and 2n+1' applies.
add a comment |
The method given by Dane H. does work with Acrobat Reader (or, to be precise, the current version of Adobe Reader). One minor point to note: the field at the top will only accept 8 characters so you can't enter something like 'subject index' into it if such a label has been used. But you can instead use menu item View > Page Navigation > Go to..., or the key equivalent.
Another tip: pdf specification always assigns page numbers consecutively, so in the case of a document produced by scanning pairs of pages the two sets of numbers get out of step (unless you laboriously number each page individually). But you can with little effort set up your document so the convention 'go to page n gets you to pages 2n and 2n+1' applies.
add a comment |
The method given by Dane H. does work with Acrobat Reader (or, to be precise, the current version of Adobe Reader). One minor point to note: the field at the top will only accept 8 characters so you can't enter something like 'subject index' into it if such a label has been used. But you can instead use menu item View > Page Navigation > Go to..., or the key equivalent.
Another tip: pdf specification always assigns page numbers consecutively, so in the case of a document produced by scanning pairs of pages the two sets of numbers get out of step (unless you laboriously number each page individually). But you can with little effort set up your document so the convention 'go to page n gets you to pages 2n and 2n+1' applies.
The method given by Dane H. does work with Acrobat Reader (or, to be precise, the current version of Adobe Reader). One minor point to note: the field at the top will only accept 8 characters so you can't enter something like 'subject index' into it if such a label has been used. But you can instead use menu item View > Page Navigation > Go to..., or the key equivalent.
Another tip: pdf specification always assigns page numbers consecutively, so in the case of a document produced by scanning pairs of pages the two sets of numbers get out of step (unless you laboriously number each page individually). But you can with little effort set up your document so the convention 'go to page n gets you to pages 2n and 2n+1' applies.
answered Mar 18 '14 at 12:39
user308637user308637
1
1
add a comment |
add a comment |
Danes answer is the best, the formats changed a little now, this might be helpful:
%PDF-1.6
29241 0 obj
<</Metadata 1685 0 R/Outlines 29461 0 R/PageLabels<</Nums[0<</S/D>>3<</S/D/St 6>>4<</S/D/St 10>>5<</S/D/St 12>>15<</S/D/St 70>>16<</S/D/St 72>>17<</S/D/St 80>>18<</S/D/St 82>>19<</S/D/St 90>>23<</S/D/St 96>>25<</S/D/St 99>>29<</S/D/St 110>>31<</S/D/St 130>>32<</S/D/St 133>>35<</S/D/St 137>>36<</S/D/St 140>>37<</S/D/St 145>>39<</S/D/St 150>>40<</S/D/St 152>>42<</S/D/St 155>>43<</S/D/St 160>>46<</S/D/St 165>>47<</S/D/St 167>>48<</S/D/St 170>>49<</S/D/St 180>>50<</S/D/St 190>>52<</S/D/St 300>>53<</S/D/St 305>>54<</S/D/St 319>>56<</S/D/St 380>>57<</S/D/St 390>>58<</S/D/St 500>>67<</S/D/St 515>>68<</S/D/St 525>>70<</S/D/St 550>>71<</S/D/St 553>>72<</S/D/St 560>>73<</S/D/St 600>>76<</S/D/St 620>>78<</S/D/St 650>>82<</S/D/St 670>>85<</S/D/St 700>>95<</S/D/St 714>>117<</S/D/St 900>>162<</S/D/St 1000>>178<</S/D/St 1200>>209<</S/D/St 1500>>263<</S/D/St 1555>>270<</S/D/St 1563>>389<</S/D/St 1681>>522<</S/D/St 1813>>]>> /PageMode/UseOutlines/Pages 29177 0 R/Type/Catalog>>
endobj
add a comment |
Danes answer is the best, the formats changed a little now, this might be helpful:
%PDF-1.6
29241 0 obj
<</Metadata 1685 0 R/Outlines 29461 0 R/PageLabels<</Nums[0<</S/D>>3<</S/D/St 6>>4<</S/D/St 10>>5<</S/D/St 12>>15<</S/D/St 70>>16<</S/D/St 72>>17<</S/D/St 80>>18<</S/D/St 82>>19<</S/D/St 90>>23<</S/D/St 96>>25<</S/D/St 99>>29<</S/D/St 110>>31<</S/D/St 130>>32<</S/D/St 133>>35<</S/D/St 137>>36<</S/D/St 140>>37<</S/D/St 145>>39<</S/D/St 150>>40<</S/D/St 152>>42<</S/D/St 155>>43<</S/D/St 160>>46<</S/D/St 165>>47<</S/D/St 167>>48<</S/D/St 170>>49<</S/D/St 180>>50<</S/D/St 190>>52<</S/D/St 300>>53<</S/D/St 305>>54<</S/D/St 319>>56<</S/D/St 380>>57<</S/D/St 390>>58<</S/D/St 500>>67<</S/D/St 515>>68<</S/D/St 525>>70<</S/D/St 550>>71<</S/D/St 553>>72<</S/D/St 560>>73<</S/D/St 600>>76<</S/D/St 620>>78<</S/D/St 650>>82<</S/D/St 670>>85<</S/D/St 700>>95<</S/D/St 714>>117<</S/D/St 900>>162<</S/D/St 1000>>178<</S/D/St 1200>>209<</S/D/St 1500>>263<</S/D/St 1555>>270<</S/D/St 1563>>389<</S/D/St 1681>>522<</S/D/St 1813>>]>> /PageMode/UseOutlines/Pages 29177 0 R/Type/Catalog>>
endobj
add a comment |
Danes answer is the best, the formats changed a little now, this might be helpful:
%PDF-1.6
29241 0 obj
<</Metadata 1685 0 R/Outlines 29461 0 R/PageLabels<</Nums[0<</S/D>>3<</S/D/St 6>>4<</S/D/St 10>>5<</S/D/St 12>>15<</S/D/St 70>>16<</S/D/St 72>>17<</S/D/St 80>>18<</S/D/St 82>>19<</S/D/St 90>>23<</S/D/St 96>>25<</S/D/St 99>>29<</S/D/St 110>>31<</S/D/St 130>>32<</S/D/St 133>>35<</S/D/St 137>>36<</S/D/St 140>>37<</S/D/St 145>>39<</S/D/St 150>>40<</S/D/St 152>>42<</S/D/St 155>>43<</S/D/St 160>>46<</S/D/St 165>>47<</S/D/St 167>>48<</S/D/St 170>>49<</S/D/St 180>>50<</S/D/St 190>>52<</S/D/St 300>>53<</S/D/St 305>>54<</S/D/St 319>>56<</S/D/St 380>>57<</S/D/St 390>>58<</S/D/St 500>>67<</S/D/St 515>>68<</S/D/St 525>>70<</S/D/St 550>>71<</S/D/St 553>>72<</S/D/St 560>>73<</S/D/St 600>>76<</S/D/St 620>>78<</S/D/St 650>>82<</S/D/St 670>>85<</S/D/St 700>>95<</S/D/St 714>>117<</S/D/St 900>>162<</S/D/St 1000>>178<</S/D/St 1200>>209<</S/D/St 1500>>263<</S/D/St 1555>>270<</S/D/St 1563>>389<</S/D/St 1681>>522<</S/D/St 1813>>]>> /PageMode/UseOutlines/Pages 29177 0 R/Type/Catalog>>
endobj
Danes answer is the best, the formats changed a little now, this might be helpful:
%PDF-1.6
29241 0 obj
<</Metadata 1685 0 R/Outlines 29461 0 R/PageLabels<</Nums[0<</S/D>>3<</S/D/St 6>>4<</S/D/St 10>>5<</S/D/St 12>>15<</S/D/St 70>>16<</S/D/St 72>>17<</S/D/St 80>>18<</S/D/St 82>>19<</S/D/St 90>>23<</S/D/St 96>>25<</S/D/St 99>>29<</S/D/St 110>>31<</S/D/St 130>>32<</S/D/St 133>>35<</S/D/St 137>>36<</S/D/St 140>>37<</S/D/St 145>>39<</S/D/St 150>>40<</S/D/St 152>>42<</S/D/St 155>>43<</S/D/St 160>>46<</S/D/St 165>>47<</S/D/St 167>>48<</S/D/St 170>>49<</S/D/St 180>>50<</S/D/St 190>>52<</S/D/St 300>>53<</S/D/St 305>>54<</S/D/St 319>>56<</S/D/St 380>>57<</S/D/St 390>>58<</S/D/St 500>>67<</S/D/St 515>>68<</S/D/St 525>>70<</S/D/St 550>>71<</S/D/St 553>>72<</S/D/St 560>>73<</S/D/St 600>>76<</S/D/St 620>>78<</S/D/St 650>>82<</S/D/St 670>>85<</S/D/St 700>>95<</S/D/St 714>>117<</S/D/St 900>>162<</S/D/St 1000>>178<</S/D/St 1200>>209<</S/D/St 1500>>263<</S/D/St 1555>>270<</S/D/St 1563>>389<</S/D/St 1681>>522<</S/D/St 1813>>]>> /PageMode/UseOutlines/Pages 29177 0 R/Type/Catalog>>
endobj
answered Jun 24 '14 at 15:59
danieldaniel
623169
623169
add a comment |
add a comment |
I found direct editing of the file (as uncompressed by pdftk) not to work if there are already '/titles' set in the '/outlines' region.
The direct-editing technique described in a post above is demonstrated on Youtube:
https://www.youtube.com/watch?v=zoH1Z_hSpak
But the 'update' feature of pdftk may be more intuitive (and more reliable when '/titles' already exist in the '/outlines' region of the PDF file) via editing the 'doc_data.txt' file used here:
https://www.pdflabs.com/blog/export-and-import-pdf-bookmarks/
1
Hi @Bob, Link-only answers are low quality. They will be useless if the target site moves or disappears. Please edit your answer and quote the relevant part of the solution here.
– C0deDaedalus
May 27 '18 at 19:18
add a comment |
I found direct editing of the file (as uncompressed by pdftk) not to work if there are already '/titles' set in the '/outlines' region.
The direct-editing technique described in a post above is demonstrated on Youtube:
https://www.youtube.com/watch?v=zoH1Z_hSpak
But the 'update' feature of pdftk may be more intuitive (and more reliable when '/titles' already exist in the '/outlines' region of the PDF file) via editing the 'doc_data.txt' file used here:
https://www.pdflabs.com/blog/export-and-import-pdf-bookmarks/
1
Hi @Bob, Link-only answers are low quality. They will be useless if the target site moves or disappears. Please edit your answer and quote the relevant part of the solution here.
– C0deDaedalus
May 27 '18 at 19:18
add a comment |
I found direct editing of the file (as uncompressed by pdftk) not to work if there are already '/titles' set in the '/outlines' region.
The direct-editing technique described in a post above is demonstrated on Youtube:
https://www.youtube.com/watch?v=zoH1Z_hSpak
But the 'update' feature of pdftk may be more intuitive (and more reliable when '/titles' already exist in the '/outlines' region of the PDF file) via editing the 'doc_data.txt' file used here:
https://www.pdflabs.com/blog/export-and-import-pdf-bookmarks/
I found direct editing of the file (as uncompressed by pdftk) not to work if there are already '/titles' set in the '/outlines' region.
The direct-editing technique described in a post above is demonstrated on Youtube:
https://www.youtube.com/watch?v=zoH1Z_hSpak
But the 'update' feature of pdftk may be more intuitive (and more reliable when '/titles' already exist in the '/outlines' region of the PDF file) via editing the 'doc_data.txt' file used here:
https://www.pdflabs.com/blog/export-and-import-pdf-bookmarks/
answered May 27 '18 at 17:48
BobBob
1
1
1
Hi @Bob, Link-only answers are low quality. They will be useless if the target site moves or disappears. Please edit your answer and quote the relevant part of the solution here.
– C0deDaedalus
May 27 '18 at 19:18
add a comment |
1
Hi @Bob, Link-only answers are low quality. They will be useless if the target site moves or disappears. Please edit your answer and quote the relevant part of the solution here.
– C0deDaedalus
May 27 '18 at 19:18
1
1
Hi @Bob, Link-only answers are low quality. They will be useless if the target site moves or disappears. Please edit your answer and quote the relevant part of the solution here.
– C0deDaedalus
May 27 '18 at 19:18
Hi @Bob, Link-only answers are low quality. They will be useless if the target site moves or disappears. Please edit your answer and quote the relevant part of the solution here.
– C0deDaedalus
May 27 '18 at 19:18
add a comment |
There is a little python script, that can do the job: https://github.com/lovasoa/pagelabels-py
In your case call something like:
./addpagelabels.py --delete file.pdf
./addpagelabels.py --startpage 1 --type 'roman lowercase' file.pdf
./addpagelabels.py --startpage 7 --type arabic file.pdf
add a comment |
There is a little python script, that can do the job: https://github.com/lovasoa/pagelabels-py
In your case call something like:
./addpagelabels.py --delete file.pdf
./addpagelabels.py --startpage 1 --type 'roman lowercase' file.pdf
./addpagelabels.py --startpage 7 --type arabic file.pdf
add a comment |
There is a little python script, that can do the job: https://github.com/lovasoa/pagelabels-py
In your case call something like:
./addpagelabels.py --delete file.pdf
./addpagelabels.py --startpage 1 --type 'roman lowercase' file.pdf
./addpagelabels.py --startpage 7 --type arabic file.pdf
There is a little python script, that can do the job: https://github.com/lovasoa/pagelabels-py
In your case call something like:
./addpagelabels.py --delete file.pdf
./addpagelabels.py --startpage 1 --type 'roman lowercase' file.pdf
./addpagelabels.py --startpage 7 --type arabic file.pdf
answered Jan 13 at 21:17
DG'DG'
18114
18114
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f232553%2fhow-to-change-internal-page-numbers-in-the-meta-data-of-a-pdf%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I'm not sure if I understand your description+requirement fully. Can you provide a link to a sample PDF you want to modify?
– Kurt Pfeifle
Jan 14 '11 at 14:17
is there a command line tool to do that, e.g. on a big pdf file without actually opening the txt file?
– jj_p
Sep 20 '13 at 13:50
like e.g. pdftk?
– jj_p
Sep 23 '13 at 7:01