Giter VIP home page Giter VIP logo

mdpdf's People

Contributors

normanlorrain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mdpdf's Issues

Hardcoded meta data

Hey @normanlorrain,

Thanks for this great package!

I just realized that the meta data is hard coded.

document = {
"creationDate": fitz.getPDFnow(), # current timestamp
"modDate": fitz.getPDFnow(), # current timestamp
"creator": "mdpdf",
"producer": "mdpdf",
"title": "title goes here",
"subject": "subject here",
"author": "author here",
}

One improvement could be to set the meta data in cli or leave it empty, as not everyone wants to have the tile "title goes here" ๐Ÿ˜‰

The paper size is hard coded as well, which some might find useful to change.

width, height = fitz.PaperSize("letter") # choose paper format

If you don't have the time for it, I'll make a pull request but it might take quite a while before I find time to dive into your code.

help

Thank you for your script
i need little help about your script

  1. i am generating pdf from md file so i want to increase font size currently font size is 10
  2. i want to change page size also
  3. in pdf file every image bellow have image file name which i want to remove example after image file name like this image-GHT23.jpg

can you help in script where i can change those setting

thank you

AttributeError: 'Document' object has no attribute 'pageCount'

I'm trying to run a simple conversion and I get this error:

$ mdpdf Process-Book.md -o process-book.pdf

Traceback (most recent call last):
  File "/home/ben/.local/bin/mdpdf", line 8, in <module>
    sys.exit(cli())
  File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/ben/.local/lib/python3.10/site-packages/mdpdf/cli.py", line 110, in cli
    converter.convert(globlist)
  File "/home/ben/.local/lib/python3.10/site-packages/mdpdf/converter.py", line 18, in convert
    self.renderer.render(ast, inputFile)
  File "/home/ben/.local/lib/python3.10/site-packages/mdpdf/pdf_renderer.py", line 73, in render
    getattr(self, node.t)(node, entering)
  File "/home/ben/.local/lib/python3.10/site-packages/mdpdf/pdf_renderer.py", line 492, in document
    self.currentPage = self.doc.newPage(-1, width, height)
AttributeError: 'Document' object has no attribute 'newPage'. Did you mean: '_newPage'?
Exception ignored in: <function PdfRenderer.__del__ at 0x7ff1b30a9fc0>
Traceback (most recent call last):
  File "/home/ben/.local/lib/python3.10/site-packages/mdpdf/pdf_renderer.py", line 51, in __del__
    if self.doc.pageCount:
AttributeError: 'Document' object has no attribute 'pageCount'

I'm using Python 3.10.6

python interface docs?

It seems README only mentions cli usage, this should only be a complement not the main way of using it.

Relative links within the pdf

To support GitHub flavoured markdown (along with #1), it would be nice to allow for relative links within the document. As a temporary solution, currently I'm changing them in the md file to web URLs using regex, and then passing it to mdpdf. Using sed:

#!/bin/bash
sed -i -e -r "s/(#[^ ][^\)]*)\)/https:\/\/example.org\/dir\1\)/g" file.md &
mdpdf -o file.pdf file.md

which finds bits such as #example-relative-link) and replaces them with https://example.org/dir#example-relative-link)

PDF not generating when using images in MD

Hi Norman and thanks for this awesome tool!

I'm having problems with converting images im my MD-File. Baically as soon as i add my header image, the script fails without a clear error message and an empty PDF is generated. Since the package description states images are supported i was wondering if you could point me in the right direction. Do you have an idea how to fix it?

Python Script

import os
import mdpdf.cli as cli
from click.testing import CliRunner, Result

if os.path.exists("output.pdf"):
  os.remove("output.pdf")

runner: CliRunner = CliRunner()
result: Result = runner.invoke(cli.cli, ["-o", "output.pdf", "output.md"])

MD File (utf-8)

Page Title

![](https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png)

# Subtitle H1
Some Text lorem ipsum

Log file

    INFO: 2021-02-09 13:12:51,972:               log.py:   20: Logging to C:\Users\[...]\mdpdf.log
   DEBUG: 2021-02-09 13:12:51,972:               cli.py:   72: output.md
    INFO: 2021-02-09 13:12:51,972:         converter.py:   16: output.md
   DEBUG: 2021-02-09 13:12:51,972:      pdf_renderer.py:  446: printSegment: Page Title

Fancy badges to README

Deal with split link text

Link text, if broken, only shows up as the first segment. See pdf_renderer.py, line 176: filename=node.first_child.literal,

A function should grab all the child text literals.

some UTF-8 characters are omitted in generating

Hi, I am not sure if it is typeface problem (?) or somewhat deeper one, but some of Czech letters, to name "ฤ›ฤ" are not rendered in resulting PDF (all default settings).. all encodings seems to be right in the source document. Thanks for any clue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.