導航:首頁 > 文檔加密 > htmltopdfjs

htmltopdfjs

發布時間:2022-06-09 20:05:11

A. jspdf 將html代碼中的table導出為pdf文件怎麼弄

jsPDF 將html代碼中的table導出為pdf文件怎麼弄
有如下方法:
1、如果你電腦上安裝了office2007/2010,其中的word或EXCEL可以直接保存為PDF格式。
2、如果你電腦上安裝安裝的是office2003,可以下載安裝adobe acrobat,acrobat可以在載入生成PDF的插件。
3、利用任意一款PDF列印機(如pdffactory pro),然後將word文件「列印」成PDF文件。

B. JS實現的將html轉為pdf功能【基於瀏覽器端插件jsPDF】

本文實例講述了JS實現的將html轉為pdf功能。分享給大家供大家參考,具體如下:
<!DOCTYPE
html>
<html>
<head>
<title>jsPDF插件</title>
<meta
http-equiv="Content-Type"
content="text/html;
charset=utf-8">
<script
src="https://code.jquery.com/jquery-git.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script>
</head>
<body>
<p
class="pdf-wrapper"
="to-pdf">HTML
content...<h1>中文</h1>
中國,漢字,測試:合同
模版
中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國</br>中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國中國....................<br/>
中國,漢字,測試:合同
模版
...................<br/>
計費
介面
....................<br/>
<img
src='http://www.jb51.net/images/logo.gif'/>
</p>
<script
type="text/javascript">
var
pdf
=
new
jsPDF('p','pt','a4');
pdf.internal.scaleFactor
=
1;
var
options
=
{
pagesplit:
true
};
//$('.pdf-wrapper')
pdf.addHTML(document.body,options,function()
{
pdf.save('web1111.pdf');
});
</script>
</body>
</html>
運行效果:
更多關於JavaScript相關內容可查看本站專題:《JavaScript擴展技巧總結》、《JavaScript常用函數技巧匯總》、《javascript面向對象入門教程》、《JavaScript中json操作技巧總結》、《JavaScript切換特效與技巧總結》、《JavaScript查找演算法技巧總結》、《JavaScript錯誤與調試技巧總結》、《JavaScript數據結構與演算法技巧總結》、《JavaScript遍歷演算法與技巧總結》及《JavaScript數學運算用法總結》
希望本文所述對大家JavaScript程序設計有所幫助。
您可能感興趣的文章:jsPDF導出pdf示例jsPDF生成pdf後在網頁展示實例使用jspdf生成pdf報表phonegap教程使用jspdf庫在應用中生成pdf文件(pdf生成方法)JS導出PDF插件的方法(支持中文、圖片使用路徑)js插件方式打開pdf文件(瀏覽器pdf插件分享)用Javascript檢查Adobe
PDF插件是否安裝的實現代碼純js實現html轉pdf的簡單實例(推薦)基於Phantomjs生成PDF的實現方法JavaScript+Java實現HTML頁面轉為PDF文件保存的方法JavaScript代碼生成PDF文件的方法

C. 如何將html頁面轉成pdf

1安裝Adobe Acrobat後會默認在IE瀏覽器中添加PDF工具欄。
該工具可以方便的將網頁轉化成PDF文檔,或者添加入已有的PDF文檔,Adobe PDF Explorer工具欄則可以在IE的收藏夾界面內管理window內的HTML文檔與PDF文檔的轉化。


2、安裝單獨的pdf虛擬列印機(pdffactory、ultra pdf等),通過網頁的列印功能轉換。



