mandolyte / mdtopdf Goto Github PK
View Code? Open in Web Editor NEWMarkdown to PDF
License: MIT License
Markdown to PDF
License: MIT License
Is able create pdf with some special chars ? In gofpdf is possible to use https://godoc.org/github.com/jung-kurt/gofpdf#Fpdf.UnicodeTranslatorFromDescriptor
A table like this:
| | head2 | head3 |
| ----- | ----- | ----- |
| 1 | 2 | 3 |
causes a panic. As far as I know, it's legal markdown to have an empty heading cell, but not sure. I've never had a problem rendering it in any other way or converting it to PDF with pandoc, vscode extensions, etc.
Need to review gofpdf examples (if any) of creating tables. BlackFriday provides events for:
I have not yet tested the BF support for tables... so that should be the first action - make sure it really works.
how to setting to support chinese
I noticed that the tool creates an output trace file by default. This isn't ideal, since the trace contains the contents of the file and leaves it on the system.
Over on gopdf
, a solution is detailed:
#jung-kurt/gofpdf#157 (comment)
Note that github.com/jung-kurt/gofpdf is no longer being maintained, whereas github.com/go-pdf/fpdf is a drop-in replacement (I have done so on my local copy), that is being actively maintained and has performance enhancements.
@jessp01 - am I doing something wrong? Below is a transcript.
$ echo $GOBIN
/home/cecil/go/bin
$ go install github.com/mandolyte/mdtopdf/cmd@latest
$ mdtopdf -h
-bash: mdtopdf: command not found
$ ls $GOBIN
catcsv csvq gomodifytags impl reordercsv staticcheck
cmd dedupcsv goplay pivotcsv simplehttpserver transformcsv
comparecsv diffcsv gopls recursecsv sortcsv
convert dlv gotests recursedata splitcsv
$ cmd -h
Usage of cmd:
-author string
Author; used if -footer is passed
-font-file string
path to font file to use
-font-name string
Font name ID; e.g 'Helvetica-1251'
-help
Show usage message
-i string
Input filename or HTTP(s) URL; default is os.Stdin
-new-page-on-hr
Interpret HR as a new page; useful for presentations
-o string
Output PDF filename; required
-orientation string
[portrait | landscape] (default "portrait")
-page-size string
[A3 | A4 | A5] (default "A4")
-s string
Path to github.com/jessp01/gohighlight/syntax_files
-theme string
[light|dark] (default "light")
-title string
Presentation title
-unicode-encoding string
e.g 'cp1251'
-with-footer
Print doc footer (author title page number)
$ go install github.com/mandolyte/mdtopdf/cmd/mdtopdf@latest
go: github.com/mandolyte/mdtopdf/cmd/mdtopdf@latest: module github.com/mandolyte/mdtopdf@latest found (v1.5.0), but does not contain package github.com/mandolyte/mdtopdf/cmd/mdtopdf
$
Request to add HTMLSpan support for CSS step styling while created pdf file:
{number}
The list tests include HR markup and it isn't present in PDF output.
Need to review gofpdf package for support this ...
Problem
While working with this library I found an interesting case. If you create this markdown
### **Email:** issuer\_email
and when you try to convert, you will get an error:
➜ go run convert.go -i bad-markdown.md -o result.pdf
2023/01/20 16:37:07 pdf.OutputFileAndClose() error:Pdf.OutputFileAndClose() error on result.pdf:could not locate "helveticaBB" among embedded core font definition files
Additional info
My understanding, gotopdf missing some fonts for italic headers
In the Syntax Highlighting section, in the README.md
file, the link to gohighlight module is incorrect (https://github.com/mandolyte/mdtopdf/blob/master/github.com/jessp01/gohighlight
) which causes a 404.
Try converting a markdown document with a wide line in the code block:
This line is really quite long, long and even more long so that the text reaches the edge of the page. More and more and more.
It is expected that either the text is wrapped or the code block font size adjusted to accommodate the width of the line.
Instead, the text goes outside of the edge of the grey code block box and gets truncated.
This project is awesome, thank you! We gophers are just too awesome!
Would it ever make sense to do a "dark mode" feature or better yet have a pluggable palette of 3-4 colors. :D
Thanks again,
Drew
Hi author, I noticed that the latest version has reached v2.2.4, but when I go get it, I only get v1.5.3, is there any way to use the latest code
Hi @mandolyte ,
Since we're now on v2, some structure changes are required as, when one runs:
go install github.com/mandolyte/mdtopdf/cmd/md2pdf@latest
The received version is v1.5.3, not v2.2.1.
When trying to explicitly install v2.2.1:
$ go install github.com/mandolyte/mdtopdf/cmd/[email protected]
One would get this message:
go: github.com/mandolyte/mdtopdf/cmd/[email protected]: github.com/mandolyte/[email protected]: invalid version: module contains a go.mod file, so module path must match major version ("github.com/mandolyte/mdtopdf/v2")
Please see https://go.dev/blog/v2-go-modules
Happy to help with the restructure if you'd like.
Cheers,
The following markdown doc causes mdtopdf to panic:
Bob had $20 and but lost $10.
The panic is:
$ ./md2pdf -i /tmp/foo.md -o /tmp/out.md.pdf
panic: Unknown node type *ast.Math
goroutine 1 [running]:
github.com/mandolyte/mdtopdf.(*PdfRenderer).RenderNode(0x4000030800?, {0x0?, 0x40001a1b08?}, {0x45ac90?, 0x4000020aa0?}, 0xc0?)
/home/psanford/projects/thirdparty/mdtopdf/mdtopdf.go:454 +0x5e4
github.com/gomarkdown/markdown.Render.func1({0x45ac90?, 0x4000020aa0?}, 0x80?)
/home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/markdown.go:63 +0x50
github.com/gomarkdown/markdown/ast.NodeVisitorFunc.Visit(0x4000172840?, {0x45ac90?, 0x4000020aa0?}, 0x68?)
/home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:574 +0x38
github.com/gomarkdown/markdown/ast.Walk({0x45ac90, 0x4000020aa0}, {0x457420, 0x400007b3e0})
/home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:546 +0x58
github.com/gomarkdown/markdown/ast.Walk({0x45a430, 0x4000172840}, {0x457420, 0x400007b3e0})
/home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:557 +0x144
github.com/gomarkdown/markdown/ast.Walk({0x45a3e8, 0x40001727e0}, {0x457420, 0x400007b3e0})
/home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:557 +0x144
github.com/gomarkdown/markdown/ast.WalkFunc(...)
/home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:580
github.com/gomarkdown/markdown.Render({0x45a3e8, 0x40001727e0}, {0x458c20, 0x40001d0000})
/home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/markdown.go:62 +0xd0
github.com/mandolyte/mdtopdf.(*PdfRenderer).Run(0x40001d0000, {0x400003e200?, 0x242?, 0x40001a1d30?})
/home/psanford/projects/thirdparty/mdtopdf/mdtopdf.go:344 +0xb4
github.com/mandolyte/mdtopdf.(*PdfRenderer).Process(0x40001d0000, {0x400003e200?, 0x1e?, 0x200?})
/home/psanford/projects/thirdparty/mdtopdf/mdtopdf.go:318 +0x1b8
main.main()
/home/psanford/projects/thirdparty/mdtopdf/cmd/md2pdf/md2pdf.go:157 +0x9fc
Seems like the issue is that you have enabled the MathJax extension via parser.CommonExtensions
but you don't actually support those AST types.
I'm not trying to use MathJax so it would be nice if there was an option to override the markdown extensions enabled.
source
Влюбиться можно в красоту, но полюбить – лишь только душу!
result
ВлюбитÑOEÑ•Ñ• можно в краѕоту, но полюбитÑOE
– лишÑOE толÑOEко душу!
This is how it makes text with non latin characters. A required font is in the project folder and the font name is used in Styler options. How to fix it?
Sorry about the issue title. What I mean specifically is to support multiple markdown files to create one PDF.
This would permit a scenario of writing a book or article with multiple chapters or sections, where each chapter/section is in its own markdown file.
Use a markdown document that references an image that is either not local or isn't a png. An example is the README.md for this project, which has a godoc image link. Run mktopdf -i <the_markdown_doc> -o test.pdf.
Expected behaviour is that the output doesn't has the image, fine since not all markdown/HTML syntax is supported. A warning might be useful.
Instead, export completely fails with an error indicating that it cannot open the file path and dumps the http URL for the image link.
I noticed that the chinese pdf example you generated is garbled.
https://github.com/mandolyte/mdtopdf/blob/master/cmd/chinese.pdf
Can you support scaling of images in this project? They are coming out at 100% which can be disproportional for the page, in the context of an eBook or white-paper this would be particularly useful.
Since markdown has no real styling information and PDF has no real equivalent to after-the-fact styling like CSS it would be interesting if this tool had some theming concept. Out of the box, it would be great to support certain common styles of PDF documents. One example that comes to mind is an academic paper style (e.g. https://arxiv.org/pdf/1801.00013.pdf). Another could be a user guide style that resembles certain common manuals. I think it would also be useful to have some way to add more themes to the tool whether programmatically or declaratively.
The following remains to be done:
Hi. First off great project.
I seem to be having problems rendering tables. Columns with very long lines overlap the table's boundary.
### Some Title Goes Here
| Horizonal Header | Horizonal Value |
|-------------------------|----------------------------------------------------------------------|
| Period | 2023/1 |
| Project | Project #1 |
| Manager | Very long name goes here without wrapping with ellipses if possible. |
| Access ID | 1234567890 |
This is what I get, which is not what I need
Also is it possible to have horizontal header/value layout?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.