I have a large program that produces customer paperwork. The forms are laid out as cells with heading strips that are shaded in. The headings are meant to be green but I often find they come out a blue-green colour, or even blue, depending on which printer you use - this is a problem for us.
Here is a minimum working example. My program creates a green square as a bitmap image and saves it to a file. It then creates a MigraDoc PDF, shades a cell in the same colour, and adds the image.
Code:
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using MigraDoc.DocumentObjectModel.Tables;
using System.Drawing;
namespace PDFPlay
{
static class Program
{
static void Main()
{
//create image file
Bitmap bitmap = new Bitmap(114, 114);
Graphics g = Graphics.FromImage(bitmap);
Brush brush = new SolidBrush(System.Drawing.Color.FromArgb(0, 176, 80));
g.FillRectangle(brush, new Rectangle(0, 0, 114, 114));
bitmap.Save(@"C:\Temp\greensquare.png");
Document document = new Document();
Section section = document.AddSection();
//add shaded square
Table mainTable = section.AddTable();
mainTable.AddColumn("3cm");
mainTable.AddRow().Height = "3cm";
mainTable.Rows[0].Cells[0].Shading.Color = new MigraDoc.DocumentObjectModel.Color(0, 176, 80);
mainTable.AddRow();
//add image
section.AddImage(@"C:\Temp\greensquare.png");
//render and save PDF
document.UseCmykColor = true;
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false);
pdfRenderer.Document = document;
pdfRenderer.RenderDocument();
pdfRenderer.PdfDocument.Save("C:\\Temp\\pdftest.pdf");
}
}
}
The result is below. You can see that the MigraDoc shading is a much darker green than the image. How can I control the colour of the shading so that it is the same as the image?
Attachment:
pdfcolourproblem.PNG [ 1.29 KiB | Viewed 5141 times ]