PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:28 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Fri Nov 16, 2018 2:45 am 
Offline

Joined: Fri Jul 27, 2018 3:29 am
Posts: 19
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?


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 16, 2018 6:30 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
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

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 16, 2018 6:41 am 
Offline

Joined: Fri Jul 27, 2018 3:29 am
Posts: 19
Nope, i change and use this pdfsharp already. :-)

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 19, 2018 8:36 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 23, 2018 9:40 am 
Offline

Joined: Fri Jul 27, 2018 3:29 am
Posts: 19
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 7194 times ]

Attachment:
3.png
3.png [ 153.54 KiB | Viewed 7194 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 7194 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.


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 23, 2018 6:35 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 339
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.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2018 1:53 am 
Offline

Joined: Fri Jul 27, 2018 3:29 am
Posts: 19
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 7165 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 7165 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?


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2018 9:56 am 
Offline

Joined: Fri Jul 27, 2018 3:29 am
Posts: 19
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 7160 times ]


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2018 12:26 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 151 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group