Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Jan 20, 2017 7:09 pm

Hello,
We are trying to determine the colorspace of a pdf document programmatically using C# with spire.pdf. Unfortunately, we are only receiving RGB as the color space. Below an example to reproduce the issue.

Code: Select all
           var pdfDoc = new PdfDocument() {ColorSpace = PdfColorSpace.GrayScale};

            var page = pdfDoc.Pages.Add();
            page.Canvas.DrawString("Grayscale text", new PdfFont(PdfFontFamily.Courier, 12f), new PdfSolidBrush(Color.Red), 10, 10  );

            pdfDoc.SaveToFile(@"C:\temp\Grayscale.pdf");
            pdfDoc.Close();

            var pdfOpen = new PdfDocument(@"C:\temp\Grayscale.pdf");
            Console.WriteLine(pdfOpen.ColorSpace.ToString());
            pdfOpen.Close();


Not sure if we are missing anything here, could not find much help on color space anywhere.

Regards
Renjith

renjith
 
Posts: 2
Joined: Tue Oct 27, 2015 3:35 pm

Sun Jan 22, 2017 6:09 am

Hello Renjith,

Thanks for your inquiry.
The default value of the ColorSpace is always RGB. When you set the value of the ColorSpace, it just set the color style of your new drawing. It won't save the value to the document. So while you load the document, it will print "RGB" to the screen as its default value.

Sincerely,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Jan 24, 2017 3:57 pm

Thank you for the update Simon. I have another related question. Is there any way to check if a pdf document has color content in it (other than grayscale content) ?

Thanks
Renjith

renjith
 
Posts: 2
Joined: Tue Oct 27, 2015 3:35 pm

Wed Jan 25, 2017 9:42 am

Hello Renjith,

You can transfer the Pdf document into picture first through Sprie.Pdf. Then detect whether the picture has the color.
https://www.e-iceblue.com/Tutorials/Spi ... -code.html

Sincerely,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Wed Apr 14, 2021 9:32 pm

Simon.yang wrote:Hello Renjith,

Thanks for your inquiry.
The default value of the ColorSpace is always RGB. When you set the value of the ColorSpace, it just set the color style of your new drawing. It won't save the value to the document. So while you load the document, it will print "RGB" to the screen as its default value.

Sincerely,
Simon
E-iceblue support team


Is there a way to set the ColorSpace such that it exports the PDF in CMYK format?

mtceegee
 
Posts: 17
Joined: Wed Oct 28, 2020 4:32 pm

Thu Apr 15, 2021 9:48 am

Hello,

Thanks for your inquiry.
We are very sorry that our Spire.PDF doesn't support setting the ColorSpace as you mentioned. If there is anything else we can do for you, please feel free to contact us. Apologize for the inconvenience caused.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF