Я использую Itextsharp DLL для создания PDF.
Я хочу изменить цвет шрифта.
Я нашел решение в Google.
Document document = new Document(PageSize.A4, 88f, 88f, 10f, 10f);
Font NormalFont = FontFactory.GetFont("Arial", 12, Font.NORMAL, Color.BLACK);
Но я пытаюсь получить исходный код.Это шоу - ошибка. Название «Цвет» не существует в текущем контексте.Цветовой класс не увлекал.
Как решить эту ошибку.
Спасибо.
Мой код ниже.
using iTextSharp.text;
using iTextSharp.text.pdf;
private void sPDF(DataRow row)
{
Document document = new Document(PageSize.A4, 88f, 88f, 10f, 10f);
Font NormalFont = FontFactory.GetFont("Arial", 12, Font.NORMAL, Color.BLACK);
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
{
PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
Phrase phrase = null;
PdfPCell cell = null;
PdfPTable table = null;
Color color = null;
document.Open();
//Separater Line
color = new Color(System.Drawing.ColorTranslator.FromHtml("#A9A9A9"));
DrawLine(writer, 25f, document.Top - 79f, document.PageSize.Width - 25f, document.Top - 79f, color);
DrawLine(writer, 25f, document.Top - 80f, document.PageSize.Width - 25f, document.Top - 80f, color);
document.Add(table);
document.Close();
byte[] bytes = memoryStream.ToArray();
memoryStream.Close();
}
}
private static void DrawLine(PdfWriter writer, float x1, float y1, float x2, float y2, Color color)
{
PdfContentByte contentByte = writer.DirectContent;
contentByte.SetColorStroke(color);
contentByte.MoveTo(x1, y1);
contentByte.LineTo(x2, y2);
contentByte.Stroke();
}