Comments (6)
Can you try using an absolute URL like (notice the /
in front of the path):
- print-site:
path_to_pdf: "/tmp/12345/document.pdf"
from mkdocs-print-site-plugin.
Alternatively, if you mean the tmp
folder is in your git repostory on the save level as docs
, you could try ../tmp/12345/document.pdf
.
In the code, a relative URL is determined from the page URL:
mkdocs-print-site-plugin/mkdocs_print_site_plugin/plugin.py
Lines 232 to 236 in 11faed7
from mkdocs-print-site-plugin.
Alternatively, if you mean the
tmp
folder is in your git repostory on the save level asdocs
, you could try../tmp/12345/document.pdf
.
I tried it,and my project look like this
│└─ docs
│└─ assets
│ └─ document.pdf
└─ mkdocs.yml
I tried
- print-site:
path_to_pdf: "../assets/document.pdf"
also tried
- print-site:
path_to_pdf: "/User/xxx/project_name/assets/document.pdf"
from mkdocs-print-site-plugin.
I see. It has to do with the get_relative_url()
function, (from mkdocs.utils
):
def get_relative_url(url: str, other: str) -> str:
"""
Return given url relative to other.
Both are operated as slash-separated paths, similarly to the 'path' part of a URL.
The last component of `other` is skipped if it contains a dot (considered a file).
Actual URLs (with schemas etc.) aren't supported. The leading slash is ignored.
Paths are normalized ('..' works as parent directory), but going higher than the
root has no effect ('foo/../../bar' ends up just as 'bar').
"""
...
So mkdocs
is expecting assets to be either a URL or inside the project.
One solution could be to use the new mkdocs 1.4 hooks feature. Pseudo code:
- Add a script like
scripts/move_assets.py
with
import shutil
from pathlib import Path
def on_startup(*args, **kwargs):
dst_path = "docs/assets/pdfs"
Path(dst_path).mkdirs(exist_ok=True)
shutil.copy("your folder location of PDF", dst_path)
- Update
mkdocs.yml
with:
hooks:
- scripts/move_assets.py
- Update your
.gitignore
file:
echo "docs/assets/pdfs/" >> .gitignore
from mkdocs-print-site-plugin.
ah,thanks for your support, will try it later.
from mkdocs-print-site-plugin.
Closing this issue, as any assets always need to be inside the docs/
folder.
There is a separate issue when using external URLs with path_to_pdf
, for which I will release a fix soon
from mkdocs-print-site-plugin.
Related Issues (20)
- Print-site and privacy plugin HOT 2
- Does this plugin work with Python 3.12? HOT 7
- If print-site step takes >10s raise a warning
- Excluding directory does not exclude submenu
- Plugin breaks site base URL configuration with Material theme HOT 1
- Use the new plugin priority system to ensure this plugin is last
- Please add support for Read the Docs theme HOT 1
- Sections with sub-sections not correctly rendered in sidebar TOC HOT 1
- Print_site_banner doesn't work when site has base url HOT 2
- :bug: MkDocs 1.5.1, Material 9.1.21, Python 3.11 and Extra JavaScript Traceback
- Missing left toc and search panel HOT 4
- Can not ignore title with print-site-plugin-ignore HOT 5
- Add support for tags HOT 2
- Fix deprecation warning on `warning_filter` HOT 1
- Use frontmatter `title` in place of level 1 heading for TOC and heading enumeration HOT 3
- Image/diagram exports or transformations made by other plugin(s) not included as expected (mkdocs-drawio-exporter) HOT 4
- Toc inclusion not fully documented HOT 3
- Option to add page numbers to footer and TOC HOT 2
- Drawio content is missing in printed export HOT 7
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 mkdocs-print-site-plugin.