这个C#代码做什么并转换为PHP?

这个C#代码做什么并转换为PHP?

问题描述:

I want to convert this code into PHP, it's a function that hides layers on a PDF file, but I don't understand how it is doing it.

        public static void HidePDFLayers(string pdf_file, string output_file)
    {
        PdfReader reader = new PdfReader(pdf_file);
        PdfStamper stamp = new PdfStamper(reader, new FileStream(output_file, FileMode.Create));

        pdf_num_pages = reader.NumberOfPages;
        Dictionary<string, PdfLayer> layers = stamp.GetPdfLayers();

        int count = 0;

        foreach(KeyValuePair<string, PdfLayer> entry in layers )
        {
            PdfLayer layer = (PdfLayer)entry.Value;
            layer.On = false;
            count++;
        }

        stamp.Close();

        Console.WriteLine("[*] Number Of Layers Hidden: " + count);
        PDFToImages(output_file);
    }

Does this create a new PDF with all the layers hidden (which layers, surely if they were all hidden then there would be nothing on the PDF?)

How would I do the same with PHP?

As you can see here http://api.itextpdf.com/itext/com/itextpdf/text/pdf/PdfStamper.html the documentation says, it gets the layers in a PDF document. So I think it gets all the layers in a PDF document.

Then it loops through all the layers, setting their visibility to false, which hides them.

PS. The more you say about the minuses, the more you are going to get I guess ;)