CMYK與國際語言PDF故障排除
This article was translated from English: Does it need improvement?
Translated
View the article in English
IronPDF支援所有 Unicode 支援的國際語言的 HTML 轉 PDF 功能,包括混合語言文件。
需要考慮的兩點是字體和輸入編碼,本常見問題頁面對此有更詳細的解釋:https://ironpdf.com/how-to/utf-8/
您的伺服器上必須安裝支援您字元集的字型。
您可能需要指定文件的輸入編碼才能正確渲染它。
您可以透過以下方式實現這一點:
1.新增 HTML "Meta Charset" 標籤
此方法涉及在 HTML 的 `<head>` 部分中包含 `<meta>` 標籤來定義字元集。 這樣可以確保您的HTML文件使用正確的字元。
```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>
```
`<meta charset="UTF-8">` 標籤指定 UTF-8 字元編碼,能夠處理任何 Unicode 字元。
2.設定IronPDF HTML 轉 PDF 轉換器的 inputEncoding 屬性
您可以設定IronPDF轉換器的 `inputEncoding` 屬性,以便在轉換過程中指定字元編碼。
這可以在 C# 程式碼中按如下方式實現:
```csharp
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");
}
}
```
- **`HtmlToPdf`** : 這是IronPDF庫中的一個類,用於將 HTML 文件轉換為 PDF。
- **`RenderOptions.InputEncoding`** : 此屬性可讓您設定輸入資料的編碼。 這裡設定為 `"UTF-8"` 以支援國際語言。
- **`RenderHtmlAsPdf`** : 此方法將給定的 HTML 內容渲染為 PDF 格式。
- **`SaveAs`** : 此方法用於將渲染的 PDF 檔案儲存到指定的檔案路徑。
請閱讀IronPDF文件中關於 inputEncoding 屬性的更多資訊: IronPDF
準備好開始了嗎?
Nuget 下載 18,560,885 | 版本: 2026.4 剛剛發布

