私はjsPDFを使用してHTMLのコードをpdfに出力しています。jsPDFの問題、整列と要素、.text()
これは私の関数である:
function demoFromHTML() {
var pdf = new jsPDF('p', 'pt', 'A4');
// source can be HTML-formatted string, or a reference
// to an actual DOM element from which the text will be scraped.
//source = $('.conteudo_simulacao_final')[0];
pdf.setFontSize(40);
pdf.text(250, 220, 'World test!');
source = '<h1><img src="jsPDF/header.jpg" alt="header" style="width:595.28px; top:0; left: 0;" ></h1>';
source += '<div style="width:400px; >'
source += '<div style="float: left;"><img src="jsPDF/cartao_img.png" style="width:300px;" alt="cartao"></div>'
source += '<div style="float: left;"> TESTSASSAE</div>';
source += '</div>':
source += '<img src="jsPDF/footer.png" alt="footer" style="width:595.28; bot: 0;" ></h1>';
// we support special element handlers. Register them with jQuery-style
// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
// There is no support for any other type of selectors
// (class, of compound) at this time.
specialElementHandlers = {
// element with id of "bypass" - jQuery style selector
'#bypassme': function (element, renderer) {
// true = "handled elsewhere, bypass text extraction"
return true
}
};
margins = {
top: 0,
bot: 0,
left: 0,
width: 522
}
// all coords and widths are in jsPDF instance's declared units
// 'inches' in this case
pdf.fromHTML(
source, // HTML string or DOM elem ref.
margins.left, // x coord
margins.top, { // y coord
'width': margins.width, // max width of content on PDF
'elementHandlers': specialElementHandlers
},
function (dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
pdf.save('Test.pdf');
}, margins);
}
私はPDFファイルを作成することができ、私の問題は次のとおりです。 私は側で2つのdiv要素の側を印刷することはできません。私はjsPDFスタイルを読むことができない、これを回避する方法は?
私がこれを行うとき、私の他の問題は、 'pdf.text(250、220、' World test! ');'テキストは私のイメージの背後にあります。
お世話になりました。
私は明日キャンバスをしようとします。 テキストについて私は間違っていると思った。img:z-index:0 text:z-index:1 これを行うにはどうすればよいですか? THks –
ちょうどアップデート、キャンバスを試して、それは働いた;) それはすべてのCSSでページを印刷します。 ちょっとした問題がありました。私が印刷したアイテムのヘッダーは黒色で表示されました。賛美歌の中でそれが白いのはどこですか? –