3使用客戶端軟體HTML2PDF_Pilot。
HTML2PDF_Pilot的截面如上圖,很簡潔。
如果只是要完成最簡單的工作只需如箭頭所示,點擊上方的添加按鈕添加HTML文檔然後點擊轉換,稍等既可以完成一個HTML文檔的轉化工作。
兩種方法的比較
靈活性:
PDF工具欄的方式相比客戶端的方式要靈活許多。
在使用的過程中發現HTML2PDF_Pilot不能通過URL(網址)直接轉化PDF文檔,而工具欄只需在瀏覽的過程隨意使用。
功能:在功能的環節上,客戶端方式的HTML2PDF_Pilot就明顯要比PDF工具欄要強大許多
工具欄只提供了最基本的保存和添加入已有文檔的功能,而HTML2PDF_Pilot則提供了更為豐富的選項。
另外,如果需要批量轉化網頁文件的話,工具欄的方式也無法提供對應的功能。
其實還是有很多可以選擇的方式,比如把網頁轉化為WORD的文件格式然後通過WPS軟體來轉化文檔等,只要能靈活運用,html文件轉PDF是非常簡單的事情。

D. 如何利用js或php將html網頁轉為pdf

首先需要安裝wkhtmltopdf這個軟體 需要執行shell_exec函數的php文件和安裝的wkhtmltopdf.exe可執行文件在同一目錄下,不然php找不到這個執行文件

shell_exec("wkhtmltopdf.exe --page-size A4 --outline 網頁地址 pdf文件名");
--page-size 以A4紙的尺寸顯示pdf內容
--outline 顯示目錄(網頁中h1,h2來定)
網頁地址 需要轉成pdf的網頁地址
pdf文件名 生成pdf的文件名,可以使用絕對路徑

E. 如何將html文件轉成pdf 在線轉換

可以藉助電腦自帶的列印功能來將其保存為PDF格式的文件。使用電腦自帶的瀏覽器將該文件打開,然後點擊列印按鈕,在出現的選項中點擊另存為PDF格式文件即可。具體的操作方法如下:

1、在電腦上找到一個HTML文件,點擊右鍵,選擇需要的使用的瀏覽器打開。

F. java將html文件轉成pdf

核心代碼如下
package com.hmkcode;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.html2pdf.HtmlConverter;

public class App {
public static final String HTML = "<h1>Hello</h1>"
+ "<p>This was created using iText</p>"
+ "<a href='hmkcode.com'>hmkcode.com</a>";

public static void main( String[] args ) throws FileNotFoundException, IOException
{
HtmlConverter.convertToPdf(HTML, new FileOutputStream("string-to-pdf.pdf"));

System.out.println( "PDF Created!" );
}
}

G. 如何使用js將html轉換為PDF文件

你好,把html轉成PDF:
1.下載HTML2FPDF開源軟體,將其放在你的網站根目錄文件夾下,比如 /srv/httpd/htdocs/test/;
2.新建1.php文件,1.php中的代碼如下:
<?php
require('html2fpdf.php');
$pdf=new HTML2FPDF();
$pdf->AddPage();
// yourfile.html 你要轉化的HTML文件
$yourfile_html = "yourfile.html"
// yourfile.pdf 轉化成功後的pdf文件名
$yourfile_pdf = "yourfile.pdf"
$fp = fopen($yourfile_html,"r");
$strContent = fread($fp, filesize($yourfile_html));
fclose($fp);
$pdf->WriteHTML($strContent);
$pdf->Output($yourfile_pdf );
echo "PDF 文件成功生成!";
3.將你要轉化的yourfile.html文件也放在test目錄下,隨後在瀏覽器中訪問1.php文件就可以把html文件轉化成PDF文件了,

H. 把網頁轉成PDF[html to pdf]

