C# 设计应用程序时字体颜色问题

C# 设计应用程序时字体颜色问题,c#,C#,我在c#中的字体颜色设计中遇到了一个问题,在创建pdf文本写入时,获取字体大小、颜色和存储在属性中。在这里,我需要编写功能,并知道如何将颜色作为输入变量传递以获得输出。如果我写kavin关于创建pdf和字体输入参数,它应该基于给定的字体大小标签和颜色 Document doc = new Document(PageSize.LETTER, Convert.ToInt32(properties.PageLeft), Convert.ToInt32(properties.PageRight), Co

我在c#中的字体颜色设计中遇到了一个问题,在创建pdf文本写入时,获取字体大小、颜色和存储在属性中。在这里,我需要编写功能,并知道如何将颜色作为输入变量传递以获得输出。如果我写kavin关于创建pdf和字体输入参数,它应该基于给定的字体大小标签和颜色

Document doc = new Document(PageSize.LETTER, Convert.ToInt32(properties.PageLeft), Convert.ToInt32(properties.PageRight), Convert.ToInt32(properties.PageTop), Convert.ToInt32(properties.PageBottom) );
PdfWriter write = PdfWriter.GetInstance(doc, new FileStream(properties.PdfPath, FileMode.Create)); 
doc.Open(); 
Font font = FontFactory.GetFont(properties.Font, Convert.ToInt32(properties.FontSize)); 
Paragraph paragraph = new Paragraph(properties.Text); 
doc.Add(paragraph); 
doc.Close(); //This is the code except color 

嗨,kavin,在将来,请尝试添加您正在使用的库,这将是我们的事情

在您的代码环境下,我相信您正在使用IText

我认为你没有分享你的可变列表,这使事情复杂化了


Document doc=新文档(PageSize.LETTER、Convert.ToInt32(properties.PageLeft)、Convert.ToInt32(properties.PageRight)、Convert.ToInt32(properties.PageTop)、Convert.ToInt32(properties.PageBottom));
PdfWriter write=PdfWriter.GetInstance(doc,newfilestream(properties.PdfPath,FileMode.Create));
doc.Open();
Font Font=FontFactory.GetFont(“您想要的字体”、“字体大小”、“颜色.红色”);
段落=新段落(properties.Text);
添加文件(第段);
doc.Close()//这是除颜色以外的代码
Font=FontFactory.GetFont(“Arial”,“28”,Color.RED)//一个更具体的例子
//如果这不起作用,请尝试使用:
段落.setColorFill(基色.红色);

如果这不起作用,请务必让我知道,我将尽我最大的努力进一步帮助您。

嗨,kavin,以后请尝试添加您正在使用的库,这将是我们的事情

在您的代码环境下,我相信您正在使用IText

我认为你没有分享你的可变列表,这使事情复杂化了


Document doc=新文档(PageSize.LETTER、Convert.ToInt32(properties.PageLeft)、Convert.ToInt32(properties.PageRight)、Convert.ToInt32(properties.PageTop)、Convert.ToInt32(properties.PageBottom));
PdfWriter write=PdfWriter.GetInstance(doc,newfilestream(properties.PdfPath,FileMode.Create));
doc.Open();
Font Font=FontFactory.GetFont(“您想要的字体”、“字体大小”、“颜色.红色”);
段落=新段落(properties.Text);
添加文件(第段);
doc.Close()//这是除颜色以外的代码
Font=FontFactory.GetFont(“Arial”,“28”,Color.RED)//一个更具体的例子
//如果这不起作用,请尝试使用:
段落.setColorFill(基色.红色);

如果这不起作用,请务必告诉我,我会尽全力帮助您。

Document doc=new Document(PageSize.LETTER,Convert.ToInt32(properties.PageLeft),Convert.ToInt32(properties.PageRight),Convert.ToInt32(properties.PageTop),Convert.ToInt32(properties.PageBottom));PdfWriter write=PdfWriter.GetInstance(doc,newfilestream(properties.PdfPath,FileMode.Create));doc.Open();Font Font=FontFactory.GetFont(properties.Font,Convert.ToInt32(properties.FontSize));段落=新段落(properties.Text);添加文件(第段);doc.Close()//这是除colorHi Kavin之外的代码,欢迎使用StackOverflow!你能告诉我们你的代码到底有什么问题吗?正在发生的事情与预期发生的事情?编辑时要小心。您取消了对其他人的编辑。我正在做创建pdf的简单应用程序…在颜色文本框中,我需要显示多个颜色选项中的一种特定颜色。(例如:文本为kavin,我将此文本显示为蓝色,并从多个颜色选项中选择该颜色)但获得的颜色为argb格式,那么,我应该如何将这个argb格式传递给我的pdf创建函数代码。Document doc=新文档(PageSize.LETTER、Convert.ToInt32(properties.PageLeft)、Convert.ToInt32(properties.PageRight)、Convert.ToInt32(properties.PageTop)、Convert.ToInt32(properties.PageBottom));PdfWriter write=PdfWriter.GetInstance(doc,newfilestream(properties.PdfPath,FileMode.Create));doc.Open();Font Font=FontFactory.GetFont(properties.Font,Convert.ToInt32(properties.FontSize));段落=新段落(properties.Text);添加文件(第段);doc.Close()//这是除colorHi Kavin之外的代码,欢迎使用StackOverflow!你能告诉我们你的代码到底有什么问题吗?正在发生的事情与预期发生的事情?编辑时要小心。您取消了对其他人的编辑。我正在做创建pdf的简单应用程序…在颜色文本框中,我需要显示多个颜色选项中的一种特定颜色。(例如:文本为kavin,我将此文本显示为蓝色,并从多个颜色选项中选择该颜色)但获得的颜色为argb格式,因此,我应该如何将此argb格式传递到我的pdf创建函数代码。如果这有助于您,请不要忘记将答案标记为正确。如果这有助于您,请不要忘记将答案标记为正确