admin管理员组文章数量:1279049
I'm having trouble learning anything from the documentation, how am I supposed to know which options exists in for example the .html method? It only says I can add an options object, but doesn't say what those options can be. What am I missing here?
I'm having trouble learning anything from the documentation, how am I supposed to know which options exists in for example the .html method? It only says I can add an options object, but doesn't say what those options can be. What am I missing here?
Share Improve this question asked Jan 17, 2019 at 8:48 Tommy StenbergTommy Stenberg 1151 silver badge8 bronze badges3 Answers
Reset to default 5As a possible alternative to find out, you can follow a source link for particular method (Documentation) to see the code. In this case it's:
https://rawgit./MrRio/jsPDF/master/docs/modules_html.js.html#line749
This is what options object can be:
options = options || {};
options.callback = options.callback || function () {};
options.html2canvas = options.html2canvas || {};
options.html2canvas.canvas = options.html2canvas.canvas ||
this.canvas;
options.jsPDF = options.jsPDF || this;
From the documentation you can see the code behind the .html module:
/**
* Generate a PDF from an HTML element or string using.
*
* @name html
* @function
* @param {Element|string} source The source element or HTML string.
* @param {Object=} options An object of optional settings.
* @description The Plugin needs html2canvas from niklasvh
*/
jsPDFAPI.html = function (src, options) {
'use strict';
options = options || {};
options.callback = options.callback || function () {};
options.html2canvas = options.html2canvas || {};
options.html2canvas.canvas = options.html2canvas.canvas || this.canvas;
options.jsPDF = options.jsPDF || this;
// Create a new worker with the given options.
var pdf = options.jsPDF;
var worker = new Worker(options);
if (!options.worker) {
// If worker is not set to true, perform the traditional 'simple' operation.
return worker.from(src).doCallback();
} else {
// Otherwise, return the worker for new Promise-based operation.
return worker;
}
return this;
};
jsPDF.html parameters:
Name Type Attributes Description
callback function The mandatory callback-function gets as first parameter the current jsPDF instance
margin number | Array. Page margins [top, right, bottom, left]. Default is 0.
autoPaging boolean | 'slice' | 'text' The auto paging mode.
false: Auto paging is disabled. true or 'slice': Will cut shapes or text chunks across page breaks. Will possibly slice text in half, making it difficult to read. 'text': Trys not to cut text in half across page breaks. Works best for documents consisting mostly of a single column of text. Default is true. filename string name of the file
image HTMLOptionImage image settings when converting HTML to image
html2canvas Html2CanvasOptions html2canvas options
fontFaces Array. A list of font-faces to match when resolving fonts. Fonts will be added to the PDF based on the specified URL. If omitted, the font match algorithm falls back to old algorithm.
jsPDF jsPDF jsPDF instance
x number x position on the PDF document in jsPDF units.
y number y position on the PDF document in jsPDF units.
width number The target width in the PDF document in jsPDF units. The rendered element will be scaled such that it fits into the specified width. Has no effect if either the html2canvas.scale is specified or the windowWidth option is NOT specified.
windowWidth number The window width in CSS pixels. In contrast to the html2canvas.windowWidth option, this option affects the actual container size while rendering and does NOT affect CSS media queries. This option only has an effect, if the width option is also specified.
本文标签: javascriptDocumentation for jsPDF that actually tells me the options I can setStack Overflow
版权声明:本文标题:javascript - Documentation for jsPDF that actually tells me the options I can set? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741292381a2370625.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论