문제

I'm using the Aspose PDF for .NET, trying to create a very simple PDF with a TextBox. I have that part working - as it is very simple.

However, I want to change the font of the text in the box, so that when printed, the font is Red (for example).

Here is the code that I think should be working:

// Create a PDF sample PDF file.
var formEditor = new FormEditor("blank.pdf", "result.pdf");

// Create a "style" for the PDF.
formEditor.Facade = new FormFieldFacade();
formEditor.Facade.BackgroundColor = System.Drawing.Color.Yellow;
formEditor.Facade.Font = FontStyle.TimesBold;
formEditor.Facade.TextColor = System.Drawing.Color.Red;
formEditor.Facade.FontSize = 24;

// Add a text box called "FirstName".
formEditor.AddField(FieldType.Text, "FirstName", 1, 100, 800, 260, 780);
formEditor.SetFieldAppearance("FirstName", AnnotationFlags.Print);

// Save the result.
formEditor.Save();

The resultant PDF has the textbox, and the background is Yellow... but the foreground text is not Red, nor is the size 24, nor is the font "TimesBold" - it's as if nothing about the actual font of the text works.

Notice both in the PDF and if I print it...

PDF with Yellow TextBox but no Red Font

PDF with Yellow TextBox but no Red Font printed as an XPS file

Am I missing something?

도움이 되었습니까?

해결책

Well, this was simple.

I was using version 6.4 (purchased over a year ago)... this was actually a bug that has been fixed since then (in version 7.3 I believe).

Thankfully, my license goes up to December 29th 2012, so I was able to get version 7.6 :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top