Troubleshooting CMYK and International Language PDFs

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronPDF 支持 HTML 转 PDF 时的所有国际语言,这些语言由 Unicode 支持,包括混合语言文档。

需要考虑的两个要点是字体输入编码,在此常见问题解答页面上有更详细的说明:https://ironpdf.com/how-to/utf-8/

必须在服务器上安装支持您的字符集的字体。

您可能需要指定文档的输入编码以正确呈现。

您可以通过以下方式实现这一点:

  1. 添加 HTML “Meta Charset” 标签

    这种方法涉及在 HTML <head> 部分中包含一个 <meta> 标签以定义字符集。 这确保了您的 HTML 文档使用正确的字符。

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Your Document Title</title>
    </head>
    <body>
        <p>Your document content goes here...</p>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Your Document Title</title>
    </head>
    <body>
        <p>Your document content goes here...</p>
    </body>
    </html>
    HTML

    <meta charset="UTF-8"> 标签指定了 UTF-8 字符编码,它能够处理任何 Unicode 字符。

  2. 设置 IronPDF HTML 转 PDF 转换器的 inputEncoding 属性

    您可以设置 IronPDF 转换器的 inputEncoding 属性,该属性允许您在转换过程中指定字符编码。

    您可以在您的 C# 代码中如下进行设置:

    using IronPdf;
    
    class Program
    {
        static void Main()
        {
            // Instantiate a renderer
            var Renderer = new HtmlToPdf
            {
                // Set the input encoding to UTF-8
                RenderOptions = new ChromePdfRendererOptions
                {
                    InputEncoding = "UTF-8"
                }
            };
    
            // Convert HTML to PDF
            var PDF = Renderer.RenderHtmlAsPdf("<p>Sample content with UTF-8 encoding</p>");
    
            // Save the PDF to disk
            PDF.SaveAs("output.pdf");
        }
    }
    using IronPdf;
    
    class Program
    {
        static void Main()
        {
            // Instantiate a renderer
            var Renderer = new HtmlToPdf
            {
                // Set the input encoding to UTF-8
                RenderOptions = new ChromePdfRendererOptions
                {
                    InputEncoding = "UTF-8"
                }
            };
    
            // Convert HTML to PDF
            var PDF = Renderer.RenderHtmlAsPdf("<p>Sample content with UTF-8 encoding</p>");
    
            // Save the PDF to disk
            PDF.SaveAs("output.pdf");
        }
    }
    Imports IronPdf
    
    Friend Class Program
    	Shared Sub Main()
    		' Instantiate a renderer
    		Dim Renderer = New HtmlToPdf With {
    			.RenderOptions = New ChromePdfRendererOptions With {.InputEncoding = "UTF-8"}
    		}
    
    		' Convert HTML to PDF
    		Dim PDF = Renderer.RenderHtmlAsPdf("<p>Sample content with UTF-8 encoding</p>")
    
    		' Save the PDF to disk
    		PDF.SaveAs("output.pdf")
    	End Sub
    End Class
    $vbLabelText   $csharpLabel
    • HtmlToPdf:这是来自 IronPdf 库的类,用于将 HTML 文档转换为 PDF。
    • RenderOptions.InputEncoding:此属性允许您设置输入数据的编码。 在此,将其设置为 "UTF-8" 以支持国际语言。
    • RenderHtmlAsPdf:此方法将给定的 HTML 内容呈现为 PDF 格式。
    • SaveAs:此方法用于将渲染的 PDF 文件保存到指定的文件路径。

请在 IronPdf 文档中阅读有关 inputEncoding 属性的更多信息:IronPdf.ChromePdfRenderOptions.inputEncoding

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 16,154,058 | 版本: 2025.11 刚刚发布