PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Change image and font color mode
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3868
Page 1 of 1

Author:  boba21 [ Fri Nov 16, 2018 2:45 am ]
Post subject:  Change image and font color mode

Hi, i'm using
Code:
gfx.DrawImage
function to draw an image from other pdf and create new pdf.
The image originally was in grayscale, but when i export to new pdf it became cmyk.
I found out that document colormode can change, but what I want is to change the image only, not the document.
So, when I'm checking it in Acrobat Pro, it can differentiate the output view.
This is for printing side, instead of using cmyk color to create black, it will only use black color. So, not waste the other color.

Second question also regarding color, when I'm checking the color using Acrobat Pro, the font color mode set as cmyk.
But the font was black only, how do I set this to greyscale?

So, how I change image and font color mode? Is there any function in pdfsharp for this?

Author:  TH-Soft [ Fri Nov 16, 2018 6:30 am ]
Post subject:  Re: Change image and font color mode

Hi!

Are you still using the inofficial PdfSharpCore port of PDFsharp where image handling is completely different?

See also:
http://forum.pdfsharp.net/viewtopic.php?f=2&t=832

Author:  boba21 [ Fri Nov 16, 2018 6:41 am ]
Post subject:  Re: Change image and font color mode

Nope, i change and use this pdfsharp already. :-)

So, is there a function in pdfsharp to do this?

Author:  Thomas Hoevel [ Mon Nov 19, 2018 8:36 am ]
Post subject:  Re: Change image and font color mode

boba21 wrote:
So, is there a function in pdfsharp to do this?
I might be able to answer that if I knew what you want.

Maybe this thread helps (at least to clarify the question):
viewtopic.php?p=9495#p9495

Otherwise the IssueSubmissionTemplate might help to clarify the question.

Author:  boba21 [ Fri Nov 23, 2018 9:40 am ]
Post subject:  How to change image and font color mode?

Hi, I'm creating an upgrade application using PDFSharp 1.50. The old application using PDFSharp 1.20, so I need to create new application for generating a pdf.
So, when user click a button, it will generate a pdf where it contains of text and an image.
I'm setting this document to CMYK color mode by default, so the colour image also will use this mode.
Code:
document.Options.ColorMode = PdfColorMode.Cmyk;


Here is the problem. When I'm checking the generated pdf output preview using Acrobat Reader Pro, I'm changing the Show only CMYK, certain part of image is missing then I try to show only Gray, the missing image show up but the other image and text is missing.
Below is the screenshot of the behaviour using PDFSharp 1.50:
Attachment:
2.png
2.png [ 73.03 KiB | Viewed 7197 times ]

Attachment:
3.png
3.png [ 153.54 KiB | Viewed 7197 times ]



When I checking the old pdf generated by PDFSharp 1.20, this issue doesn't exist. When selecting to show CMYK, no image and text will show up. But, when selecting Gray, both image will shown up. Here is the screenshot of pdf using PDFSharp 1.20:
Attachment:
5.png
5.png [ 204.31 KiB | Viewed 7197 times ]


Then I try to change text color only using this code below. All text will show up in CMYK mode, but not in Gray mode when checking in Acrobat Reader Pro:
Code:
XBrush grayScale_0 = new XSolidBrush(XColor.FromGrayScale(0));
XBrush black_cmyk = new XSolidBrush(XColor.FromCmyk(0, 0, 0, 100));
XBrush black_rgb = new XSolidBrush(XColor.FromArgb(0, 0, 0));
XBrushes.Black


So, is there a function in PDFSharp 1.50 to do this, change font color and image color mode to Gray?
Or this function only exist in v1.20? Please anyone help me..Thanks.

Author:  () => true [ Fri Nov 23, 2018 6:35 pm ]
Post subject:  Re: How to change image and font color mode?

boba21 wrote:
So, is there a function in PDFSharp 1.50 to do this, change font color and image color mode to Gray?
Or this function only exist in v1.20? Please anyone help me..Thanks.
AFAIK no functions were removed from PDFsharp. I'm afraid I don't understand what the issue is here.

Author:  boba21 [ Tue Nov 27, 2018 1:53 am ]
Post subject:  Re: Change image and font color mode

If you see the image below, this is the original image in PDF format. The image was in black and white only.
Attachment:
original image.PNG
original image.PNG [ 57.8 KiB | Viewed 7168 times ]


But, when I drawing the image into another pdf using PDFSharp, the image color change. There is a bit dark black color in the image.
Below is the result after using PDFSharp.
Attachment:
new image with text.PNG
new image with text.PNG [ 41.81 KiB | Viewed 7168 times ]


It seem PDFSharp DrawImage change the image color.
That's why I want to know if there is image color mode to make the image like original image?

Author:  boba21 [ Tue Nov 27, 2018 9:56 am ]
Post subject:  Re: Change image and font color mode

Hi, I found why this thing happen. The image have dark/black.

I just need to draw the image first then draw the text. Now it works.
But, must use PDFSharp 1.32.

If use the latest version 1.5rc2, only dark/image will shown up.
Here I attach the sample when try in version 1.5.
Attachment:
image missing and crop.PNG
image missing and crop.PNG [ 87.36 KiB | Viewed 7163 times ]

Author:  Thomas Hoevel [ Tue Nov 27, 2018 12:26 pm ]
Post subject:  Re: Change image and font color mode

boba21 wrote:
It seem PDFSharp DrawImage change the image color.
It seems you do not use the IssueSubmissionTemplate.
I still don't fully understand what this is about. I cannot replicate the issue.

Version 1.50 has some bug fixes, but does not otherwise change how images are handled.
Version 1.32 incorrectly applies transparency to images when it shouldn't. In the worst case your code relies on a bug in the old version.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/