시스템에 설치되지 않는 매우 특정한 글꼴이 필요한 PDF를 생성하는 C# .NET WPF 데스크탑 응용 프로그램에서 작업하고 있습니다. 나는 PdfSharp-WPF v1.32를 사용하고 있습니다. 파일 importantSc.ttf
은 프로젝트 리소스 폴더에 있습니다.PDFsharp에서 개인 TTF 글꼴 사용
최선의 방법은 내 URI 경로가 잘못되었지만 올바른 것으로 생각됩니다. 폰트가 내 dev 컴퓨터에 설치되어있는 동안 나는 폰트 패밀리 이름이 맞다.
using System;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using Microsoft.Win32;
using PdfSharp.Drawing.Layout;
using System.Collections.Generic;
using System.Windows.Input;
using System.Windows;
namespace MyProject
{
public class MyPdfFile
{
private PdfDocument doc;
public void MakePdf()
{
Double x1, y1;
XBrush brush = XBrushes.Black;
XGraphics xgf = XGraphics.FromPdfPage(page);
doc = new PdfDocument();
PdfPage page = doc.AddPage();
// Load in a private font to use.
XPrivateFontCollection privateFontCollection = new XPrivateFontCollection();
String fontFamilyName = "Important Script AM";
String fontUriPath = @"pack://application:,,,/importantSc.ttf";
Uri fontUri = new Uri(fontUriPath);
privateFontCollection.Add(fontUri, "./#" + fontFamilyName);
XFont font = new XFont(fontFamilyName, 9, XFontStyle.Regular); // <-- the error happens here
//Add text to page
x1 = 1.96 * 72;
y1 = 3.25 * 72;
String printString = "I wish this would work!";
xgf.DrawString(printString, font, brush, x1, y1);
xgf.Dispose();
}
}
}
나는 다음과 같은 오류가 점점 오전 :
처리되지 않은 'System.InvalidOperationException'형식의 예외가 PdfSharp-WPF.dll의 발생을
추가 정보 : 일치하는 그림 문자를 가져올 수 없습니다 글꼴 '중요한 스크립트 오전'글꼴.