最好能有代码例子
Markdown2Pdf 使用这个类库
直接用markdown2document https://github.com/floppylab/markdown2document
这个我用过,简单易用。
你对于需求描述的不是很清楚。
ContentFactory contentFactory = ContentFactory.getInstance();
Document document = Document
.builder()
.markdownContents(Arrays.asList(
contentFactory.create("# Sample header \n sample content "),
contentFactory.create(new URL("https://floppylab.com/resources/markdown2document/sample.md"))
))
.styles(Arrays.asList(
contentFactory.create("body { font-family: sans-serif; color: #555; /* some comment*/ }"),
new Link("https://floppylab.com/resources/markdown2document/sample.css")
)).build();
PdfGenerator pdfGenerator = new PdfGenerator();
Output output = pdfGenerator.generate(document);
output.toFile("sample.pdf");
HtmlGenerator htmlGenerator = new HtmlGenerator();
output = htmlGenerator.generate(document);
output.toFile("sample.html");
将markdown文档转化为pdf格式
跟着步骤来
https://blog.csdn.net/weixin_67340472/article/details/126554960