有沒有辦法在PdfSharp/MigraDoc中將陰影應用於Paragraph
的零件(例如,只是一個詞)?我嘗試添加一個Style
,其陰影爲Document
,然後將樣式名稱傳遞給AddFormattedText
方法,但它只從樣式中獲取字體信息。PdfSharp/MigraDoc - 如何遮擋部分段落
感謝,
有沒有辦法在PdfSharp/MigraDoc中將陰影應用於Paragraph
的零件(例如,只是一個詞)?我嘗試添加一個Style
,其陰影爲Document
,然後將樣式名稱傳遞給AddFormattedText
方法,但它只從樣式中獲取字體信息。PdfSharp/MigraDoc - 如何遮擋部分段落
感謝,
我正在使用PdfSharp/MigraDoc從幾個星期和之前正確回答您的問題我已閱讀它的源代碼,自由disponible。
簡短的回答是:是不可能
的長答案是: 上的樣式由AddFormattedText(string text, string style)
唯一考慮的部分是文字部分。然後,作爲ParagraphFormat
的一部分的Shading
無法應用,並且由PdfSharp/MigraDoc進行渲染。
的編碼答案是:
public FormattedText AddFormattedText(string text, string style)
{
FormattedText formattedText = AddFormattedText(text);
formattedText.Style = style;
return formattedText;
}
internal class FormattedTextRenderer : RendererBase
...
/// <summary>
/// Renders the style if it is a character style and the font of the formatted text.
/// </summary>
void RenderStyleAndFont()
{
bool hasCharacterStyle = false;
if (!this.formattedText.IsNull("Style"))
{
Style style = this.formattedText.Document.Styles[this.formattedText.Style];
if (style != null && style.Type == StyleType.Character)
hasCharacterStyle = true;
}
object font = GetValueAsIntended("Font");
if (font != null)
{
if (hasCharacterStyle)
this.rtfWriter.WriteControlWithStar("cs", this.docRenderer.GetStyleIndex(this.formattedText.Style));
RendererFactory.CreateRenderer(this.formattedText.Font, this.docRenderer).Render();
}
}
我希望這可以幫助你。 Davide。
你可以嘗試加載你的風格的段落是這樣的:
paragraph = section.AddParagraph();
paragraph.Style = "StyleName";
我個人沒有使用遮陽的功能,但是這是我載入我的風格的方式,它的工作原理好。
雖然增加了一個新的段落。我正在尋找一種方法來改變段落的陰影部分,而不是整個段落本身。 – theburningmonk
你解決了這個問題嗎?您可以使用一種解決方法,並嘗試創建一個包含單個單詞的新段落,或者只是「您的部分」,然後按照樣式設置新段落。 – f1v3