我正在將 PDF 頁面轉換為影像,并且作業正常,我遇到的問題是它遺漏了 PDF 頁面上的評論或注釋。
當我使用 TIFF 格式時,它會保留它們,但是當我輸出到 PNG 時它會洗掉它們。
我怎樣才能把它們留在里面?
這是我用來轉換PDF的代碼:
function Convert-pdf {
param (
$PDF_Output, # Output path where converted PDF files will be stored
$path_to_pdf,
$PNG_Output # Output path where the PNG files will be saved
)
#Path to your Ghostscript EXE
$tool = 'C:\Program Files\gs\gs9.55.0\bin\gswin64c.exe'
$pdf = get-item $path_to_pdf
$png = $PNG_Output $pdf.BaseName "d" ".png"
if(test-path $png)
{
"png file already exists " $png
}
else
{
'Processing ' $pdf.Name
$param = "-sOutputFile=$png"
& $tool -q -dNOPAUSE -sDEVICE=png256 $param -r300 $pdf.FullName -c quit
}
Move-Item $pdf $PDF_Output
return $png
}
當我更改png256為tiff64nc它時,將在 PDF 上顯示注釋,否則不顯示它們。
編輯:我使用的是 GS 版本 9.55.0
這是我正在通過代碼提交的 pdf 的示例影像:

這是我得到的輸出:

如果你想自己測驗,這里是檔案:

因此,要獲得 256 種最大顏色,您需要使用 shell path\variables 的 3 行,并注意多頁 %d 值。
mutool draw -o "out-draw.png" -r 300 "69846382 annots not printing in GS png.pdf"
mutool draw -o "out-draw.pdf" "out-draw.png"
gswin64c -o "GSout256.png" -sDEVICE=png256 -r300 "out-draw.pdf"
并且由于通用格式處理類似于 PS 圖形,因此分兩步使用可以得到更快的結果。
mutool draw -o "out-draw.ps" -r 300 "69846382 annots not printing in GS png.pdf"
gswin64c -o "GSout256.png" -sDEVICE=png256 -r300 "out-draw.ps"
However the result of double image in-out processes was "Moire" than desired
, which I should have expected. Whichever method I used to improve the result it was not an even tone
thus I suspect even if the annotations were good the result would not equal expectation, that is not just Ghostscript, I get similar results saving as 256 colour output from MSpaint
etc. in effect its colour "dithering".
Also I tried without success to pipe one into another since GS should input piped data, and MuTool can output to pipe, but hit problems, most probably due to me corrupting GS by testing different calls (beware accidentally overwriting the exe) I dropped trying, as we see, it seemed not worth chasing in this case.
Finally with my trials for the safest shortest command we are currently left with mutool 1023 colours that would need another command line tool to drop those to 8 bit per pixel colours. 
mutool draw -o"out.png" -r 300 "69846382 annots not printing in GS png.pdf"
irfanview / gimp / other image converter
The alternative is to use a graphics package that can read pdf and output 8 bpp without dithering for a result much like this try right click to download 
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/354884.html
下一篇:pdf-lib使用什么顏色格式?