使用 TuesPechkin (C#)類庫, 這個是將wkhtmltopdf(C++) 使用?C# 進行的封裝

使用方便 ,

publicpartialclassDefault:System.Web.UI.Page
{

privateIConverterconverter=
newStandardConverter(
newPdfToolset(
newWin64EmbeddedDeployment(
newTempFolderDeployment())));

protectedvoidPage_Load(objectsender,EventArgse)
{
stringhtmlPath=Server.MapPath("~/index.html");
stringhtmlContext=System.IO.File.ReadAllText(htmlPath);


vardoc=newHtmlToPdfDocument();
doc.Objects.Add(newObjectSettings(){HtmlText=htmlContext});
doc.Objects.Add(newObjectSettings{PageUrl="http://news.ifeng.com/history/special/yuanshikai/

});

varresult=converter.Convert(doc);
varpath=@"d: ext.pdf";

System.IO.File.WriteAllBytes(path,result);
}
}

源碼地址: https://github.com/tuespetre/TuesPechkin

I. 怎麼使用js,html5在瀏覽器直接打開pdf文檔

<html>
<body>
<div>
<button id="prev" onclick="goPrevious()">Previous</button>
<button id="next" onclick="goNext()">Next</button>

<span>Page: <span id="page_num"></span> / <span id="page_count"></span></span>
</div>

<div>
<canvas id="the-canvas" style="border:1px solid black"></canvas>
</div>

<!-- Use latest PDF.js build from Github -->
<script type="text/javascript" src="https://raw.github.com/mozilla/pdf.js/gh-pages/build/pdf.js"></script>

<script type="text/javascript">
//
// NOTE:
// Modifying the URL below to another server will likely *NOT* work. Because of browser
// security restrictions, we have to use a file server with special headers
// (CORS) - most servers don't support cross-origin browser requests.
//
var url = 'http://cdn.mozilla.net/pdfjs/tracemonkey.pdf';

//
// Disable workers to avoid yet another cross-origin issue (workers need the URL of
// the script to be loaded, and currently do not allow cross-origin scripts)
//
PDFJS.disableWorker = true;

var pdfDoc = null,
pageNum = 1,
scale = 0.8,
canvas = document.getElementById('the-canvas'),
ctx = canvas.getContext('2d');

//
// Get page info from document, resize canvas accordingly, and render page
//
function renderPage(num) {
// Using promise to fetch the page
pdfDoc.getPage(num).then(function(page) {
var viewport = page.getViewport(scale);
canvas.height = viewport.height;
canvas.width = viewport.width;

// Render PDF page into canvas context
var renderContext = {
canvasContext: ctx,
viewport: viewport
};
page.render(renderContext);
});

// Update page counters
document.getElementById('page_num').textContent = pageNum;
document.getElementById('page_count').textContent = pdfDoc.numPages;
}

//
// Go to previous page
//
function goPrevious() {
if (pageNum <= 1)
return;
pageNum--;
renderPage(pageNum);
}

//
// Go to next page
//
function goNext() {
if (pageNum >= pdfDoc.numPages)
return;
pageNum++;
renderPage(pageNum);
}

//
// Asynchronously download PDF as an ArrayBuffer
//
PDFJS.getDocument(url).then(function getPdfHelloWorld(_pdfDoc) {
pdfDoc = _pdfDoc;
renderPage(pageNum);
});
</script>
</body>
</html>

閱讀全文

與htmltopdfjs相關的資料

熱點內容
雲伺服器20性能 瀏覽:986
android強制系統橫屏 瀏覽:280
怎麼提前看未播出的電視劇app 瀏覽:666
cad轉pdf圖層 瀏覽:600
程序員接私活初級 瀏覽:433
全無油潤滑壓縮機 瀏覽:185
代碼加密常用方法 瀏覽:953
安卓手機如何解除已禁用 瀏覽:396
演算法的隨機性 瀏覽:486
高中解壓體育游戲 瀏覽:533
androidstudior丟失 瀏覽:345
命令行筆記 瀏覽:738
360目標文件夾訪問拒絕 瀏覽:519
3b編程加工指令 瀏覽:790
c8051f系列單片機選型手冊 瀏覽:773
南昌php程序員 瀏覽:513
bcs命令 瀏覽:447
如何在伺服器指向域名 瀏覽:417
車床編程可以做刀嗎 瀏覽:519
ln命令源碼 瀏覽:793