0
using (GhostscriptRasterizer rasterizer = new GhostscriptRasterizer())
        {
                byte[] buffer = sideOne;
                MemoryStream ms = new MemoryStream(buffer);

                GhostscriptVersionInfo gvi = 
                            Ghostscript.NET.GhostscriptVersionInfo.GetLastInstalledVersion();

                rasterizer.Open(ms, gvi, true);

                for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++)
                {
                    string pageFilePath = Path.Combine(filePath, "Page-" + Guid.NewGuid().ToString() 
                    + ".Jpg");

                    var img = rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber);
                    img.Save(pageFilePath, ImageFormat.Jpeg);
                    using (System.Drawing.Image image = System.Drawing.Image.FromFile(pageFilePath))
                    {
                        using (MemoryStream m = new MemoryStream())
                    {
                        image.Save(m, image.RawFormat);
                        imageBytes = m.ToArray();
                        image.Dispose();
                        File.Delete(pageFilePath);
                    }
                }
            }
            rasterizer.Close();
        }
        

我们正在使用 Ghostscript Rasterizer 将 pdf 转换为 jpg 但对于少数图像,转换后的 jpg 正在擦除带有黑色标记的数据,如上面的屏幕截图所示,它与 Ghostscript 相关还是我们需要添加过滤器屏蔽数据

4

0 回答 0