adrienbrignon / mkdocs-exporter

⚡ The fastest and most configurable plugin for MkDocs, allowing seamless export of individual pages and/or entire documentation as PDF documents.
https://adrienbrignon.github.io/mkdocs-exporter/
MIT License
83 stars 9 forks source link

Aggregate files not found when processing overly large projects #51

Open nbanyan opened 2 weeks ago

nbanyan commented 2 weeks ago

Unfortunately, this may be hard to replicate with a fabricated example. One of my MkDocs projects is very large (trying to print the entire thing with another program put it at over PDF 1800 pages). With that project, I get the following error where it looks like the temporary directory or files are expiring before aggregation can complete.

Traceback (most recent call last):
  File "/Users/training4/venv3.9/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/mkdocs/__main__.py", line 268, in serve_command
    serve.serve(**kwargs)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 85, in serve
    builder(config)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 67, in builder
    build(config, serve_url=None if is_clean else serve_url, dirty=is_dirty)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 347, in build
    config.plugins.on_post_build(config=config)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/mkdocs/plugins.py", line 602, in on_post_build
    return self.run_event('post_build', config=config)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/mkdocs/plugins.py", line 568, in run_event
    result = method(**kwargs)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/mkdocs_exporter/formats/pdf/plugin.py", line 190, in _on_post_build_2
    self.aggregator.append(page.formats['pdf']['path'] + '.aggregate')
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/mkdocs_exporter/formats/pdf/aggregator.py", line 90, in append
    self.writer.append(document)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/pypdf/_writer.py", line 2638, in append
    self.merge(
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/pypdf/_writer.py", line 2688, in merge
    stream, encryption_obj = self._create_stream(fileobj)
  File "/Users/training4/venv3.9/lib/python3.9/site-packages/pypdf/_writer.py", line 2555, in _create_stream
    with FileIO(fileobj, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/ry/06xwpwrn3cvgmlgm77pbdd9h0000gp/T/mkdocs_tg3gc1b3/content_category_54/file_name.pdf.aggregate'