Modify page numbering in PDF Map Book ie.( i, ii, iii, 1, 2, 3...)

2909
4
Jump to solution
12-10-2013 03:51 AM
JimIrwin
New Contributor
I have three cover pages and I want the map pages to start at 1 under the page thumbnails.  I've succesfuly made this happen by opening up the map book in a text editor and adding the following in the metadata section

PageLabels << /Nums [0 << /S /r >>3 << /S /D >>]>>


This says that starting at page index 0, number pages with lowercase roman, and starting at page index 3, number with decimal.  This works and I can even do a search and replace with my text editor to get it in the right pace and make it happen. What won't work is doing a simple search and replace using python since it gets fouled up on the binary characters in the pdf.  My python code iterates through 256 towns to build separate map books.

OK with that said I would like to add this to my Python code in ArcGIS, but I can't get the syntax right.  I am trying to use pdf_keywords attribute which applies to metadata. the here is what I am trying;

               #Append cover sheets PDF file         for f in coverSheets:             finalPdf.appendPages(f)                  #Append Locus         finalPdf.appendPages(tmpPdf_locus)                  #Append pages         finalPdf.appendPages(tmpPdf)          #Update the properties of the final pdf to show thumbnail view         finalPdf.updateDocProperties(pdf_open_view='USE_THUMBS',                                                pdf_keywords="PageLabels << /Nums [0 << /S /r >>3 << /S /D >>]>>",  #NOT WORKING                                                pdf_layout='SINGLE_PAGE')


One more thing I looked at is getting the properties of a modified working pdf with pdfMiner.  This property is listed as follows;

[ATTACH=CONFIG]29710[/ATTACH]

Any help would be appreciated.
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Original User: msayler

I think the pdf "keywords" the arcpy is refering to are basically tags, not anything to do with the pdf settings.

Example 2 from the help:
import arcpy pdfDoc = arcpy.mapping.PDFDocumentOpen(r"C:\Project\ParcelAtlasMapBook.pdf") pdfDoc.updateDocProperties(pdf_title="Atlas Map",                            pdf_author="Author",                            pdf_subject="Map Book",                            pdf_keywords="Atlas; Map Books",                            pdf_open_view="USE_THUMBS",                            pdf_layout="SINGLE_PAGE") pdfDoc.saveAndClose() del pdfDoc


http://resources.arcgis.com/en/help/main/10.1/index.html#//00s30000002w000000

I think ReportLab is the most robust python library for pdfs, but I haven't used it so no idea if it can help you out.
http://www.reportlab.com/software/opensource/rl-toolkit/

View solution in original post

0 Kudos
4 Replies
by Anonymous User
Not applicable
Original User: msayler

I think the pdf "keywords" the arcpy is refering to are basically tags, not anything to do with the pdf settings.

Example 2 from the help:
import arcpy pdfDoc = arcpy.mapping.PDFDocumentOpen(r"C:\Project\ParcelAtlasMapBook.pdf") pdfDoc.updateDocProperties(pdf_title="Atlas Map",                            pdf_author="Author",                            pdf_subject="Map Book",                            pdf_keywords="Atlas; Map Books",                            pdf_open_view="USE_THUMBS",                            pdf_layout="SINGLE_PAGE") pdfDoc.saveAndClose() del pdfDoc


http://resources.arcgis.com/en/help/main/10.1/index.html#//00s30000002w000000

I think ReportLab is the most robust python library for pdfs, but I haven't used it so no idea if it can help you out.
http://www.reportlab.com/software/opensource/rl-toolkit/
0 Kudos
JimIrwin
New Contributor
Your answer makes perfect sense.  pdf_keywords is for metatata only, and is only for search terms.  I'll abandon using arcpy to set page numbers and go to third party modules.  I am working with PyPDF2 to try to come up with a solution and I'll look at ReportLab.

Thanks for your help
0 Kudos
by Anonymous User
Not applicable
Original User: jbarrette

Other than using a site-package like Report Lab, if you have Data Driven Pages enabled, there is a property called "Starting Page Number" to provide this offset.  You could also do it with arcpy.mapping if you use Python logic to increment the value of a text element on a layout.

Here is a sample that uses arcpy.mapping AND ReportLab to build street index pages at the end of the map book.

http://www.arcgis.com/home/item.html?id=0588e23e83f245afaa8501e84e7b25e5


Jeff
0 Kudos
JimIrwin
New Contributor
Thanks for the reply, I built my map books and they came out great using python and the data driven pages tools.  In all the previous years I used a dot net application that I wrote from scratch that pulls from the Adobe SDK.  The new way is so much cleaner and better.

I wound up handling the page numbering problem using Adobe Acrobat Pro.  It allows for batch processing where you can point to a folder and have it renumber all 256 pdfs in a few minutes.

I've downloaded the sample that you provided below and will look into adding functionality from Reportlab.

Jim
0 Kudos