dongsonghen9931 2011-11-24 05:32
浏览 39
已采纳

这个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?

  • 写回答

1条回答 默认 最新

  • dongwen5351 2011-11-24 06:03
    关注

    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 ;)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题