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

@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.