Replies: 3 comments 5 replies
-
I already got it to work. However, now I need to add support for page breaks. I managed to achieve that with this code, but sadly this breaks links between different pages: markdown_parser = markdown.markdown
pdf_document = fitz.open()
content_parts = re.split(r'<pagebreak>', self.content)
for part in content_parts:
html_content = markdown_parser(part, extensions=list(self.plugins))
story = fitz.Story(html=html_content, user_css=self.custom_css, archive=".")
def rectfn(rect_num, filled):
rectangle = fitz.paper_rect("A4") + (36, 36, -36, -36)
return fitz.paper_rect("A4"), rectangle, None
document = story.write_with_links(rectfn)
pdf_document.insert_pdf(document)
pdf_document.save(file_path)
pdf_document.close() Notice that, because
Is there a way to mantain this page break functionality and links between pages working at the same time? |
Beta Was this translation helpful? Give feedback.
-
Oh, I am sure you will be successful. |
Beta Was this translation helpful? Give feedback.
-
I would love to see an easy way to make the At the moment, it looks like they stop writing altogether when that happens, as for HTML content with multiple page breaks ( I think I have a lot to learn before I'm ready to contribute to a project like this, but I'm looking forward to that moment! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm making a script to translate Markdown into HTML, and then pass the HTML + some CSS to a fitz Story, place that Story to a document, and save the document as a PDF.
This is the relevant part of the code:
This works perfectly fine, except that hyperlinks (both to the same document and to URLs on the internet) are not clickable in the final PDF.
I have tried Story.write_with_links() but I'm getting errors in the terminal that the destination of the link does not exist, plus I cannot manage to get the margins to be the same as with the looped approach in the code above.
I'm using the 'markdown' package to get the HTML from the MD file that I then pass to fitz, if that helps.
PyMuPDF==1.23.3
Beta Was this translation helpful? Give feedback.
All reactions