ArtifexSoftware / Ghostscript.NET

Ghostscript.NET - managed wrapper around the Ghostscript library (32-bit & 64-bit)
https://ghostscript.com
GNU Affero General Public License v3.0
395 stars 152 forks source link

Transparency is not respected when rendering PDFs #60

Closed benj2240 closed 3 years ago

benj2240 commented 5 years ago

https://github.com/jhabjan/Ghostscript.NET/blob/49a233f888eff8d3ac67786a602c5fe40b0da675/Ghostscript.NET/Viewer/FormatHandlers/GhostscriptViewerPdfFormatHandler.cs#L274

This line causes incorrect handling of PDFs with embedded transparent images.

Code that determines whether transparency is required on a given page is included in the procedure pdfshowpage_setpage. I'm not clear on what else that procedure does, but the rest of it might be important too.

Unless there is a specific reason that pdfshowpage_setpage is being omitted, it should be included here. Alternatively, this line could be simplified to

this.Execute("Page pdfshowpage");

... which calls pdfshowpage_init, pdfshowpage_setpage, and pdfshowpage_finish in succession (and has done so since at least 2007 for Ghostscript 8.56, and likely earlier).

Attached is an example of a PDF with a transparent image. Currently it is displayed as a black box on a gray background. It should be displayed as the word "hello", in black text on a gray background.

hellopng.pdf

jhabjan commented 5 years ago

Good finding, thanks. I will include this in next release.

zhjmao commented 4 years ago

by using `

this.Execute("Page pdfshowpage");

` transparent image works fine

jhabjan commented 3 years ago

Fixed in today's v.1.2.2. release.