首页 新闻 会员 周边

ghostscript 将ps转pdf时文件整体被缩放问题

0
悬赏园豆:20 [待解决问题]

转换命令:
gswin64c.exe -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=11.ps 11.pdf

文档原内容:

转换日志:

转换结果:

我一直以为是驱动上传的ps文件内容有问题,知道我在linux上预览了ps文件,发现是正常的,通过工具转为pdf后就不正常。但该工具我用了很久了,从未出现过该问题。

ps文件内容(中间内容部分太长了省略):
%-12345X@PJL JOB
@PJL COMMENT
@PJL SET USERNAME = "JH-Rent"
@PJL SET KMCOETYPE=2
@PJL SET DRIVERJOBID = "A029422AB60B0108080E3500E0"
@PJL SET STRINGCODESET = UTF8
@PJL SET JOBNAME = "safeG的SQL.txt"
@PJL SET KMDRIVER=ON
@PJL SET HOLD = OFF
@PJL SET BOXHOLDTYPE = PUBLIC
@PJL SET KMCERTSIMPLEAUTHREQ = OFF
@PJL SET QTY = 1
@PJL SET ORIENTATION = PORTRAIT
@PJL SET BINDING = LEFT
@PJL SET FINISH = NONE
@PJL SET FOLDING = OFF
@PJL SET OUTBIN = DEFAULT
@PJL SET EDGEMATCHING = FINISH
@PJL SET PUNCH = OFF
@PJL SET JOBOFFSET = OFF
@PJL SET OHPINTERLEAVE = NONE
@PJL SET FRONTCOVERMODE = NONE
@PJL SET BACKCOVERMODE = NONE
@PJL SET PIFRONT = OFF
@PJL SET PIBACK = OFF
@PJL SET PAPER = A4
@PJL SET LAYOUT = NORMAL
@PJL SET CHAPTERMODE = OFF
@PJL SET IMAGESHIFT = OFF
@PJL SET JIMONMODE = OFF
@PJL SET DTSTPMODE = OFF
@PJL SET PAGESTAMP = "NONE,1,1"
@PJL SET HFSTPMODE = OFF
@PJL SET TONERSAVE = OFF
@PJL SET POINT4CHARACTER = OFF
@PJL ENTER LANGUAGE = POSTSCRIPT
%!PS-Adobe-3.0
%%Title: (safeG\265\304SQL.txt)
%%Creator: PScript5.dll Version 5.2.2
%%CreationDate: 1/8/2024 16:14:53
%%For: JH-Rent
%%BoundingBox: (atend)
%%DocumentNeededResources: (atend)
%%DocumentSuppliedResources: (atend)
%%DocumentData: Clean7Bit
%%TargetDevice: (UPD) (3010.01) 1
%%LanguageLevel: 3
%%EndComments

%%BeginDefaults
%%ViewingOrientation: 1 0 0 1
%%EndDefaults

