zhaoterryy / mkdocs-pdf-export-plugin

An MkDocs plugin to export content pages as PDF files
MIT License
318 stars 42 forks source link

Image resizing in pdf generated #59

Open nehatharani opened 5 years ago

nehatharani commented 5 years ago

Hi, I am trying to export the documentation build using mkdocs - material theme. It has been working smoothly so far. The problem arises when I try to take export in pdf. Every time I do ENABLE_PDF_EXPORT=1 mkdocs build I get the error that

Traceback (most recent call last):
  File "/python/miniconda3/bin/mkdocs", line 10, in <module>
    sys.exit(cli())
  File "/python/miniconda3/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/python/miniconda3/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/python/miniconda3/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/python/miniconda3/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/python/miniconda3/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/python/miniconda3/lib/python3.7/site-packages/mkdocs/__main__.py", line 163, in build_command
    ), dirty=not clean)
  File "/python/miniconda3/lib/python3.7/site-packages/mkdocs/commands/build.py", line 298, in build
    config['plugins'].run_event('post_build', config)
  File "/python/miniconda3/lib/python3.7/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "/python/miniconda3/lib/python3.7/site-packages/mkpdfs_mkdocs/mkpdfs.py", line 64, in on_post_build
    self.generator.write()
  File "/python/miniconda3/lib/python3.7/site-packages/mkpdfs_mkdocs/generator.py", line 60, in write
    font_config=font_config)
  File "/python/miniconda3/lib/python3.7/site-packages/weasyprint/__init__.py", line 212, in write_pdf
    target, zoom, attachments)
  File "/python/miniconda3/lib/python3.7/site-packages/weasyprint/document.py", line 696, in write_pdf
    with open(target, 'wb') as fd:
FileNotFoundError: [Errno 2] No such file or directory: '/python/html/data/www/website/mkdocs-project/site/pdf/combined.pdf'

Further, there is some pdf generated but the images are too large. Is there a way to scale image via custom CSS? I have already tried to reseize images using

tags but in pdf generation, it does not reflect.

Any help will be much appreciated. Thanks!

Settings: mkdocs version -1.0.4 mkdocs-pdf-export-plugin - 0.5.5 python - 3.7.3

Sphinkie commented 3 years ago

Hello, I meet the same issue: the images are too large in the generated pdf document. I have tried different styles.scss and also .png images with different dpi : but without results. Did you manage to find a way to reduce the image size in the pdf ? Thanks David

nehatharani commented 3 years ago

Hi @Sphinkie,

I haven't found anything with custom CSS yet as I worked on it for a very short time and got busy with other work. But for the time being I just use (ctrl+p or cmd+p)print -> send to pdf and it creates a nice pdf with all formatting intact.

Hello, I meet the same issue: the images are too large in the generated pdf document. I have tried different styles.scss and also .png images with different dpi : but without results. Did you manage to find a way to reduce the image size in the pdf ? Thanks David