Spire.PDF如何添加簡體和繁體漢字到PDF文件(C #,VB.NET)
當(dāng)前位置:點(diǎn)晴教程→知識(shí)管理交流
→『 技術(shù)文檔交流 』
http://www.adobe.com/support/downloads/thankyou.jsp?ftpID=5508&fileID=5521 詳細(xì)步驟和代碼片段: 步驟1 PdfDocument pdf = new PdfDocument(); PdfPageBase page = pdf.Pages.Add();
步驟2 PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial Unicode MS", 11f), true); PdfCjkStandardFont font1 = new PdfCjkStandardFont(PdfCjkFontFamily.MonotypeSungLight, 11f);
步驟3 page.Canvas.DrawString("中國", font, PdfBrushes.Red, 50, 50); page.Canvas.DrawString("中國", font1, PdfBrushes.Red, 50, 70);
步驟4 pdf.SaveToFile("result.pdf");
運(yùn)行該項(xiàng)目,我們將得到如下 Full codes: [C#] using Spire.Pdf; using Spire.Pdf.Graphics; using System.Drawing; namespace Add_Chinese_Characters_to_PDF { class Program { static void Main(string[] args) { PdfDocument pdf = new PdfDocument(); PdfPageBase page = pdf.Pages.Add(); PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial Unicode MS", 11f), true); PdfCjkStandardFont font1 = new PdfCjkStandardFont(PdfCjkFontFamily.MonotypeSungLight, 11f); page.Canvas.DrawString("中國", font, PdfBrushes.Red, 50, 50); page.Canvas.DrawString("中國", font1, PdfBrushes.Red, 50, 70); pdf.SaveToFile("result.pdf"); System.Diagnostics.Process.Start("result.pdf"); } } } [VB.NET] Imports Spire.Pdf Imports Spire.Pdf.Graphics Imports System.Drawing Namespace Add_Chinese_Characters_to_PDF Class Program Private Shared Sub Main(args As String()) Dim pdf As New PdfDocument() Dim page As PdfPageBase = pdf.Pages.Add() Dim font As New PdfTrueTypeFont(New Font("Arial Unicode MS", 11F), True) Dim font1 As New PdfCjkStandardFont(PdfCjkFontFamily.MonotypeSungLight, 11F) page.Canvas.DrawString("中國", font, PdfBrushes.Red, 50, 50) page.Canvas.DrawString("中國", font1, PdfBrushes.Red, 50, 70) pdf.SaveToFile("result.pdf") System.Diagnostics.Process.Start("result.pdf") End Sub End Class End Namespace
文章來源:這里 該文章在 2018/1/23 15:33:28 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |