PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
Custom Font Color http://forum.pdfsharp.de/viewtopic.php?f=2&t=1587 |
Page 1 of 1 |
Author: | slowjoe [ Mon Mar 21, 2011 2:00 am ] |
Post subject: | Custom Font Color |
Hi, I have written a fairly simple C# windows app that draws a background image then text on top of it. I can not seem to set the font color to a "custom" color (RGB or CMYK) but the predefined colors work. The custom colors appear black. I hope I'm missing something simple. Any help is appreciated. Thank you, Joe Code: PdfDocument document = new PdfDocument();
// Create a new page PdfPage page = document.AddPage(); page.Size = PageSize.Letter; page.Orientation = PageOrientation.Portrait; XGraphics gfx = XGraphics.FromPdfPage(page, XPageDirection.Downwards); // Draw background gfx.DrawImage(XImage.FromFile("Background.pdf"), 0, 0); // Write on top of background with known colors gfx.DrawString("Name", new XFont("Garamond", 12, XFontStyle.Regular), XBrushes.Firebrick, 100, 670, XStringFormats.TopLeft); gfx.DrawString("Title", new XFont("Garamond", 10, XFontStyle.Italic), XBrushes.DodgerBlue, 100, 685, XStringFormats.TopLeft); // Write on top of background with custom colors // DOES NOT WORK, COMES OUT BLACK!!!!!! gfx.DrawString("Phone", new XFont("Garamond", 12, XFontStyle.Regular), new XSolidBrush(XColor.FromCmyk(62, 28, 2, 3)), 100, 700, XStringFormats.TopLeft); gfx.DrawString("Email", new XFont("Garamond", 10, XFontStyle.Regular), new XSolidBrush(XColor.FromCmyk(5, 95, 39, 16)), 100, 715, XStringFormats.TopLeft); // Save the document... document.Save("BackgroundWithText.pdf"); |
Author: | Thomas Hoevel [ Mon Mar 21, 2011 9:24 am ] |
Post subject: | Re: Custom Font Color |
Hi! Please note that CMYK uses floating point numbers for the colour components. Values >= 1 mean full saturation. So all colours you specify are black! See also here: http://www.pdfsharp.net/wiki/ColorsCMYK ... hx?HL=cmyk You use CMYK colours, but you don't set the PDF file to CMYK mode. This should not make a big difference. |
Author: | slowjoe [ Mon Mar 21, 2011 5:50 pm ] |
Post subject: | Re: Custom Font Color |
Hi Thomas, Thanks for the quick reply. I won't be able to test it out untill tonight but it leads to my next question. Do I enter the CMKY values as a percentage of 255 or of 100. In other words, the values I tried (62, 28, 2, 3) were given to me from someone that uses photo shop. Should I enter 0.62, 0.28, 0.02, 0.03 or 62/255, 28/255 etc.? I guess I could just try each case myself but if you know that would be great. Thanks again, Joe |
Author: | Thomas Hoevel [ Tue Mar 22, 2011 8:37 am ] |
Post subject: | Re: Custom Font Color |
slowjoe wrote: Should I enter 0.62, 0.28, 0.02, 0.03 or 62/255, 28/255 etc.? I'd go for 0.62, 0.28, 0.02, 0.03 (that's what the average photo shop user will expect to see). |
Author: | slowjoe [ Tue Mar 22, 2011 2:25 pm ] |
Post subject: | Re: Custom Font Color |
Hi Thomas, That was what I needed - the colors look right. Thank you very much, Joe |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |