Comments (6)
You already can manipulate the bookmarks data structure manually. Yes, I'd like to add this. Bookmarks have a lot of functionality associated.
from pikepdf.
Thanks again !
from pikepdf.
Finally i got what I wanted by parsing and imitating existing cases.
outlines = pikepdf.Dictionary({
"/Type": pikepdf.Name("/Outlines"),
"/Count": 0
})
for i in enumerate(ordered_bookmarks):
child = pikepdf.Dictionary({
"/A": pikepdf.Dictionary({
"/D": pikepdf.Array([
pdf_writer.root["/Pages"]["/Kids"][i[0]],
pikepdf.Name("/Fit")
]),
"/S": pikepdf.Name("/GoTo")
}),
"/Title": pikepdf.String(i[1]),
})
if "/First" not in outlines:
outlines["/First"] = child
else:
outlines["/Last"]["/Next"] = child
outlines["/Last"] = child
outlines["/Count"] += 1
pdf_writer.root["/Outlines"] = outlines
from pikepdf.
@OnlyFor , what is the variable ordered_bookmarks
you are enumerating?
My quest is to find the page numbers that specifically a named bookmark refers to. I'm from the javascript world, so still trying to wrap my mind around python's style.
Do you have any examples that show a list of the bookmarks + their properties (namely just "Title" and "Page")?
from pikepdf.
Have a look at the PDF reference manual (ISO32000 2008) in section H.6 for a description of how the document outline works. In short it is a tree data structure and you have to decide how you want to traverse it. It's difficult to describe without diagrams. The reference manual is linked the pikepdf documentation.
from pikepdf.
Thanks @jbarlow83 . I'll take a look.
from pikepdf.
Related Issues (20)
- PackagesNotFoundError in Conda HOT 2
- image and its caption HOT 1
- Deterministic PDF generation HOT 1
- How to access OCR-data? HOT 1
- Import/Export annotations to FDF/JSON format HOT 1
- cannot install
- Accessibility Settings Issue HOT 1
- [ISSUE] Missing XMP Metadata HOT 1
- Traverse PDF layers and classes HOT 1
- Instalation errors
- How to replace the value of an Object mapped to a variable HOT 1
- pikepdf, libjpeg, l HOT 1
- 8.11.0: pytest requires `conftest` HOT 5
- Add 2 overlaid images to page with transparency mask HOT 2
- Add type checking for setting XMP metadata HOT 1
- RDF/XMP generated by pikepdf is incorrect?
- Question on file compression. HOT 1
- Re-enable 32-bit wheels on Windows HOT 2
- While emplacing a pdf, it changes underlying page metadata incorrectly HOT 1
- The pdf doc has been linearized, but the property "fast web view" still is “no" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pikepdf.