C# AbcPdf pdf到gif转换,保持透明
我需要将PDF转换成透明的GIF格式。我在上找到了一些代码示例,但结果与预期不符。共同的问题是失去透明度 我尝试的代码如下:C# AbcPdf pdf到gif转换,保持透明,c#,pdf,gif,abcpdf,abcpdf9,C#,Pdf,Gif,Abcpdf,Abcpdf9,我需要将PDF转换成透明的GIF格式。我在上找到了一些代码示例,但结果与预期不符。共同的问题是失去透明度 我尝试的代码如下: using (var doc = new Doc()) { doc.Read(source); doc.Rendering.SaveAlpha = true; // the following lines from the official site. // And this
using (var doc = new Doc()) {
doc.Read(source);
doc.Rendering.SaveAlpha = true;
// the following lines from the official site.
// And this is showing blue background if I set this.
// But I don't need this blue background.
// Do not set anything special won't give good result.
//doc.Color.SetRgb(0, 0, 255); // blue background ...
//doc.FillRect(); // ... so you can see transparency
doc.Rendering.Save(destination);
doc.Clear();
}
如果有人对此有经验,请帮助。谢谢Rendering.SaveAlpha属性不适用于GIF GIF文件中的颜色定义存储在选项板中,而不是作为通道。调色板最多可包含256种颜色,包括一种设置为透明的颜色。与使用alpha通道不同,没有透明度。每个像素要么是不透明的颜色,要么是透明的
要保留alpha通道,您需要渲染为其他格式,如PNG、BMP、TIFF(灰度、RGB和CMYK)或Photoshop PSD。如果结果看起来不错,可以尝试将其转换为透明GIF,但我希望您会发现一些透明信息将丢失。这是不可避免的。我没有把注意力集中在AbcPdf上。我可能需要转换任何其他工具或库。