Spire.PDF如何添加简体和繁体汉字到PDF文件(C #,VB.NET)
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
http://www.adobe.com/support/downloads/thankyou.jsp?ftpID=5508&fileID=5521 详细步骤和代码片段: 步骤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");
运行该项目,我们将得到如下 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 编辑过 |
关键字查询
相关文章
正在查询... |