Provide Any Property to Identify that Individual Page Contains Color or Not

@hemalp

Are you using a valid license while testing? Also, can you please share a sample console application for our reference so that we can try to replicate the issue in our environment and address it accordingly.

Hello @asad.ali

Please Find below Code sample and output of PDF

using AsposePdf = global::Aspose.Pdf;
AsposePdf.Document _document = new AsposePdf.Document(datadir + “ColorText_word.pdf”);

        foreach (AsposePdf.Page page in _document.Pages)
        {
            Console.WriteLine($"Page Number : {page.Number} || Color Type : {page.ColorType}");
        }

OUTPUT:
Page Number : 1 || Color Type : Rgb
Page Number : 2 || Color Type : Rgb
Page Number : 3 || Color Type : Rgb
Page Number : 4 || Color Type : Rgb

Input PDF :ColorText_word.pdf (218.3 KB)

Hello @asad.ali

Now It’s Working Fine.

Thanks

@hemalp

Its nice to know that your issue is sorted out. Please feel free to create a new topic in case you need further assistance.

Hello @asad.ali

Still below extension not support except(Aspose.word,Aspsoe.pdf)
Aspose.Cells , Aspose.Diagram , Aspose.Imaging , Aspose.Note , Aspose.PUB , Aspose.Slides

Thanks

@hemalp,

To evaluate colors regarding Aspose.Cells and Aspose.Note, we already replied and provided the details. See the reply for your reference.

Regarding Aspose.Diagram, Aspose.Imaging, Aspose.PUB and Aspose.Slides, our concerned teams will assist you soon.

@hemalp,
I apologize for the belated reply. I looked at your sample presentation above. Could you please describe the issue you are experiencing in more detail?

Hello @amjad.sahi @asad.ali

reply According to your reply for Aspose.Cell it’s not possible to access all cells and check their color, we want to identify the property of particular pages while imageGeneration using Aspose.Cells , Aspose.Diagram , Aspose.Imaging , Aspose.Note , Aspose.PUB , Aspose.Slides etc. Please give me a proper solution on how to identify the property of All pages above mentioned all extension type reply And check the above we already describe the issue in detail.

Thanks

@hemalp

About Aspose.Diagram and Aspose.PUB, can you kindly share the respective sample source files for our reference so that we can further investigate your requirements accordingly and share our feedback with you.

@hemalp,
As for the “Black Color PPT.pptx” file, it looks like you need to determine if each slide contains any colored objects (not grayscale objects). Could you please confirm this?

@hemalp,

1). Regarding Aspose.Cells, you may easily write your own code to check if a specific page is colored or has shaded background. I have used your template Excel file and written the following sample code to evaluate each page in the worksheet if it has colored background or not. Please refer to it and write/update your own code accordingly.

            Workbook workbook = new Workbook("g:\\test2\\Blak&Color_Excel.xlsx");
            
            Worksheet worksheet = workbook.Worksheets[0];

            ImageOrPrintOptions printoption = new ImageOrPrintOptions();
            printoption.PrintingPage = PrintingPageType.Default;
            SheetRender sr = new SheetRender(worksheet, printoption);
            int pageCount = sr.PageCount;
            Console.WriteLine(pageCount);

            CellArea[] area = worksheet.GetPrintingPageBreaks(printoption);
            Console.WriteLine(area.Length);

            for (int i = 0; i < area.Length; i++)
            {

                //Get the page rows of each area. 
                int strow = area[i].StartRow;
                int stcol = area[i].StartColumn;

                int numrows = area[i].EndRow;
                int numcols = area[i].EndColumn;

                Console.WriteLine("Page " + (i + 1).ToString() + " starts at: " + CellsHelper.CellIndexToName(strow, stcol));
                Console.WriteLine("Page " + (i + 1).ToString() + " ends at: " + CellsHelper.CellIndexToName(numrows, numcols));
                
                bool colored = false;
                for (int r = strow; r < numrows +1; r++)
                {
                    for (int c = stcol; c < numcols +1; c++)
                    {
                        //Get the style of the cell
                        Style style = worksheet.Cells.GetCellStyle(r, c);                        
                        if (!(style.ForegroundColor.IsEmpty) &&! (style.ForegroundColor.A.ToString()  == "255" & style.ForegroundColor.R.ToString() == "255" & style.ForegroundColor.G.ToString() == "255" & style.ForegroundColor.B.ToString() =="255"))
                        {
                            colored = true;                            
                            break;
                            
                        }
                        
                    }                    
                }

                if (colored)
                {

                    Console.WriteLine("Page " + (i + 1) + " is with colored background");
                }
                else {

                    Console.WriteLine("Page " + (i + 1) + " is not colored or shaded with white background");
                }

            } 

2). Regarding Aspose.Note, please refer to the following sample code for your reference.

            Aspose.Note.Document doc1 = new Aspose.Note.Document("g:\\test2\\test_doc.one");

            // Get number of pages
            int count = doc1.GetChildNodes<Aspose.Note.Page>().Count;
            Console.WriteLine("Page count: " + count);

            for (int i = 0; i<count; i++)
            {
                Console.WriteLine("Page: " + (i+1));
            }

            //scan for background color
            foreach (var page in doc1)
            {
                Console.WriteLine(page.BackgroundColor.ToString());
                
            }
            //scan for rich text
            foreach (var node in doc1.GetChildNodes<Aspose.Note.RichText>())
            {
                var c = node.ParagraphStyle.FontColor;
                Console.WriteLine(c.ToString());
                
            } 

Hope, this helps a bit.

Hello @andrey.potapov

reply yes, We want to determine if each slide contains any colored objects or not

Thanks

Hello @asad.ali

Please check the above reply we have already given all extension (also Pub or diagram file include) type file.

Thanks

@hemalp,
Presentation slides can contain many different color objects (text, shapes, SmartArt, charts, tables, and so on) and they have their own properties for getting and setting color properties. There is no general property or method in Aspose.Slides to check if there are colored objects on the slide. Could you please explain what is your goal? Why is it necessary to detect colored objects on slides?

reply then how do we identify whether that particular slide is color or not?

@hemalp,
I can suggest two ways, but they have big drawbacks:

The first way
Iterate over all objects on a slide and check the color properties of the objects (this can take a long time to implement because there are objects of a large number of types in PowerPoint presentations).

The second way
Convert presentation slides to RGB images and check if the images contain color pixels (this method may have poor performance).

hello @andrey.potapov

can you please give me a proper solution to find a particular slide is a color or not like Aspose.PDF and Aspose.word .

@hemalp,
Unfortunately, not. I have suggested you two solutions above.

Hello @andrey.potapov

as per your suggestion, we can’t use your given solution due to a performance issue. please give us proper solution.

@hemalp,
Unfortunately, there are no other solutions to achieve your requirements with Aspose.Slides.