pandoc高级用法
记录分享pandoc,高级用法
一、摘要
- 撰写: 半条虫(466814195)
- BLOG: https://blog.csdn.net/rimke
二、生成PDF
1. 水印
pandoc \
--pdf-engine=weasyprint \
--css=./markdown.css \
--css=./markdown-watermark.css \
--filter=pandoc-mermaid \
f.md -o f.pdf
markdown-watermark.css
@page {
margin: 1.0cm; /* 可选:设置页边距 */
margin-top: 2.0cm;
/* 页眉 */
@top-left {
content: "";
background-image: url("./logo-24x24.png");
width: 30px;
height: 68px;
background-size: 24px 24px;
background-repeat: no-repeat;
background-position: center left;
vertical-align: middle;
}
@top-center {
content: "39DOO科技";
font-family: "SimHei", "Microsoft YaHei", sans-serif;
font-size: 16px;
font-weight: bold;
color: #003366;
text-shadow: 0 1px 1px rgba(0,0,0,0.1);
letter-spacing: 0.8px;
vertical-align: middle;
}
@top-right {
content: "机密";
font-family: "SimSun", serif;
font-size: 12px;
color: #c00;
font-weight: bold;
vertical-align: middle;
padding-top: 6px;
}
/* 页脚 */
@bottom-left {}
@bottom-center {
}
@bottom-right {
content: counter(page) " / " counter(pages);
font-size: 10pt;
color: #666;
padding-top: 5px;
}
}
body {
/* 1. 定义背景图:使用 SVG Data URI */
/* 这里的 SVG 包含了一个旋转的文本,颜色为半透明黑色 */
background-image: url("data:image/svg+xml,%3Csvg width='410' height='150' xmlns='http://www.w3.org/2000/svg'%3E%3Ctext x='50%25' y='50%25' font-size='14' fill='rgba(0,0,0,0.08)' text-anchor='middle' transform='rotate(-25 245 50)'%3ESHENZHEN 39DOO CO., LTD. %3C/text%3E%3C/svg%3E");
/* 2. 关键属性:重复平铺 */
background-repeat: repeat;
/* 3. 确保背景图覆盖整个视口,即使内容很少 */
min-height: 100vh;
/* 4. 确保背景图固定在窗口,不随内容滚动(可选) */
background-attachment: fixed;
}
2. 丛向/横向
pandoc \
--pdf-engine=weasyprint \
--css=./markdown.css \
--css=./markdown-landscape.css \
--filter=pandoc-mermaid \
f.md -o f.pdf
markdown-landscape.css
@page {
size: A4 landscape;
}
3. 页码
@page {
/* 页脚 */
@bottom-left {}
@bottom-center {}
@bottom-right {
content: counter(page) " / " counter(pages);
font-size: 10pt;
color: #666;
padding-top: 5px;
}
}

551

被折叠的 条评论
为什么被折叠?



