JSPDFを使用して、罫線をPDFとして含む段落<p>
を保存し、書式設定を組み込み、要素をページの中央に保持することはできますか?パラグラフをPDFとして動的に保存しますか?
次のコードでは、テキストをtextarea
に貼り付けると段落が生成されます。このFiddleに示されているように、テーブルとしてPDFとして保存することは可能です。
ただし、動的な段落と枠線を動的にPDFとして保存することはできますか?
更新されたフィドルを提供できる場合は、私はまだコーディングに新しいので、非常に感謝しています。
ありがとうございました!
HTML:
<div align="center">
<h4 align="center">
<u>Paste text in the field below to divide text into paragraphs.</u>
</h4>
<textarea placeholder="Type text here, then press the button below." cols="50" id="textarea1" rows="10">
</textarea>
<br><br>
<button id="Go">Divide Text into Paragraphs!</button>
</div>
<hr> <h2 align="center">Dynamic Paragraphs will appear below: <br>[Paragraphs below for saving as PDF]</h2> <div> <div align="center" id="text_land" style="font-family: monospace"> </div></div>
はJQuery:
$(function(){$("#Go").on("click",function(){for(var t=$("textarea").val(),e=300;t.length;){for(;t.length>e&&" "!==t.charAt(e);)e++;$("#text_land").append("<br></br><p>"+t.substring(0,e)+"</p><br></br>"),t=t.substring(e),e=300,$("p").attr("contenteditable","true"),$("p").addClass("text")}})}),$("select").on("change",function(){var t=$("#text_land p"),e=this.dataset.property;t.css(e,this.value)}).prop("selectedIndex",0),end;
CSS:
@media print{p{page-break-inside:avoid}}p{position:relative}@media print{.no-print,.no-print *{display:none !important}}p{border-style:solid}p{color:#000}p{display:block;text-align:justify;border-width:5px;font-size:19px}p{overflow:hidden;height:300px;width:460px;word-wrap:break-word}
ウィンドウのサイズを変更するか、ズームしかし、実際の段落要素の変更がPDFに保存するときに指定したサイズよりもサイズ。また、PDF文書では、段落が余白を介して次のページに移動するのではなく、段落を2つの別々のページに分割しています。したがって、これらの問題を修正することは可能ですか? – Dave
@Dave 'pagesplit:true'を改ページしないよう' pagesplit:false'に変更し、 'p'に固定幅があるのでウィンドウの幅が何であるかは関係ありません。 'p'をウィンドウの後ろに置くには' p'のルールを 'width:80%; min-width:460px;' – LGSon
のようにパーセントに変更してください。PDFに保存するとテキストがぼやけているようです。これはhtml2canvasの問題であると思われるため、解決できる問題ですか? – Dave