我需要找到一種方法,可以將一個單詞加粗。PDFsharp一個粗體單詞
我有一個長文本,需要一些粗體字。
File.WriteAllText("Vertrag/vertrag.txt", File.ReadAllText("Vertrag/vertrag.txt").Replace("Verstragsgegenstand", new XFont("Verdana"mbox 7m XFontStyle.Bold) "BoldWord");
但這並不起作用。
我需要找到一種方法,可以將一個單詞加粗。PDFsharp一個粗體單詞
我有一個長文本,需要一些粗體字。
File.WriteAllText("Vertrag/vertrag.txt", File.ReadAllText("Vertrag/vertrag.txt").Replace("Verstragsgegenstand", new XFont("Verdana"mbox 7m XFontStyle.Bold) "BoldWord");
但這並不起作用。
你可以嘗試使用chunck
string path = Server.MapPath("PDFs");
Rectangle r = new Rectangle(400, 300);
Document doc = new Document(r);
PdfWriter.GetInstance(doc, new FileStream(path + "/Blocks.pdf", FileMode.Create));
doc.Open();
Chunk c1 = new Chunk("A chunk represents an isolated string. ");
for (int i = 1; i < 4; i++)
{
doc.Add(c1);
}
的更多細節http://www.mikesdotnetting.com/article/82/itextsharp-adding-text-with-chunks-phrases-and-paragraphs
這是iTextSharp而不是PDFSharp ... – Gomze
隨着PDFsharp你要分割你的文字,使正常的和大膽的文字單獨調用DrawString
。
我推薦使用MigraDoc。您仍然需要拆分文本,並使用AddFormattedText
作爲粗體字,但會自動獲得換行符和分頁符。
您的問題中顯示的方法(使用String.Replace
)將不起作用。
也許 「Verstragsgegenstand」(原文如此)不能在文本文件中找到。即使搜索「Vertragsgegenstand」,「String.Replace」方法也不起作用。 –