iTextSharpを使用してPDFに「✔」文字を表示しようとしています。ただし、作成されたPDFに文字は表示されません。これで私を助けてください。iTextSharpを使って✔をPDFで表示するには?
答えて
Phrase phrase = new Phrase("A check mark: ");
Font zapfdingbats = new Font(Font.FontFamily.ZAPFDINGBATS);
phrase.Add(new Chunk("\u0033", zapfdingbats));
phrase.Add(" and more text");
document.Add(phrase);
PDF仕様に準拠PDFレンダラーは14個のフォントからなる共通のセットをサポートしなければならず、Zapf Dingbatsもその1つです。このソリューションは、フォントを埋め込む必要がないため、おそらく最適です。実際にフォントを埋め込む唯一の理由は、このレンダリング方法が気に入らない場合です。 –
フォントWingdingsは "o"の代わりにこの文字を印刷します。 このフォントをアプリケーションに接続し、このフォントをletterに適用し、互換性のためpdfにフォントを埋め込む必要があります。
これは私が自分のプロジェクトの中でしばらく前から使っていた機能です(クリーニングされていません)。 クリーンアップしてください。ただし、必要な機能がいくつかあります。 (私は私のカスタムフォント(font1.ttfとfont2.ttf)をプロジェクトディレクトリにコピーしました)
私はあなたに役立つことを望んでいます。
public void StartConvert(String originalFile, String newFile)
{
Document myDocument = new Document(PageSize.LETTER);
PdfWriter.GetInstance(myDocument, new FileStream(newFile, FileMode.Create));
myDocument.Open();
int totalfonts = FontFactory.RegisterDirectory("C:\\WINDOWS\\Fonts");
iTextSharp.text.Font content = FontFactory.GetFont("Pea Heather's Handwriting", 13);//13
iTextSharp.text.Font header = FontFactory.GetFont("assign", 16); //16
BaseFont customfont = BaseFont.CreateFont(@"font1.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
Font font = new Font(customfont, 13);
string s = " ";
myDocument.Add(new Paragraph(s, font));
BaseFont customfont2 = BaseFont.CreateFont(@"font2.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
Font font2 = new Font(customfont2, 16);
string s2 = " ";
myDocument.Add(new Paragraph(s2, font2));
try
{
try
{
using (StreamReader sr = new StreamReader(originalFile))
{
// Read and display lines from the file until the end of
// the file is reached.
String line;
while ((line = sr.ReadLine()) != null)
{
String newTempLine = "";
String[] textArray;
textArray = line.Split(' ');
newTempLine = returnSpaces(RandomNumber(0, 6)) + newTempLine;
int counterMax = RandomNumber(8, 12);
int counter = 0;
foreach (String S in textArray)
{
if (counter == counterMax)
{
Paragraph P = new Paragraph(newTempLine + Environment.NewLine, font);
P.Alignment = Element.ALIGN_LEFT;
myDocument.Add(P);
newTempLine = "";
newTempLine = returnSpaces(RandomNumber(0, 6)) + newTempLine;
}
newTempLine = newTempLine + returnSpaces(RandomNumber(1, 5)) + S;
counter++;
}
Paragraph T = new Paragraph(newTempLine, font2);
T.Alignment = Element.ALIGN_LEFT;
myDocument.Add(T);
}
}
}
catch (Exception e)
{
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
}
catch (DocumentException de)
{
Console.Error.WriteLine(de.Message);
}
catch (IOException ioe)
{
Console.Error.WriteLine(ioe.Message);
}
try
{
myDocument.Close();
}
catch { }
}
1つのメソッド内でGC.Collect()呼び出しが非常に多く見たことはありません。 – lurkerbelow
- 1. iTextSharpを使ってpdfに中国語フォントを表示する方法は?
- 2. iTextSharpはiTextSharpを使用してPDFファイル
- 3. WinForms - iTextSharpを使って保存したばかりのPDFを開いて表示するには?
- 4. iTextSharp PDFファイルの表を読むには
- 5. C#とiTextSharpを使ってPDFに画像を追加するには?
- 6. iTextSharpはitextsharp 4.2.0を使用して、無効なPDF
- 7. iTextSharpはPDFを生成してブラウザに直接表示します
- 8. pdf itextsharpを使ったpdfの中心画像
- 9. データベースからの画像でitextsharpを使ってpdfを作成する
- 10. Itextsharp PDFをダウンロード
- 11. itextsharpでpdfチェックボックスをオフにする
- 12. itextsharpを使用してpdfにブックマークを追加する
- 13. itextsharpを使用して画像をPDFに変換する
- 14. iTextSharpを使用してPDF文書をTIFFに変換する
- 15. iTextSharpを使用してPDFファイルにボタンを追加する
- 16. iTextSharpを使用してPDFにWMFを追加する
- 17. iTextSharpを使用してPDFファイルを出力ストリームにマージする
- 18. iTextSharp - ホバーにテキストを表示
- 19. itextsharpを使用して他のpdfファイルにpdfを追加する方法
- 20. itextsharp 5.5.10 PDFの見出しを使ってC#でpdfに変換するgridview? (初心者)
- 21. itextsharpを使ってpdfイメージの向きを取得する方法
- 22. iTextsharpを使ってpdfファイル内のテーブルの位置を指定する方法#
- 23. iTextSharpを使用してMVCでWebGridをPDFにエクスポート
- 24. wicked_pdfを使ってpdf上に地図を表示する方法は?
- 25. AzureでiTextSharpでPDFを作成する
- 26. ベトナム語の文字を.pdf文書でitextsharpを使って表示するにはどうすればいいですか?
- 27. PDFでテーブルを読むItextsharp
- 28. iTextSharpを使用して作成した表示イメージです。
- 29. テーブルをitextsharpで作成するpdf
- 30. PDF CでiTextSharpを使用してUSBトークンを使用して署名する
あなたは私たちにあなたがiTextSharpを使用してPDF文書にその文字を追加するために使用しているコードを表示することができますか? – user7116
✔文字のあるフォントを使用していますか? –