%%BeginProlog
%%BeginResource: file Pscript_WinNT_ErrorHandler 5.0 0
/currentpacking where{pop/oldpack currentpacking def/setpacking where{pop false
setpacking}if}if/$brkpage 64 dict def $brkpage begin/prnt{dup type/stringtype
ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def currentpoint/toy exch
def/tox exch def 1 setgray newpath tox toy 2 sub moveto 0 ty rlineto tx 0
rlineto 0 ty neg rlineto closepath fill tox toy moveto 0 setgray show}bind def
/nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def/{/cp 0 def
typeprint nl}def/typeprint{dup type exec}readonly def/lmargin 72 def/rmargin 72
def/tprint{dup length cp add rmargin gt{nl/cp 0 def}if dup length cp add/cp
exch def prnt}readonly def/cvsprint{=string cvs tprint( )tprint}readonly def
/integertype{cvsprint}readonly def/realtype{cvsprint}readonly def/booleantype
{cvsprint}readonly def/operatortype{(--)tprint =string cvs tprint(-- )tprint}
readonly def/marktype{pop(-mark- )tprint}readonly def/dicttype{pop
(-dictionary- )tprint}readonly def/nulltype{pop(-null- )tprint}readonly def
/filetype{pop(-filestream- )tprint}readonly def/savetype{pop(-savelevel- )
tprint}readonly def/fonttype{pop(-fontid- )tprint}readonly def/nametype{dup
xcheck not{(/)tprint}if cvsprint}readonly def/stringtype{dup rcheck{(()tprint
tprint())tprint}{pop(-string- )tprint}ifelse}readonly def/arraytype{dup rcheck
{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}forall(])
tprint}ifelse}{pop(-array- )tprint}ifelse}readonly def/packedarraytype{dup
rcheck{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}
forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse}readonly def/courier
/Courier findfont 10 scalefont def end errordict/handleerror{systemdict begin
$error begin $brkpage begin newerror{/newerror false store vmstatus pop pop 0
ne{grestoreall}if errorname(VMerror)ne{showpage}if initgraphics courier setfont
lmargin 720 moveto errorname(VMerror)eq{userdict/ehsave known{clear userdict
/ehsave get restore 2 vmreclaim}if vmstatus exch pop exch pop PrtVMMsg}{
(ERROR: )prnt errorname prnt nl(OFFENDING COMMAND: )prnt/command load prnt
$error/ostack known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{
}
repeat}if}ifelse systemdict/showpage get exec(%%[ Error: )print errorname
=print(; OffendingCommand: )print/command load =print( ]%%)= flush}if end end
end}dup 0 systemdict put dup 4 $brkpage put bind readonly put/currentpacking
where{pop/setpacking where{pop oldpack setpacking}if}if
%%EndResource
userdict /Pscript_WinNT_Incr 230 dict dup begin put
%%BeginResource: file Pscript_FatalError 5.0 0
userdict begin/FatalErrorIf{{initgraphics findfont 1 index 0 eq{exch pop}{dup
length dict begin{1 index/FID ne{def}{pop pop}ifelse}forall/Encoding
{ISOLatin1Encoding}stopped{StandardEncoding}if def currentdict end
/ErrFont-Latin1 exch definefont}ifelse exch scalefont setfont counttomark 3 div
cvi{moveto show}repeat showpage quit}{cleartomark}ifelse}bind def end
%%EndResource
userdict begin/PrtVMMsg{vmstatus exch sub exch pop gt{[
(This job requires more memory than is available in this printer.)100 500
(Try one or more of the following, and then print again:)100 485
(For the output format, choose Optimize For Portability.)115 470
(In the Device Settings page, make sure the Available PostScript Memory is accurate.)
115 455(Reduce the number of fonts in the document.)115 440
(Print the document in parts.)115 425 12/Times-Roman[/STSong-Light--GBK-EUC-H
dup{findfont}stopped{cleartomark}{/FontName get eq{pop cleartomark[
<b8c3cec4bcfed0e8d2aad3c3b5c4c4dab4e6ccabb6e0a1a3c4fabfc9d2d4cad4d3c3c8e7cfc2b5
c4b7bdb7a8d4d9b4f2d3a1a3ba>100 500<d4daa1b0506f7374536372697074a1b1b6d4bbb0bf
f2a3acd1a1d4f1a1b0506f7374536372697074a3a8b6d4b1e3d0afcabd41445343b5c4d3c5bbafa
3a9a1b1a1a3>115 485<d4daa1b0c9e8b1b8d1a1cfeea1b1b6d4bbb0bff2a3aca1b0bfc9d3c3b
4f2d3a1bbfac4dab4e6a1b1b5c4d6b5cac7beabc8b7b5c4a1a3>115 470<d4dacec4bcfed6d0c
9d9d3c3bcb8d6d6d7d6cce5a1a3>115 455<b5a5b6c0b4f2d3a1b8c3cec4bcfeb5c4b2bbcdacb
2bfb7d6bbf2d2b3a1a3>115 440 10 0/STSong-Light--GBK-EUC-H}{cleartomark}ifelse}
ifelse showpage(%%[ PrinterError: Low Printer VM ]%%)= true FatalErrorIf}if}
bind def end version cvi 2016 ge{/VM?{pop}bind def}{/VM? userdict/PrtVMMsg get
def}ifelse
105000 VM?
LH
(%%[Page: 1]%%) =
%%PageTrailer
....中间省略
%%Trailer
%%DocumentNeededResources:
%%+ font Arial-BoldMT
%%+ font ArialMT
%%DocumentSuppliedResources:
%%+ procset Pscript_WinNT_ErrorHandler 5.0 0
%%+ procset Pscript_FatalError 5.0 0
%%+ procset Pscript_Win_Basic 5.0 0
%%+ procset Pscript_Win_Utils_L2 5.0 0
%%+ procset Pscript_Win_GdiObject 5.0 0
%%+ procset Pscript_Win_GdiObject_L3 5.0 0
%%+ procset Pscript_Text 5.0 0
%%+ procset Pscript_Encoding256 5.0 0
%%+ procset Pscript_Win_Euro_L2 5.0 0
%%+ procset Pscript_T42Hdr 5.0 0
%%+ procset Pscript_CMap_FF 5.0 0
%%+ procset Pscript_TextBold 5.0 0
Pscript_WinNT_Incr dup /terminate get exec
ehsave restore
(%%[LastPage]%%) =
%%EOF
%-12345X@PJL EOJ
%-12345X

玩屎的猪的主页 玩屎的猪 | 初学一级 | 园豆:59
提问于:2024-01-08 16:35
< >
分享
所有回答(3)
0

加上参数-dPDFSETTINGS=/ebook ,似乎能解决问题,目前不知道是否有其他影响

玩屎的猪 | 园豆:59 (初学一级) | 2024-01-08 17:04
0

看起来你的PS文件中有一些打印机相关的命令(PJL命令),这可能导致Ghostscript在处理时产生问题。尝试将这些命令从PS文件中去除,只保留PostScript语言的部分。

你可以使用文本编辑器手动去除或编写脚本来处理。以下是一个简单的Python脚本示例,可以尝试去除PJL命令:

python

input_file = 'your_input.ps'
output_file = 'output.ps'

with open(input_file, 'r', encoding='utf-8') as infile:
ps_content = infile.read()

去除PJL命令

ps_content = ps_content.split('%%EndComments')[1]

with open(output_file, 'w', encoding='utf-8') as outfile:
outfile.write(ps_content)
将你的PS文件保存为your_input.ps,然后运行上述脚本,它将生成一个新的PS文件output.ps,其中已经去除了PJL命令。接下来,尝试使用Ghostscript将新生成的PS文件转换为PDF。

如果这样仍然没有解决问题,可以考虑检查Ghostscript的版本,可能需要更新到最新版本以获得更好的兼容性。

Technologyforgood | 园豆:6468 (大侠五级) | 2024-01-08 18:42
0

Make sure the input PS file is not corrupted or contains errors. Sometimes PS files may not be perfect and cause conversion problems. Suika game

sarausa | 园豆:208 (菜鸟二级) | 2024-04-17 12:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册