Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 影院成人区精品一区二区婷婷丽春院影视,www亚洲欲色成人久久精品,精品国精品国产自在久国产不卡

          整合營(yíng)銷服務(wù)商

          電腦端+手機(jī)端+微信端=數(shù)據(jù)同步管理

          免費(fèi)咨詢熱線:

          java將html轉(zhuǎn)為pdf


          html轉(zhuǎn)為pdf的組件有很多,但是還沒(méi)有哪一款能達(dá)到這個(gè)效果,其只要原因是wkhtmltopdf使用webkit網(wǎng)頁(yè)渲染引擎開(kāi)發(fā)的用來(lái)將 html轉(zhuǎn)成 pdf的工具,可以跟多種腳本語(yǔ)言進(jìn)行集成來(lái)轉(zhuǎn)換文檔。但是就使用簡(jiǎn)便性來(lái)說(shuō)還是itext等組件占據(jù)優(yōu)勢(shì),如果你要轉(zhuǎn)換格式有比較高的要求,那么wkhtmltopdf絕對(duì)是不二之選!

          下載路徑

          官網(wǎng)地址 wkhtmltopdf.org/

          github地址 github.com/wkhtmltopdf…

          使用方法

          1. windows直接使用:只要在windows命令行中輸入c:\wkhtmltopdf.exe my.oschina.net/papio/blog/… c:\blog.pdf 就可以把這篇文章轉(zhuǎn)成pdf,并保存到C盤根目錄。
          2. java調(diào)用:java中調(diào)用wkhtmltopdf的命令Runtime.getRuntime().exec("c:\wkhtmltopdf.exe my.oschina.net/papio/blog/… c:\blog.pdf")就可以實(shí)現(xiàn)轉(zhuǎn)換。

          java調(diào)用demo

          public class HtmlToPdfInterceptor extends Thread { private InputStream is; public HtmlToPdfInterceptor(InputStream is){ this.is = is; } public void run(){ try{ InputStreamReader isr = new InputStreamReader(is, "utf-8"); BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) { System.out.println(line.toString()); //輸出內(nèi)容 } }catch (IOException e){ e.printStackTrace(); } }}public class HtmlToPdf { //wkhtmltopdf在系統(tǒng)中的路徑 private static final String toPdfTool = "D:\wkhtmltopdf\bin\wkhtmltopdf.exe"; /** * html轉(zhuǎn)pdf * @param srcPath html路徑,可以是硬盤上的路徑,也可以是網(wǎng)絡(luò)路徑 * @param destPath pdf保存路徑 * @return 轉(zhuǎn)換成功返回true */ public static boolean convert(String srcPath, String destPath){ File file = new File(destPath); File parent = file.getParentFile(); //如果pdf保存路徑不存在,則創(chuàng)建路徑 if(!parent.exists()){ parent.mkdirs(); } StringBuilder cmd = new StringBuilder(); cmd.append(toPdfTool); cmd.append(" "); cmd.append(" --header-line");//頁(yè)眉下面的線 cmd.append(" --header-center 這里是頁(yè)眉這里是頁(yè)眉這里是頁(yè)眉這里是頁(yè)眉 ");//頁(yè)眉中間內(nèi)容 //cmd.append(" --margin-top 30mm ");//設(shè)置頁(yè)面上邊距 (default 10mm) cmd.append(" --header-spacing 10 ");//(設(shè)置頁(yè)眉和內(nèi)容的距離,默認(rèn)0) cmd.append(srcPath); cmd.append(" "); cmd.append(destPath); boolean result = true; try{ Process proc = Runtime.getRuntime().exec(cmd.toString()); HtmlToPdfInterceptor error = new HtmlToPdfInterceptor(proc.getErrorStream()); HtmlToPdfInterceptor output = new HtmlToPdfInterceptor(proc.getInputStream()); error.start(); output.start(); proc.waitFor(); }catch(Exception e){ result = false; e.printStackTrace(); } return result; } public static void main(String[] args) { HtmlToPdf.convert("https://my.oschina.net/papio/blog/835645", "d:/wkhtmltopdf.pdf"); }}復(fù)制代碼

          wkhtmltopdf 參數(shù)詳解

          wkhtmltopdf [OPTIONS]... <input file> [More input files] <output file>常規(guī)選項(xiàng) --allow <path> 允許加載從指定的文件夾中的文件或文件(可重復(fù)) --book* 設(shè)置一會(huì)打印一本書的時(shí)候,通常設(shè)置的選項(xiàng) --collate 打印多份副本時(shí)整理 --cookie <name> <value> 設(shè)置一個(gè)額外的cookie(可重復(fù)) --cookie-jar <path> 讀取和寫入的Cookie,并在提供的cookie jar文件 --copies <number> 復(fù)印打印成pdf文件數(shù)(默認(rèn)為1) --cover* <url> 使用HTML文件作為封面。它會(huì)帶頁(yè)眉和頁(yè)腳的TOC之前插入 --custom-header <name> <value> 設(shè)置一個(gè)附加的HTTP頭(可重復(fù)) --debug-javascript 顯示的javascript調(diào)試輸出 --default-header* 添加一個(gè)缺省的頭部,與頁(yè)面的左邊的名稱,頁(yè)面數(shù)到右邊,例如: --header-left '[webpage]' --header-right '[page]/[toPage]' --header-line --disable-external-links* 禁止生成鏈接到遠(yuǎn)程網(wǎng)頁(yè) --disable-internal-links* 禁止使用本地鏈接 --disable-javascript 禁止讓網(wǎng)頁(yè)執(zhí)行JavaScript --disable-pdf-compression* 禁止在PDF對(duì)象使用無(wú)損壓縮 --disable-smart-shrinking* 禁止使用WebKit的智能戰(zhàn)略收縮,使像素/ DPI比沒(méi)有不變 --disallow-local-file-access 禁止允許轉(zhuǎn)換的本地文件讀取其他本地文件,除非explecitily允許用 --allow --dpi <dpi> 顯式更改DPI(這對(duì)基于X11的系統(tǒng)沒(méi)有任何影響) --enable-plugins 啟用已安裝的插件(如Flash --encoding <encoding> 設(shè)置默認(rèn)的文字編碼 --extended-help 顯示更廣泛的幫助,詳細(xì)介紹了不常見(jiàn)的命令開(kāi)關(guān) --forms* 打開(kāi)HTML表單字段轉(zhuǎn)換為PDF表單域 --grayscale PDF格式將在灰階產(chǎn)生 --help Display help --htmldoc 輸出程序HTML幫助 --ignore-load-errors 忽略claimes加載過(guò)程中已經(jīng)遇到了一個(gè)錯(cuò)誤頁(yè)面 --lowquality 產(chǎn)生低品質(zhì)的PDF/ PS。有用縮小結(jié)果文檔的空間 --manpage 輸出程序手冊(cè)頁(yè) --margin-bottom <unitreal> 設(shè)置頁(yè)面下邊距 (default 10mm) --margin-left <unitreal> 將左邊頁(yè)邊距 (default 10mm) --margin-right <unitreal> 設(shè)置頁(yè)面右邊距 (default 10mm) --margin-top <unitreal> 設(shè)置頁(yè)面上邊距 (default 10mm) --minimum-font-size <int> 最小字體大小 (default 5) --no-background 不打印背景 --orientation <orientation> 設(shè)置方向?yàn)闄M向或縱向 --page-height <unitreal> 頁(yè)面高度 (default unit millimeter) --page-offset* <offset> 設(shè)置起始頁(yè)碼 (default 1) --page-size <size> 設(shè)置紙張大小: A4, Letter, etc. --page-width <unitreal> 頁(yè)面寬度 (default unit millimeter) --password <password> HTTP驗(yàn)證密碼 --post <name> <value> Add an additional post field (repeatable) --post-file <name> <path> Post an aditional file (repeatable) --print-media-type* 使用的打印介質(zhì)類型,而不是屏幕 --proxy <proxy> 使用代理 --quiet Be less verbose --read-args-from-stdin 讀取標(biāo)準(zhǔn)輸入的命令行參數(shù) --readme 輸出程序自述 --redirect-delay <msec> 等待幾毫秒為JS-重定向(default 200) --replace* <name> <value> 替換名稱,值的頁(yè)眉和頁(yè)腳(可重復(fù)) --stop-slow-scripts 停止運(yùn)行緩慢的JavaScripts --title <text> 生成的PDF文件的標(biāo)題(第一個(gè)文檔的標(biāo)題使用,如果沒(méi)有指定) --toc* 插入的內(nèi)容的表中的文件的開(kāi)頭 --use-xserver* 使用X服務(wù)器(一些插件和其他的東西沒(méi)有X11可能無(wú)法正常工作) --user-style-sheet <url> 指定用戶的樣式表,加載在每一頁(yè)中 --username <username> HTTP認(rèn)證的用戶名 --version 輸出版本信息退出 --zoom <float> 使用這個(gè)縮放因子 (default 1) 頁(yè)眉和頁(yè)腳選項(xiàng)--header-center* <text> (設(shè)置在中心位置的頁(yè)眉內(nèi)容) --header-font-name* <name> (default Arial) (設(shè)置頁(yè)眉的字體名稱)--header-font-size* <size> (設(shè)置頁(yè)眉的字體大小)--header-html* <url> (添加一個(gè)HTML頁(yè)眉,后面是網(wǎng)址)--header-left* <text> (左對(duì)齊的頁(yè)眉文本)--header-line* (顯示一條線在頁(yè)眉下)--header-right* <text> (右對(duì)齊頁(yè)眉文本)--header-spacing* <real> (設(shè)置頁(yè)眉和內(nèi)容的距離,默認(rèn)0)--footer-center* <text> (設(shè)置在中心位置的頁(yè)腳內(nèi)容) --footer-font-name* <name> (設(shè)置頁(yè)腳的字體名稱) --footer-font-size* <size> (設(shè)置頁(yè)腳的字體大小default 11)--footer-html* <url> (添加一個(gè)HTML頁(yè)腳,后面是網(wǎng)址)--footer-left* <text> (左對(duì)齊的頁(yè)腳文本)--footer-line* 顯示一條線在頁(yè)腳內(nèi)容上)--footer-right* <text> (右對(duì)齊頁(yè)腳文本)--footer-spacing* <real> (設(shè)置頁(yè)腳和內(nèi)容的距離)./wkhtmltopdf --footer-right '[page]/[topage]' http://www.baidu.com baidu.pdf./wkhtmltopdf --header-center '報(bào)表' --header-line --margin-top 2cm --header-line http://192.168.212.139/oma/ oma.pdf表內(nèi)容選項(xiàng)中 --toc-depth* <level> Set the depth of the toc (default 3) --toc-disable-back-links* Do not link from section header to toc --toc-disable-links* Do not link from toc to sections --toc-font-name* <name> Set the font used for the toc (default Arial) --toc-header-font-name* <name> The font of the toc header (if unset use --toc-font-name) --toc-header-font-size* <size> The font size of the toc header (default 15) --toc-header-text* <text> The header text of the toc (default Table Of Contents) --toc-l1-font-size* <size> Set the font size on level 1 of the toc (default 12) --toc-l1-indentation* <num> Set indentation on level 1 of the toc (default 0) --toc-l2-font-size* <size> Set the font size on level 2 of the toc (default 10) --toc-l2-indentation* <num> Set indentation on level 2 of the toc (default 20) --toc-l3-font-size* <size> Set the font size on level 3 of the toc (default 8) --toc-l3-indentation* <num> Set indentation on level 3 of the toc (default 40) --toc-l4-font-size* <size> Set the font size on level 4 of the toc (default 6) --toc-l4-indentation* <num> Set indentation on level 4 of the toc (default 60) --toc-l5-font-size* <size> Set the font size on level 5 of the toc (default 4) --toc-l5-indentation* <num> Set indentation on level 5 of the toc (default 80) --toc-l6-font-size* <size> Set the font size on level 6 of the toc (default 2) --toc-l6-indentation* <num> Set indentation on level 6 of the toc (default 100) --toc-l7-font-size* <size> Set the font size on level 7 of the toc (default 0) --toc-l7-indentation* <num> Set indentation on level 7 of the toc (default 120) --toc-no-dots* Do not use dots, in the toc輪廓選項(xiàng) --dump-outline <file> 轉(zhuǎn)儲(chǔ)目錄到一個(gè)文件 --outline 顯示目錄(文章中h1,h2來(lái)定) --outline-depth <level> 設(shè)置目錄的深度(默認(rèn)為4)頁(yè)腳和頁(yè)眉 * [page] 由當(dāng)前正在打印的頁(yè)的數(shù)目代替 * [frompage] 由要打印的第一頁(yè)的數(shù)量取代 * [topage] 由最后一頁(yè)要打印的數(shù)量取代 * [webpage] 通過(guò)正在打印的頁(yè)面的URL替換 * [section] 由當(dāng)前節(jié)的名稱替換 * [subsection] 由當(dāng)前小節(jié)的名稱替換 * [date] 由當(dāng)前日期系統(tǒng)的本地格式取代 * [time] 由當(dāng)前時(shí)間,系統(tǒng)的本地格式取代
          作者:曹元
          鏈接:https://juejin.im/post/6856547881873047559
          來(lái)源:掘金
          著作權(quán)歸作者所有。商業(yè)轉(zhuǎn)載請(qǐng)聯(lián)系作者獲得授權(quán),非商業(yè)轉(zhuǎn)載請(qǐng)注明出處。

          TML常用標(biāo)簽有:a標(biāo)簽、table標(biāo)簽、img標(biāo)簽、form標(biāo)簽和input標(biāo)簽。

          a標(biāo)簽

          作用

          1. 跳轉(zhuǎn)到外部網(wǎng)頁(yè)
          2. 跳轉(zhuǎn)到內(nèi)部錨點(diǎn)
          3. 跳轉(zhuǎn)到郵箱或電話等

          屬性

          (一)href

          href是hyper reference的縮寫,超鏈接的意思。

          用于指定鏈接目標(biāo)的ur地址,(必須屬性)當(dāng)為標(biāo)簽應(yīng)用href屬性時(shí),它就具有了超鏈接的功能;
          href=“#”表示這是一個(gè)空鏈接;
          如果href里面地址是—個(gè)文件或者壓縮包,會(huì)下載這個(gè)文件。

          <a href="https://google.com">超鏈接到google網(wǎng)站的主頁(yè)</a>
           <a href="https://google.com">超鏈接到google的主頁(yè)</a>
           <a href="//google.com">超鏈接到google的主頁(yè)</a>

          展現(xiàn)形式:

          點(diǎn)擊此鏈接,即可到達(dá)google的主頁(yè)

          a標(biāo)簽href的取值:

          1、上述代碼中的網(wǎng)址的取值(推薦使用第三行的代碼)

          <a href="//google.com">超鏈接到google的主頁(yè)</a>

          由于此方式能夠自動(dòng)補(bǔ)齊相關(guān)的網(wǎng)絡(luò)地址,前面兩種寫錯(cuò)就會(huì)報(bào)錯(cuò),所以推薦使用。

          2、路徑

          • /a/b/c 或者是a/b/c

          當(dāng)前路徑下的a里面的b,b里面的c

          • index.html 以及./index.html

          在當(dāng)前目錄下尋找index.html文件

          3、偽協(xié)議

          • javascript:代碼;(冒號(hào)與分號(hào)一定要寫)
          <a href="javascript:;">點(diǎn)擊后無(wú)任何點(diǎn)擊或刷新等動(dòng)作的反應(yīng)</a>
          • 錨點(diǎn)鏈接
          <a href="#要跳轉(zhuǎn)的元素的id"></a>

          點(diǎn)擊鏈接的時(shí)候,會(huì)跳轉(zhuǎn)到指定元素所在的位置。

          • mailto:郵箱
          <a href="mailto:abcdefg@163.com ">發(fā)郵件給我</a>
          • tel:手機(jī)號(hào)
          <a href="tel:12345678901">打電話給我</a>

          (二)targe

          用于指定鏈接頁(yè)面的打開(kāi)方式

          a的target取值

          1、內(nèi)置名字

          _blank 在空白頁(yè)打開(kāi)

          _self 在當(dāng)前頁(yè)面打開(kāi)

          _parent 在父級(jí)窗口打開(kāi)

          _top 在最頂級(jí)的窗口打開(kāi)

          <a href="//google.com" target="_blank">超鏈接到google網(wǎng)站的主頁(yè)在空白頁(yè)打開(kāi)</a>

          2、程序員的命名

          window:name(在xxx頁(yè)面打開(kāi))

          iframe的name(iframe現(xiàn)在已經(jīng)很少使用了,是指內(nèi)嵌窗口)


          (三)download

          下載頁(yè)面,但目前很少用,有的瀏覽器不支持,尤其是手機(jī)瀏覽器可能不支持。

          table標(biāo)簽

          1、table標(biāo)簽的語(yǔ)法:

          thead:表頭

          tbody:表的內(nèi)容,用于定義

          tfoot:表的腳部

          tr:table row,表格里的行

          th:表格的表頭部分,其中的文本內(nèi)容字體加粗居中顯示

          td:table data,表格數(shù)據(jù),用于定義表格中的單元格

          <!DOCTYPE html>
          <html lang="zh-CN">
            <head>
              <meta charset="UTF-8" />
              <meta name="viewport" content="width=device-width, initial-scale=1.0" />
              <meta http-equiv="X-UA-Compatible" content="ie=edge" />
              <title>Document</title>
            </head>
            <body>
              <table>
                <thead>
                  <tr>
                    <th></th>
                    <th>小紅</th>
                    <th>小黃</th>
                    <th>小藍(lán)</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <th>數(shù)學(xué)</th>
                    <td>90</td>
                    <td>60</td>
                    <td>80</td>
                  </tr>
                  <tr>
                    <th>語(yǔ)文</th>
                    <td>88</td>
                    <td>95</td>
                    <td>97</td>
                  </tr>
                  <tr>
                    <th>英語(yǔ)</th>
                    <td>88</td>
                    <td>95</td>
                    <td>97</td>
                  </tr>
                </tbody>
                <tfoot>
                  <tr>
                    <th>總分</th>
                    <td>266</td>
                    <td>250</td>
                    <td>274</td>
                  </tr>
                </tfoot>
              </table>
            </body>
          </html>
          



          第一行的th標(biāo)簽為空

          2、table的樣式

          table-layout:auto;自動(dòng)計(jì)算每一行的寬高

          table-layout:fixed;通過(guò)列表的寬度來(lái)決定平均寬度

          border-collapse:collapse; 合并邊框(默認(rèn)邊框與邊框之間不合并)

          border-spacing:0;邊框?yàn)?.(邊框與邊框之間的距離)。

          img標(biāo)簽(圖片)

          作用:發(fā)出get請(qǐng)求,展示一張圖片。

          <img src="1.JPG" alt="頭像" width="400" />

          當(dāng)前路徑下的1.jpg,確定寬度為400,只寫寬度高度會(huì)自適應(yīng)

          屬性

          alt:alternate的縮寫,替換的意思。替換文本,圖像不能顯示的文字。

          路徑錯(cuò)誤顯示alt內(nèi)容

          title:提示文本。鼠標(biāo)放到圖像上,顯示的文字。

          響應(yīng)

          max-width:100% 所有的圖片在手機(jī)上都自適應(yīng)寬度,寬度最大為100%。

          事件

          onload/onerror 監(jiān)聽(tīng)圖片是否加載成功,加載成功時(shí)用onload,不成功是用onerror事件。確保在onerror事件能夠補(bǔ)救。

          <body>
           <img id="xxx" src="dog.jpg" alt="一只小狗">
          <script>
          xxx.onload = function () {
          console.log("圖片加載成功");
           };
          xxx.onerror = function () {
          console.log("圖片加載失敗");
          xxx.src = "/404.jpg";
           };
          </script>
          </body>

          監(jiān)聽(tīng)成功時(shí),打印出成功

          監(jiān)聽(tīng)失敗時(shí),先打印出監(jiān)聽(tīng)失敗并且開(kāi)始執(zhí)行加載失敗是的挽救圖片。404.jpg文件執(zhí)行

          感想:

          • a標(biāo)簽的默認(rèn)樣式可以設(shè)置清除,href屬性可以有好多種取值,a標(biāo)簽的意義也不僅僅是跳轉(zhuǎn)到一個(gè)網(wǎng)址,還可以發(fā)郵件打電話。
          • 給img標(biāo)簽設(shè)置寬度和高度時(shí),不能讓圖片變形
          • table標(biāo)簽必須按照thead,tbody,tfoot的結(jié)構(gòu)去寫,先劃分好結(jié)構(gòu),再往里填充內(nèi)容,即使tfoot寫在前面,也會(huì)顯示在頁(yè)面的尾部

          本文為作者本人的原創(chuàng)文章,著作權(quán)歸作者本人和饑人谷所有,轉(zhuǎn)載務(wù)必注明來(lái)源。

          spose.Words無(wú)需Microsoft Word也可在任何平臺(tái)上滿足Word文檔的一切操作需求。本文將與大家分享如何將word和圖像轉(zhuǎn)換為PDF

          將HTML轉(zhuǎn)換為PDF

          要將HTML轉(zhuǎn)換為PDF,只需調(diào)用Document.Save方法并指定擴(kuò)展名為“.PDF”即可。如果要從外部源加載圖像和CSS等,可以使用IResourceSavingCallback。下面的代碼示例演示將HTML轉(zhuǎn)換為PDF并從外部源加載圖像。

          // For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
          public class ImageLoadingWithCredentialsHandler : IResourceLoadingCallback
          {
           public ImageLoadingWithCredentialsHandler()
           {
           mWebClient = new WebClient();
           }
           public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args)
           {
           if (args.ResourceType == ResourceType.Image)
           {
           Uri uri = new Uri(args.Uri);
           if (uri.Host == "www.aspose.com")
           mWebClient.Credentials = new NetworkCredential("User1", "akjdlsfkjs");
           else
           mWebClient.Credentials = new NetworkCredential("SomeOtherUserID", "wiurlnlvs");
           // Download the bytes from the location referenced by the URI.
           byte[] imageBytes = mWebClient.DownloadData(args.Uri);
           args.SetData(imageBytes);
           return ResourceLoadingAction.UserProvided;
           }
           else
           {
           return ResourceLoadingAction.Default;
           }
           }
           private WebClient mWebClient;
          }
          

          在Base64編碼中將字體導(dǎo)出為HTML

          使用Aspose.Words我們可以檢查字體資源是否應(yīng)該以base 64編碼嵌入到HTML中。默認(rèn)情況下,該值為false,字體將寫入單獨(dú)的文件。如果此選項(xiàng)設(shè)置為true,則字體將嵌入到Base64編碼的文檔CSS中。 該屬性僅影響HTML格式,不會(huì)影響EPUB和MHTML。這是HtmlSaveOptions.ExportFontResources選項(xiàng)的擴(kuò)展,ExportFontsAsBase64僅在此屬性設(shè)置為true時(shí)才有效。下面的示例演示如何使用Base64編碼將字體導(dǎo)出為HTML。

          // For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
          // The path to the documents directory.
          string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
          string fileName = "Document.doc";
          Document doc = new Document(dataDir + fileName);
          HtmlSaveOptions saveOptions = new HtmlSaveOptions();
          saveOptions.ExportFontResources = true;
          saveOptions.ExportFontsAsBase64 = true; 
          dataDir = dataDir + "ExportFontsAsBase64_out.html";
          doc.Save(dataDir, saveOptions);
          

          使用HtmlSaveOptions屬性

          使用Aspose.Words,我們可以指定一個(gè)文件夾,在將文檔導(dǎo)出為HTML時(shí),可以保存圖像,字體和外部CSS等所有資源。默認(rèn)值為空字符串。ResourceFolder是指定應(yīng)寫入所有資源的文件夾的最簡(jiǎn)單方法。我們可以使用FontsFolder等單獨(dú)的屬性將字體保存到指定的文件夾,使用ImagesFolder將圖像保存到指定的文件夾。

          使用ResourceFolderAlias屬性,我們還可以指定用于構(gòu)造寫入HTML文檔的所有資源的URI的文件夾的名稱,這是指定應(yīng)如何構(gòu)造所有資源文件的URI的最簡(jiǎn)單方法。可以通過(guò)ImagesFolderAlias和FontsFolderAliasproperties分別為圖像和字體指定相同的信息。 但是,CSS沒(méi)有單獨(dú)的屬性。 FontsFolder,F(xiàn)ontsFolderAlias,ImagesFolder,ImagesFolderAlias和CssStyleSheetFileName屬性的行為不會(huì)更改。請(qǐng)注意,CssStyleSheetFileName屬性用于指定文件夾名稱和文件名。

          指定相對(duì)路徑時(shí),F(xiàn)ontsFolder和ImagesFolder相對(duì)于代碼程序集所在的文件夾,ResourceFolder和CssStyleSheetFileName相對(duì)于HTML文檔所在的輸出文件夾。在下面的示例中,ResourceFolder指定此路徑相對(duì)于輸出文件夾的相對(duì)路徑,其中保存HTML文檔,http://example.com/resources 別名用于構(gòu)造所有資源的URL。

          // For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
          // The path to the documents directory.
          string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
          string fileName = "Document.doc";
          Document doc = new Document(dataDir + fileName);
          HtmlSaveOptions saveOptions = new HtmlSaveOptions();
          saveOptions.CssStyleSheetType = CssStyleSheetType.External;
          saveOptions.ExportFontResources = true;
          saveOptions.ResourceFolder = dataDir + @"\Resources";
          saveOptions.ResourceFolderAlias = "http://example.com/resources";
          doc.Save(dataDir + "ExportResourcesUsingHtmlSaveOptions.html", saveOptions);
          

          如何將文檔轉(zhuǎn)換為MHTML和電子郵件

          Aspose.Words可以以MHTML(Web Archive)格式保存任何文檔。這使得Aspose.Words和Aspose.Email一起使用可以生成和發(fā)送內(nèi)容豐富的電子郵件。例如,你可以將預(yù)定義的DOC,OOXML或RTF文檔加載到Aspose.Words中,用數(shù)據(jù)填充之后另存為MHTML,然后使用Aspose.Email發(fā)送電子郵件。 下面的代碼示例演示了如何使用Aspose.Email將Aspose.Words中的文檔保存為MHTML和電子郵件。

          // For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
          // The path to the documents directory.
          string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
          // Load the document into Aspose.Words.
          Document doc = new Document(dataDir + "Test File (docx).docx");
          // Save into a memory stream in MHTML format.
          Stream stream = new MemoryStream();
          doc.Save(stream, SaveFormat.Mhtml);
          // Rewind the stream to the beginning so Aspose.Email can read it.
          stream.Position = 0;
          // Create an Aspose.Network MIME email message from the stream.
          MailMessage message = MailMessage.Load(stream, new MhtmlLoadOptions());
          message.From = "your_from@email.com";
          message.To = "your_to@email.com";
          message.Subject = "Aspose.Words + Aspose.Email MHTML Test Message";
          // Send the message using Aspose.Email
          SmtpClient client = new SmtpClient();
          client.Host = "your_smtp.com";
          client.Send(message);
          

          點(diǎn)擊“了解更多”下載產(chǎn)品最新版

          ↓↓↓


          主站蜘蛛池模板: 亚洲乱色熟女一区二区三区蜜臀 | 亚洲狠狠狠一区二区三区| 麻豆国产在线不卡一区二区| 91麻豆精品国产自产在线观看一区| 国模极品一区二区三区| 中文字幕在线观看一区| 亚洲AV成人一区二区三区观看| 久久久91精品国产一区二区三区 | 亚洲国产精品自在线一区二区| 国产三级一区二区三区| 在线免费观看一区二区三区| 日本片免费观看一区二区| 国产午夜福利精品一区二区三区| 无码人妻精品一区二| 国产成人一区在线不卡| 爱爱帝国亚洲一区二区三区| 乱码人妻一区二区三区| 日韩免费一区二区三区在线播放| 一区二区三区亚洲| 亚洲一区二区三区高清视频| 亚洲AV无码一区二区二三区软件| 亚洲一区二区三区在线观看精品中文 | 狠狠爱无码一区二区三区| 色婷婷亚洲一区二区三区 | 亚洲成AV人片一区二区密柚 | 爱爱帝国亚洲一区二区三区| 亚洲AV无码一区二区乱子仑 | 成人精品一区二区户外勾搭野战| 日本免费一区二区三区| 精品无码一区二区三区亚洲桃色| 秋霞午夜一区二区| 国产主播福利一区二区| 日本精品无码一区二区三区久久久| 在线视频一区二区三区四区| 天堂一区二区三区在线观看| 手机福利视频一区二区| 天天看高清无码一区二区三区 | 一区二区三区无码高清视频| 欧洲精品码一区二区三区免费看| 国产一区二区三区在线免费| 国模无码一区二区三区不卡|