相关疑难解决方法(0)

pdfkit生成小规模的pdf

我正在使用pdfkit从html字符串生成pdf,由我的Django视图呈现.

出于某种原因,输出pdf很小.我的pdfkit选项字典是 -

options = {
            'quiet': '',
            'page-size': 'A4',
            'margin-top': '0.75in',
            'margin-right': '0.75in',
            'margin-bottom': '0.75in',
            'margin-left': '0.75in',
            'disable-smart-shrinking': ''
        }
Run Code Online (Sandbox Code Playgroud)

输出文件在这里

Html代码是 -

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="pdfkit-orientation" content="Portrait"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Dribble</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
    <!-- Google Font -->
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,700,800" rel="stylesheet"> …
Run Code Online (Sandbox Code Playgroud)

html django pdfkit wkhtmltopdf

7
推荐指数
1
解决办法
4242
查看次数

Rotativa Pdf 生成不考虑 HTML 字符间距

我正在使用 Rotativa 将 MVC HTML 转换为 Pdf。在 HTML 中,一切看起来都很好,但在 Pdf 格式中,字符间距的格式不太好,因为它太小了。这大大降低了文档的可读性。

下图中是 HTML 中的字符串:

和

这是使用 Rotativa 生成的相同字符串:

在此输入图像描述

我尝试增加 css 的字符间距,但是当我将其更改为 时1px,在 HTML 方面,一切看起来都更好,但在 Pdf 中,所有字符串都混乱了,并且获得的间距大于10px沿 div 分割并与每个元素重叠的间距其他。

我发现这可能是 Rotativa 问题之一,就像这个问题一样,这对我没有多大帮助,因为它仅针对 Debian Sid 操作系统得到解决,而且我使用的是 Windows,并且我已经使用 Nuget 安装了 Rotativa 1.64。

有谁知道使用 Rotativa 修复字母间距的方法吗?

html css pdf asp.net-mvc rotativa

5
推荐指数
1
解决办法
4044
查看次数

标签 统计

html ×2

asp.net-mvc ×1

css ×1

django ×1

pdf ×1

pdfkit ×1

rotativa ×1

wkhtmltopdf ×1