Wkhtmltopdf vừa với trang
Có cách nào xem hình nền trong pdf do QWeb/Report tạo không? wkhtmltopdf và wkhtmltoimage là các công cụ dòng lệnh mã nguồn mở (LGPLv3) để kết xuất HTML thành PDF và các định dạng hình ảnh khác nhau bằng cách sử dụng công cụ kết xuất Qt WebKit. Chúng chạy hoàn toàn "không đầu" và không yêu cầu dịch vụ hiển thị hoặc hiển thị. wkhtmltopdf cũng được sử dụng trong các công cụ tạo PDF phổ biến như Snappy của PHP, pdf độc ác của Ruby và pdfkit Trong bài viết trước, chúng ta đã biết cách sử dụng wkhtmltopdf. Nhưng khi làm mình gặp phải vấn đề rất muốn chia sẻ với các bạn Mỗi vấn đề có một giải phápTrước tiên, bạn phải hiểu wkhtmltopdf làm gì. hiển thị html bằng 'trình duyệt của chính nó'. Vì vậy, khi một cái gì đó dường như không hoạt động, hãy thử
Bây giờ, chúng tôi có thể cải thiện kết xuất pdf của mình Cách xử lý kích thước của pdfĐầu tiên, chúng ta cần xác định hai chức năng mới này Và đưa hai giá trị mới này vào back-end của chúng ta Ở phía sau, bạn chỉ cần đặt các tùy chọn sau
Bằng cách này, bạn có chính xác những gì bạn nhìn thấy trên bộ điều hướng của mình Nota Bene. các giá trị wkhtmltopdf [GLOBAL OPTION].. [OBJECT]..4 và wkhtmltopdf [GLOBAL OPTION].. [OBJECT]..5 được tính bằng mm, vì vậy tôi nghĩ mình nên có 0. 264583333 tỷ lệ từ pixel đến mm. Nhưng khi tôi thử, tôi thấy 0. 271 như một xấp xỉ tốt hơn. (Điều này hữu ích cho dự án của tôi vì SVG có kích thước nội tuyến) Cách hiển thị hình ảnh chính xácBạn cần biết một điều. wkhtmltopdf cần đường dẫn tuyệt đối cho hình ảnh. Trong dự án của tôi, tôi đã sử dụng bản sửa lỗi này Nhưng bạn phải thay đổi regex wkhtmltopdf [GLOBAL OPTION].. [OBJECT]..8 và đường dẫn wkhtmltopdf [GLOBAL OPTION].. [OBJECT]..9 theo nơi lưu trữ hình ảnh Cung cấp bởi. wkhtmltopdf 0. 12. 5-1build1_AMD64 Tênwkhtmltopdf - html to pdf converter Tóm tắtwkhtmltopdf [GLOBAL OPTION].. [OBJECT].. đối tượng tài liệuwkhtmltopdf is able to put several objects into the output file, an object is either a single webpage, a cover webpage or a table of contents. The objects are put into the output document in the order they are specified on the command line, options can be specified on a per object basis or in the global options area. Options from the Global Options section can only be placed in the global options area A page objects puts the content of a single webpage into the output document. (page)? [PAGE OPTION]... Options for the page object can be placed in the global options and the page options areas. The applicable options can be found in the Page Options and Headers And Footer Options sections. A cover objects puts the content of a single webpage into the output document, the page does not appear in the table of contents, and does not have headers and footers. cover [PAGE OPTION]... All options that can be specified for a page object can also be specified for a cover. A table of contents object inserts a table of contents into the output document. toc [TOC OPTION]... All options that can be specified for a page object can also be specified for a toc, further more the options from the TOC Options section can also be applied. The table of contents is generated via XSLT which means that it can be styled to look however you want it to look. To get an idea of how to do this you can dump the default xslt document by supplying the --dump-default-toc-xsl, and the outline it works on by supplying --dump-outline, see the Outline Options section. Sự miêu tảConverts one or more HTML pages into a PDF document, not using wkhtmltopdf patched qt. Tùy chọn toàn cầu--collate Collate when printing multiple copies --no-collate Do not collate when printing multiple copies --cookie-jar Read and write cookies from and to the supplied cookie jar file --copies Number of copies to print into the pdf file -d, --dpi Change the dpi explicitly (this has no effect on X11 based systems) -H, --extended-help Display more extensive help, detailing less common command switches -g, --grayscale PDF will be generated in grayscale -h, --help Display help --htmldoc Output program html help --license Output license information and exit --log-level Set log level to: none, error, warn or info -l, --lowquality Generates lower quality pdf/ps. Useful to shrink the result document space --manpage Output program man page -B, --margin-bottom Set the page bottom margin -L, --margin-left Set the page left margin -R, --margin-right Set the page right margin -T, --margin-top Set the page top margin -O, --orientation Set orientation to Landscape or Portrait --page-height Page height -s, --page-size Set paper size to: A4, Letter, etc. --page-width Page width -q, --quiet Be less verbose, maintained for backwards compatibility; Same as using --log-level none --read-args-from-stdin Read command line arguments from stdin --readme Output program readme --title The title of the generated pdf file (The title of the first document is used if not specified) -V, --version Output version information and exit Tùy chọn trang--allow Allow the file or files from the specified folder to be loaded (repeatable) --background Do print background --no-background Do not print background --bypass-proxy-for Bypass proxy for host (repeatable) --cache-dir Web cache directory --checkbox-checked-svg Use this SVG file when rendering checked checkboxes --checkbox-svg Use this SVG file when rendering unchecked checkboxes --cookie Set an additional cookie (repeatable), value should be url encoded. --custom-header Set an additional HTTP header (repeatable) --custom-header-propagation Add HTTP headers specified by --custom-header for each resource request. --no-custom-header-propagation Do not add HTTP headers specified by --custom-header for each resource request. --debug-javascript Show javascript debugging output --no-debug-javascript Do not show javascript debugging output --encoding Set the default text encoding, for input --images Do load or print images --no-images Do not load or print images -n, --disable-javascript Do not allow web pages to run javascript --enable-javascript Do allow web pages to run javascript --javascript-delay Wait some milliseconds for javascript finish --load-error-handling Specify how to handle pages that fail to load: abort, ignore or skip --load-media-error-handling Specify how to handle media files that fail to load: abort, ignore or skip --disable-local-file-access Do not allowed conversion of a local file to read in other local files, unless explicitly allowed with --allow --enable-local-file-access Allowed conversion of a local file to read in other local files. --minimum-font-size Minimum font size --page-offset Set the starting page number --password HTTP Authentication password --disable-plugins Disable installed plugins --enable-plugins Enable installed plugins (plugins will likely not work) --post Add an additional post field (repeatable) --post-file Post an additional file (repeatable) -p, --proxy Use a proxy --proxy-hostname-lookup Use the proxy for resolving hostnames --radiobutton-checked-svg Use this SVG file when rendering checked radiobuttons --radiobutton-svg Use this SVG file when rendering unchecked radiobuttons --run-script Run this additional javascript after the page is done loading (repeatable) --ssl-crt-path Path to the ssl client cert public key in OpenSSL PEM format, optionally followed by intermediate ca and trusted certs --ssl-key-password Password to ssl client cert private key --ssl-key-path Path to ssl client cert private key in OpenSSL PEM format --stop-slow-scripts Stop slow running javascripts --no-stop-slow-scripts Do not Stop slow running javascripts --user-style-sheet Specify a user style sheet, to load with every page --username HTTP Authentication username --window-status Wait until window.status is equal to this string before rendering page --zoom Use this zoom factor Chỉ định ProxyBy default proxy information will be read from the environment variables: proxy, all_proxy and http_proxy, proxy options can also by specified with the -p switch := "http://" | "socks5://" := (":" )? "@" := "None" | ? ? (":" )? Here are some examples (In case you are unfamiliar with the BNF): http://user:password@myproxyserver:8080 socks5://myproxyserver None Giảm chức năngThis version of wkhtmltopdf has been compiled against a version of QT without the wkhtmltopdf patches. Therefore some features are missing, if you need these features please use the static version. Currently the list of features only supported with patch QT includes: * Printing more than one HTML document into a PDF file. * Running without an X11 server. * Adding a document outline to the PDF file. * Adding headers and footers to the PDF file. * Generating a table of contents. * Adding links in the generated PDF file. * Printing using the screen media-type. * Disabling the smart shrink feature of WebKit. Kích thước trang________số 8Đọc đối số từ stdinIf you need to convert a lot of pages in a batch, and you feel that wkhtmltopdf is a bit too slow to start up, then you should try --read-args-from-stdin, When --read-args-from-stdin each line of input sent to wkhtmltopdf on stdin will act as a separate invocation of wkhtmltopdf, with the arguments specified on the given line combined with the arguments given to wkhtmltopdf For example one could do the following: echo "http://qt-project.org/doc/qt-4.8/qapplication.html qapplication.pdf" >> cmds echo "cover google.com http://en.wikipedia.org/wiki/Qt_(software) qt.pdf" >> cmds wkhtmltopdf --read-args-from-stdin --book < cmds Ngắt trangwkhtmltopdf [GLOBAL OPTION].. [OBJECT]..0 Tiếp xúcwkhtmltopdf [GLOBAL OPTION].. [OBJECT]..1 tác giảwkhtmltopdf [GLOBAL OPTION].. [OBJECT]..2 |