Found another issue, when generate pdf using PDFSharp 1.32.
I draw the text first, set to purple colour (
Xbrushes.Purple) then draw the image after the text.
I just change the arrangement to draw text first and image second.
Below is the code:
Code:
PdfDocument document = new PdfDocument();
document.Options.ColorMode = PdfColorMode.Cmyk; // set colour sep as original
// Create an empty page
PdfPage page = document.AddPage();
page.Size = PageSize.A4;
XGraphics gfx = XGraphics.FromPdfPage(page);
// get the image
XImage image = XImage.FromFile("D:\\sample_image.pdf");
double imageCenter_X = image.PointWidth / 2;
double pageCenter_X = page.Width / 2;
double center_X = pageCenter_X - imageCenter_X;
// draw the text - 1st
XFont font = new XFont("Verdana", 14, XFontStyle.Bold);
gfx.DrawString("Using: XBrushes.Purple| Processed Image Drawn First", font, XBrushes.Purple, pageCenter_X, 20, XStringFormats.Center);
gfx.DrawString("PDFSharp 1.32.3057", font, XBrushes.Purple, pageCenter_X, 40, XStringFormats.Center);
// draw the image - 2nd
gfx.DrawImage(image, center_X, 60);
// Save the pdf document...
string filename = "D:\\Test\\PDFOutput_" + string.Format("{0:ddMMyyyy_HHmmss}.pdf", DateTime.Now);
document.Info.Title = filename;
document.Save(filename);
The result will give me an image mix up with the purple colour.
The image will reflex based on the last colour set to the text. So, if I set last colour to green, the image will have green colour.
Here the screenshot of the pdf generated when draw text first and image later.
Attachment:
PDFSharp 1.32.3057 - purple.PNG [ 77.81 KiB | Viewed 5522 times ]