Closed GoogleCodeExporter closed 8 years ago
Thank you for submitting this bug report.
Please note that pdfsizeopt is not supported on Windows at all, so don't expect
that it works nicely out-of-the-box -- but you may need to do some manual
changes and workarounds.
Nevertheless, thank you for submitting the bug report, it's good to know what
the problems are. Maybe someone will volunteer to solve them in the future.
My first suggestion would be that you should run
python -c "import os; os.system('gs')"
If this one doesn't work, but the command
gs
works, then this is most likely a bug or misconfiguration in your Windows or in
your Python distribution -- and not a bug in pdfsizeopt. So please report this
bug to whoever you got Python for Windows from.
If this simple command works, then please reply to this issue, because then
there is a bug in pdfsizeopt.
In the meantime, you can replace gs in pdfsizeopt.py with the full path to
gs.exe, like C:\\Program Files\\gs.exe . Please note that you might need double
backslashes in the pathname.
Since I'm not a Windows expert, and pdfsizeopt is officially not supported
Original comment by pts...@gmail.com
on 28 Jun 2011 at 3:28
Try "gswin32c" if "gs" doesn't work. This is the console-mode version of gs.
Original comment by lev.bishop
on 28 Jun 2011 at 4:27
First of all, thank you for your quick answers.
Here ist the output of the first proposal:
python -c "import os; os.system('gs')"
gives:
S:\XXX-2011>python -c "import os; os.system('gs')"
GPL Ghostscript 9.02 (2011-03-30)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>^CTraceback (most recent call last):
File "<string>", line 1, in <module>
KeyboardInterrupt
I terminated GS using Ctrl-C. And GS works:
S:\XXX-2011>gs
GPL Ghostscript 9.02 (2011-03-30)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>^C
Could you tell me, where to replace "gs" in pdfsizeopt.py with the full path as
you suggested? I understand your suggestion, but no python, so I failed to find
the line doing a word search for "gs" in Emacs: it's used often.
Thanks again,
Regards,
Alexander
Original comment by cookie...@web.de
on 28 Jun 2011 at 5:59
What does the following command print?
python -c "import os; os.system('gs -dBATCH -dNODISPLAY')"
Does the following solve your problem? What does it print?
python pdfsizeopt.py Beispiel.pdf
Search for GetGsCommand in pdfsizeopt.py, and modify it like this:
def GetGsCommand():
return r'"C:\Program Files\gs.exe"'
Original comment by pts...@gmail.com
on 28 Jun 2011 at 6:11
Hey, you are fast.
S:\XXX-2011>python -c "import os; os.system('gs -dBATCH -dNODISPLAY')"
GPL Ghostscript 9.02 (2011-03-30)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
And:
S:\XXX-2011>python pdfsizeopt.py Beispiel.pdf
python: can't open file 'pdfsizeopt.py': [Errno 2] No such file or directory
Then I renamed pdfsizeopt.py to pdfsizeopt-w.py and changed
def GetGsCommand():
"""Return shell command-line prefix for running Ghostscript (gs)."""
return r'"C:\Program Files\gs.exe"'
to
def GetGsCommand():
"""Return shell command-line prefix for running Ghostscript (gs)."""
return r'"C:\Programme\gs\gs9.02\bin\gswin32c.exe"'
And now it works. However, can I somewhere add the path to multivalent as well?
Because:
error: Multivalent.jar not found. Make sure it is on the $PATH, or it is one of
the files on the $CLASSPATH.
Traceback (most recent call last):
File "C:\Programme\pdfsizeopt\pdfsizeopt-w.py", line 6953, in <module>
main(sys.argv)
File "C:\Programme\pdfsizeopt\pdfsizeopt-w.py", line 6945, in main
do_generate_xref_stream=do_generate_xref_stream)
File "C:\Programme\pdfsizeopt\pdfsizeopt-w.py", line 6701, in SaveWithMultival
ent
assert 0, 'Multivalent.jar not found, see above'
AssertionError: Multivalent.jar not found, see above
Multivalent.jar is stored in the same folder like pdfsizeopt.py.
On my Linux-machine I get other trouble, but it is often easier to find the
source.
Thank you for your much appreciated help,
Alexander
Original comment by cookie...@web.de
on 28 Jun 2011 at 6:50
Thank you for the detailed bug report. Based on the information you provided I
could identify a bug in pdfsizeopt, and I've fixed the bug in r162. (The bug
was that pdfsizeopt always used ":" instead of os.pathsep.)
Please download the newest pdfsizeopt.py (with size 278828 bytes), rename
gs.exe back to gswin32c.exe, and try again:
pdfsizeopt.py Beispiel.pdf
It should work now. If it doesn't work, please reply to this issue, and include
what it prints.
Original comment by pts...@gmail.com
on 28 Jun 2011 at 7:39
Two weeks ago I changed from MikTeX 2.9 to texlive 2010. To my surprise
pdfsizeopt had less difficulties with pdfs produced by the latter.
Something happend I do not understand, now: I've got two pdfsizeopt-versions:
1. pdfsizeopt-w.py, with full path to gswin32c.exe
2. pdfsizeopt.py, r163
S:\XXX-2011>pdfsizeopt.py Beispiel.pdf
info: This is pdfsizeopt.py rUNKNOWN size=278828.
info: loading PDF from: Beispiel.pdf
info: loaded PDF of 440432 bytes
info: found 45 obj offsets and 1 obj streams in xref stream
info: separated to 43 objs + xref + trailer
info: found 6 Type1 fonts loaded
info: writing Type1CConverter (408687 font bytes) to: pso.conv.tmp.ps
info: executing Type1CConverter with Ghostscript: gswin32c -q -dNOPAUSE -dBATCH
-sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dColorConversionStrategy=/LeaveColorUn
changed -sOutputFile=pso.conv.tmp.pdf -f pso.conv.tmp.ps
Type1CConverter: using interpreter GPL Ghostscript 902 20110330
Type1CConverter: converting font /TKFQHN+LinBiolinumB to /Obj0000000032
Type1CConverter: converting font /XTDEAW+LinBiolinum to /Obj0000000034
Type1CConverter: converting font /BYNZDK+LinBiolinumI to /Obj0000000036
Type1CConverter: converting font /ZBISBW+LinLibertineB to /Obj0000000038
Type1CConverter: converting font /JVGWIF+LinLibertine to /Obj0000000040
Type1CConverter: converting font /MKHCTZ+LMMathSymbols8-Regular to /Obj000000004
2
Type1CConverter: all OK
info: loading PDF from: pso.conv.tmp.pdf
info: loaded PDF of 31445 bytes
info: separated to 30 objs + xref + trailer
info: found 6 fonts in GS output
info: optimized total Type1 font size 408755 to Type1C font size 22525 (6%)
info: optimized Type1 font XObject 32,31: new size=2671 (4%)
info: optimized Type1 font XObject 34,33: new size=6710 (8%)
info: optimized Type1 font XObject 36,35: new size=3447 (6%)
info: optimized Type1 font XObject 38,37: new size=2472 (3%)
info: optimized Type1 font XObject 40,39: new size=8618 (8%)
info: optimized Type1 font XObject 42,41: new size=658 (25%)
info: found 6 Type1C fonts loaded
info: writing Type1CParser (22401 font bytes) to: pso.conv.parse.tmp.ps
info: executing Type1CParser with Ghostscript: gswin32c -q -dNOPAUSE -dBATCH -sD
EVICE=nullpage -sDataFile=pso.conv.parsedata.tmp.ps -f pso.conv.parse.tmp.ps
Type1CParser: using interpreter GPL Ghostscript 902 20110330
Type1CParser: all OK
info: parsed 6 Type1C fonts
info: will optimize image XObject 1; orig width=2741 height=459 colorspace=/Inde
xed/DeviceRGB bpc=8 filter=/FlateDecode dp=1 size=21935 gs_device=png16m
info: saving PNG to pso.conv-1.parse.png
info: written 21739 bytes to PNG
info: optimizing 1 images of 21935 bytes in total
info: executing image optimizer sam2p_np: sam2p -pdf:2 -c zip:1:9 -s Gray1:Index
ed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:stop -- pso
.conv-1.parse.png pso.conv-1.sam2p-np.pdf
This is sam2p v0.48.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: writeTTT: using template: p02
sam2p: Notice: applyProfile: applied OutputRule #9
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-np.pdf"
Success.
info: sam2p_np failed, status=0x1
Traceback (most recent call last):
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 6960, in <module>
main(sys.argv)
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 6943, in main
pdf.OptimizeImages(use_pngout=use_pngout, use_jbig2=use_jbig2)
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 5675, in OptimizeImages
cmd_name='sam2p_np'))
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 5154, in ConvertImage
assert 0, '%s failed (status)' % cmd_name
AssertionError: sam2p_np failed (status)
So sam2p_np fails.
I tried in vain:
S:\XXX-2011>pdfsizeopt.py --use-sam2p=false Beispiel.pdf
info: This is pdfsizeopt.py rUNKNOWN size=278828.
error: in command line: option --use-sam2p not recognized
For comparison, see what happens using the pdfsizeopt-w.py created yesterday:
S:\XXX-2011>pdfsizeopt-w.py Beispiel.pdf
info: This is pdfsizeopt-w.py rNone size=285538.
info: loading PDF from: Beispiel.pdf
info: loaded PDF of 440432 bytes
info: found 45 obj offsets and 1 obj streams in xref stream
info: separated to 43 objs + xref + trailer
info: found 6 Type1 fonts loaded
info: writing Type1CConverter (408687 font bytes) to: pso.conv.tmp.ps
info: executing Type1CConverter with Ghostscript: "C:\Programme\gs\gs9.02\bin\gs
win32c.exe" -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dColo
rConversionStrategy=/LeaveColorUnchanged -sOutputFile=pso.conv.tmp.pdf -f pso.co
nv.tmp.ps
Type1CConverter: using interpreter GPL Ghostscript 902 20110330
Type1CConverter: converting font /TKFQHN+LinBiolinumB to /Obj0000000032
Type1CConverter: converting font /XTDEAW+LinBiolinum to /Obj0000000034
Type1CConverter: converting font /BYNZDK+LinBiolinumI to /Obj0000000036
Type1CConverter: converting font /ZBISBW+LinLibertineB to /Obj0000000038
Type1CConverter: converting font /JVGWIF+LinLibertine to /Obj0000000040
Type1CConverter: converting font /MKHCTZ+LMMathSymbols8-Regular to /Obj000000004
2
Type1CConverter: all OK
info: loading PDF from: pso.conv.tmp.pdf
info: loaded PDF of 31451 bytes
info: separated to 30 objs + xref + trailer
info: found 6 fonts in GS output
info: optimized total Type1 font size 408755 to Type1C font size 22525 (6%)
info: optimized Type1 font XObject 32,31: new size=2671 (4%)
info: optimized Type1 font XObject 34,33: new size=6710 (8%)
info: optimized Type1 font XObject 36,35: new size=3447 (6%)
info: optimized Type1 font XObject 38,37: new size=2472 (3%)
info: optimized Type1 font XObject 40,39: new size=8618 (8%)
info: optimized Type1 font XObject 42,41: new size=658 (25%)
info: found 6 Type1C fonts loaded
info: writing Type1CParser (22401 font bytes) to: pso.conv.parse.tmp.ps
info: executing Type1CParser with Ghostscript: "C:\Programme\gs\gs9.02\bin\gswin
32c.exe" -q -dNOPAUSE -dBATCH -sDEVICE=nullpage -sDataFile=pso.conv.parsedata.tm
p.ps -f pso.conv.parse.tmp.ps
Type1CParser: using interpreter GPL Ghostscript 902 20110330
Type1CParser: all OK
info: parsed 6 Type1C fonts
info: will optimize image XObject 1; orig width=2741 height=459 colorspace=/Inde
xed/DeviceRGB bpc=8 filter=/FlateDecode dp=1 size=21935 gs_device=png16m
info: saving PNG to pso.conv-1.parse.png
info: written 21739 bytes to PNG
info: optimizing 1 images of 21935 bytes in total
info: executing image optimizer sam2p_np: sam2p -pdf:2 -c zip:1:9 -s Gray1:Index
ed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:stop -- pso
.conv-1.parse.png pso.conv-1.sam2p-np.pdf
This is sam2p v0.45.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: writeTTT: using template: p02
sam2p: Notice: applyProfile: applied OutputRule #9
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-np.pdf"
Success.
info: loading image from: pso.conv-1.sam2p-np.pdf
info: loading PDF from: pso.conv-1.sam2p-np.pdf
info: loaded PDF of 25916 bytes
info: separated to 5 objs + xref + trailer
info: loaded PNG IDAT of 24987 bytes and PLTE of 99 bytes
info: executing image optimizer sam2p_pr: sam2p -c zip:15:9 -- pso.conv-1.parse.
png pso.conv-1.sam2p-pr.png
This is sam2p v0.45.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: applyProfile: applied OutputRule #12
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-pr.png"
Success.
info: loading image from: pso.conv-1.sam2p-pr.png
info: loaded PNG IDAT of 30215 bytes and PLTE of 99 bytes
info: executing image optimizer pngout: pngout pso.conv-1.parse.png pso.conv-1.p
ngout.png
In: 21739 bytes pso.conv-1.parse.png /c3 /f0 /d8
Out: 21531 bytes pso.conv-1.pngout.png /c3 /f0 /d8, 33 colors
Chg: -208 bytes ( 99% of original)
info: loading image from: pso.conv-1.pngout.png
info: loaded PNG IDAT of 21363 bytes and PLTE of 99 bytes
info: optimized image XObject 1 file_name=pso.conv-1.pngout.png size=21697 (99%)
methods=pngout:21697,#orig:21852,parse:21905,sam2p_np:25279,sam2p_pr:30549
info: saved 155 bytes (1%) on optimizable images
info: eliminated 1 unused objs in 1 classes
info: writing Multivalent input PDF: pso.conv.mi.tmp.pdf
info: saving PDF with 42 objs to: pso.conv.mi.tmp.pdf
info: generated 58373 bytes (13%)
error: Multivalent.jar not found. Make sure it is on the $PATH, or it is one of
the files on the $CLASSPATH.
Traceback (most recent call last):
File "C:\Programme\pdfsizeopt\pdfsizeopt-w.py", line 6953, in <module>
main(sys.argv)
File "C:\Programme\pdfsizeopt\pdfsizeopt-w.py", line 6945, in main
do_generate_xref_stream=do_generate_xref_stream)
File "C:\Programme\pdfsizeopt\pdfsizeopt-w.py", line 6701, in SaveWithMultival
ent
assert 0, 'Multivalent.jar not found, see above'
AssertionError: Multivalent.jar not found, see above
I attach both versions of pdfsizeopt, just in case I made a mistake. My file
"Beispiel.pdf" contains a png-picture. If it helps you, I can create a more or
less similar file for upload.
Regards,
Alexander
Original comment by cookie...@web.de
on 29 Jun 2011 at 9:01
Attachments:
Yes, the pdfsizeopt.py of size 278828 is correct.
Hmm, that's indeed strange:
info: executing image optimizer sam2p_np: sam2p -pdf:2 -c zip:1:9 -s Gray1:Indexed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:stop -- pso.conv-1.parse.png pso.conv-1.sam2p-np.pdf
This is sam2p v0.48.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: writeTTT: using template: p02
sam2p: Notice: applyProfile: applied OutputRule #9
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-np.pdf"
Success.
info: sam2p_np failed, status=0x1
So sam2p succeeds (prints `Success.'), but pdfsizeopt detects that sam2p has
failed (status=0x1). The successful status would be 0.
In the meantime, try modifying line 5152 (`if status:') of pdfsizeop.py to:
if status and status > 1:
This might be a workaround to your problem.
Please attach an example .pdf file which causes problems, and please attach the
console output of pdfsizeopt.py.
Original comment by pts...@gmail.com
on 29 Jun 2011 at 12:37
Your workaround does it. If I try to compress the attached pdf, the console
lists:
U:\>pdfsizeopt.py Beispiel2.pdf
info: This is pdfsizeopt.py rUNKNOWN size=278843.
info: loading PDF from: Beispiel2.pdf
info: loaded PDF of 115275 bytes
info: found 17 obj offsets and 1 obj streams in xref stream
info: separated to 15 objs + xref + trailer
info: found 1 Type1 fonts loaded
info: writing Type1CConverter (100193 font bytes) to: pso.conv.tmp.ps
info: executing Type1CConverter with Ghostscript: gswin32c -q -dNOPAUSE -dBATCH
-sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dColorConversionStrategy=/LeaveColorUn
changed -sOutputFile=pso.conv.tmp.pdf -f pso.conv.tmp.ps
Type1CConverter: using interpreter GPL Ghostscript 902 20110330
Type1CConverter: converting font /JCPLAY+LinLibertine to /Obj0000000014
Type1CConverter: all OK
info: loading PDF from: pso.conv.tmp.pdf
info: loaded PDF of 9092 bytes
info: separated to 15 objs + xref + trailer
info: found 1 fonts in GS output
info: optimized total Type1 font size 100166 to Type1C font size 4912 (5%)
info: optimized Type1 font XObject 14,13: new size=5291 (5%)
info: found 1 Type1C fonts loaded
info: writing Type1CParser (4928 font bytes) to: pso.conv.parse.tmp.ps
info: executing Type1CParser with Ghostscript: gswin32c -q -dNOPAUSE -dBATCH -sD
EVICE=nullpage -sDataFile=pso.conv.parsedata.tmp.ps -f pso.conv.parse.tmp.ps
Type1CParser: using interpreter GPL Ghostscript 902 20110330
Type1CParser: all OK
info: parsed 1 Type1C fonts
info: will optimize image XObject 1; orig width=303 height=171 colorspace=/Devic
eRGB bpc=8 filter=/FlateDecode dp=1 size=12651 gs_device=png16m
info: saving PNG to pso.conv-1.parse.png
info: written 12450 bytes to PNG
info: optimizing 1 images of 12651 bytes in total
info: executing image optimizer sam2p_np: sam2p -pdf:2 -c zip:1:9 -s Gray1:Index
ed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:stop -- pso
.conv-1.parse.png pso.conv-1.sam2p-np.pdf
This is sam2p v0.48.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: writeTTT: using template: p02
sam2p: Notice: applyProfile: applied OutputRule #11
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-np.pdf"
Success.
info: loading image from: pso.conv-1.sam2p-np.pdf
info: loading PDF from: pso.conv-1.sam2p-np.pdf
info: loaded PDF of 7929 bytes
info: separated to 5 objs + xref + trailer
info: loaded PNG IDAT of 7221 bytes
info: executing image optimizer sam2p_pr: sam2p -c zip:15:9 -- pso.conv-1.parse.
png pso.conv-1.sam2p-pr.png
This is sam2p v0.48.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: applyProfile: applied OutputRule #14
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-pr.png"
Success.
info: loading image from: pso.conv-1.sam2p-pr.png
info: loaded PNG IDAT of 8961 bytes
info: executing image optimizer pngout: pngout pso.conv-1.parse.png pso.conv-1.p
ngout.png
In: 12450 bytes pso.conv-1.parse.png /c2 /f4
Out: 8563 bytes pso.conv-1.pngout.png /c2 /f4
Chg: -3887 bytes ( 68% of original)
info: loading image from: pso.conv-1.pngout.png
info: loaded PNG IDAT of 8506 bytes
info: optimized image XObject 1 file_name=pso.conv-1.sam2p-np.pdf size=7396 (58%
) methods=sam2p_np:7396,pngout:8731,sam2p_pr:9186,parse:12619,#orig:12651
info: saved 5255 bytes (42%) on optimizable images
info: writing Multivalent input PDF: pso.conv.mi.tmp.pdf
info: saving PDF with 15 objs to: pso.conv.mi.tmp.pdf
info: generated 15405 bytes (13%)
Traceback (most recent call last):
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 6960, in <module>
main(sys.argv)
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 6952, in main
do_generate_xref_stream=do_generate_xref_stream)
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 6707, in SaveWithMultivalen
t
assert ':' not in multivalent_jar # $CLASSPATH separator
AssertionError
U:\>
Should I repeat without the modified line 5152? And thank you again!
Regards,
Alexander
Original comment by cookie...@web.de
on 29 Jun 2011 at 2:13
Attachments:
In case you can fix the multivalent-error, pdfsizeopt.py would run on Windows
XP from my point of view "out of the box".
Wouldn't that be a good moment for a new release?
By the way, I wrote an article about pdfsizeopt on Markus Kohms' komascript.de
two weeks ago:
http://www.komascript.de/node/1477
I guess you understand German, don't you?
Regards,
Alexander
Original comment by cookie...@web.de
on 29 Jun 2011 at 2:52
The multivalent-error has been fixed in r164. Please retry. (You may have to
change `if status:' to `if status and status > 1:' again.
> Wouldn't that be a good moment for a new release?
Yes it would, but I'd like to fix the sam2p issue first.
Where did you get your sam2p.exe? Could you please attach your sam2p.exe to
this issue?
I think you have the wrong sam2p.exe, because version 0.48 has never been
released on Windows. If you are using a 3rd party sam2p.exe, not the original
one, that might cause problems, because the 3rd party might have introduced
bugs (which would make the `if status:' check in pdfsizeopt fail).
Original comment by pts...@gmail.com
on 29 Jun 2011 at 5:16
To avoid further confusion, I just made a new release of sam2p (0.49). Download
it for Windows from here:
http://sam2p.googlecode.com/files/sam2p-0.49-win32.zip
Original comment by pts...@gmail.com
on 29 Jun 2011 at 5:58
I did, but without success:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
U:\>pdfsizeopt.py Beispiel2.pdf
info: This is pdfsizeopt.py rUNKNOWN size=278835.
info: loading PDF from: Beispiel2.pdf
info: loaded PDF of 115275 bytes
info: found 17 obj offsets and 1 obj streams in xref stream
info: separated to 15 objs + xref + trailer
info: found 1 Type1 fonts loaded
info: writing Type1CConverter (100193 font bytes) to: pso.conv.tmp.ps
info: executing Type1CConverter with Ghostscript: gswin32c -q -dNOPAUSE -dBATCH
-sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dColorConversionStrategy=/LeaveColorUn
changed -sOutputFile=pso.conv.tmp.pdf -f pso.conv.tmp.ps
Type1CConverter: using interpreter GPL Ghostscript 902 20110330
Type1CConverter: converting font /JCPLAY+LinLibertine to /Obj0000000014
Type1CConverter: all OK
info: loading PDF from: pso.conv.tmp.pdf
info: loaded PDF of 9092 bytes
info: separated to 15 objs + xref + trailer
info: found 1 fonts in GS output
info: optimized total Type1 font size 100166 to Type1C font size 4912 (5%)
info: optimized Type1 font XObject 14,13: new size=5291 (5%)
info: found 1 Type1C fonts loaded
info: writing Type1CParser (4928 font bytes) to: pso.conv.parse.tmp.ps
info: executing Type1CParser with Ghostscript: gswin32c -q -dNOPAUSE -dBATCH -sD
EVICE=nullpage -sDataFile=pso.conv.parsedata.tmp.ps -f pso.conv.parse.tmp.ps
Type1CParser: using interpreter GPL Ghostscript 902 20110330
Type1CParser: all OK
info: parsed 1 Type1C fonts
info: will optimize image XObject 1; orig width=303 height=171 colorspace=/Devic
eRGB bpc=8 filter=/FlateDecode dp=1 size=12651 gs_device=png16m
info: saving PNG to pso.conv-1.parse.png
info: written 12450 bytes to PNG
info: optimizing 1 images of 12651 bytes in total
info: executing image optimizer sam2p_np: sam2p -pdf:2 -c zip:1:9 -s Gray1:Index
ed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:stop -- pso
.conv-1.parse.png pso.conv-1.sam2p-np.pdf
This is sam2p 0.49.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: writeTTT: using template: p02
sam2p: Notice: applyProfile: applied OutputRule #11
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-np.pdf"
Success.
info: sam2p_np failed, status=0x1
Traceback (most recent call last):
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 6960, in <module>
main(sys.argv)
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 6943, in main
pdf.OptimizeImages(use_pngout=use_pngout, use_jbig2=use_jbig2)
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 5675, in OptimizeImages
cmd_name='sam2p_np'))
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 5154, in ConvertImage
assert 0, '%s failed (status)' % cmd_name
AssertionError: sam2p_np failed (status)
U:\>
But if I change line 5152, I still geht an multivalent-error:
U:\>pdfsizeopt.py Beispiel2.pdf
info: This is pdfsizeopt.py rUNKNOWN size=278850.
info: loading PDF from: Beispiel2.pdf
info: loaded PDF of 115275 bytes
info: found 17 obj offsets and 1 obj streams in xref stream
info: separated to 15 objs + xref + trailer
info: found 1 Type1 fonts loaded
info: writing Type1CConverter (100193 font bytes) to: pso.conv.tmp.ps
info: executing Type1CConverter with Ghostscript: gswin32c -q -dNOPAUSE -dBATCH
-sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dColorConversionStrategy=/LeaveColorUn
changed -sOutputFile=pso.conv.tmp.pdf -f pso.conv.tmp.ps
Type1CConverter: using interpreter GPL Ghostscript 902 20110330
Type1CConverter: converting font /JCPLAY+LinLibertine to /Obj0000000014
Type1CConverter: all OK
info: loading PDF from: pso.conv.tmp.pdf
info: loaded PDF of 9092 bytes
info: separated to 15 objs + xref + trailer
info: found 1 fonts in GS output
info: optimized total Type1 font size 100166 to Type1C font size 4912 (5%)
info: optimized Type1 font XObject 14,13: new size=5291 (5%)
info: found 1 Type1C fonts loaded
info: writing Type1CParser (4928 font bytes) to: pso.conv.parse.tmp.ps
info: executing Type1CParser with Ghostscript: gswin32c -q -dNOPAUSE -dBATCH -sD
EVICE=nullpage -sDataFile=pso.conv.parsedata.tmp.ps -f pso.conv.parse.tmp.ps
Type1CParser: using interpreter GPL Ghostscript 902 20110330
Type1CParser: all OK
info: parsed 1 Type1C fonts
info: will optimize image XObject 1; orig width=303 height=171 colorspace=/Devic
eRGB bpc=8 filter=/FlateDecode dp=1 size=12651 gs_device=png16m
info: saving PNG to pso.conv-1.parse.png
info: written 12450 bytes to PNG
info: optimizing 1 images of 12651 bytes in total
info: executing image optimizer sam2p_np: sam2p -pdf:2 -c zip:1:9 -s Gray1:Index
ed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:stop -- pso
.conv-1.parse.png pso.conv-1.sam2p-np.pdf
This is sam2p 0.49.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: writeTTT: using template: p02
sam2p: Notice: applyProfile: applied OutputRule #11
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-np.pdf"
Success.
info: loading image from: pso.conv-1.sam2p-np.pdf
info: loading PDF from: pso.conv-1.sam2p-np.pdf
info: loaded PDF of 7929 bytes
info: separated to 5 objs + xref + trailer
info: loaded PNG IDAT of 7221 bytes
info: executing image optimizer sam2p_pr: sam2p -c zip:15:9 -- pso.conv-1.parse.
png pso.conv-1.sam2p-pr.png
This is sam2p 0.49.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: applyProfile: applied OutputRule #14
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-pr.png"
Success.
info: loading image from: pso.conv-1.sam2p-pr.png
info: loaded PNG IDAT of 8961 bytes
info: executing image optimizer pngout: pngout pso.conv-1.parse.png pso.conv-1.p
ngout.png
In: 12450 bytes pso.conv-1.parse.png /c2 /f4
Out: 8563 bytes pso.conv-1.pngout.png /c2 /f4
Chg: -3887 bytes ( 68% of original)
info: loading image from: pso.conv-1.pngout.png
info: loaded PNG IDAT of 8506 bytes
info: optimized image XObject 1 file_name=pso.conv-1.sam2p-np.pdf size=7396 (58%
) methods=sam2p_np:7396,pngout:8731,sam2p_pr:9186,parse:12619,#orig:12651
info: saved 5255 bytes (42%) on optimizable images
info: writing Multivalent input PDF: pso.conv.mi.tmp.pdf
info: saving PDF with 15 objs to: pso.conv.mi.tmp.pdf
info: generated 15405 bytes (13%)
info: executing Multivalent to optimize PDF: java -cp 'C:\Programme\pdfsizeopt/M
ultivalent.jar' tool.pdf.Compress -nopagepiece -noalt pso.conv.mi.tmp.pdf
Exception in thread "main" java.lang.NoClassDefFoundError: tool/pdf/Compress
Caused by: java.lang.ClassNotFoundException: tool.pdf.Compress
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: tool.pdf.Compress. Program will exit.
info: Multivalent failed, status=0x1
Traceback (most recent call last):
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 6960, in <module>
main(sys.argv)
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 6952, in main
do_generate_xref_stream=do_generate_xref_stream)
File "C:\Programme\pdfsizeopt\pdfsizeopt.py", line 6725, in SaveWithMultivalen
t
assert 0, 'Multivalent failed (status)'
AssertionError: Multivalent failed (status)
U:\>
Well, I took the version of multivalent you are offering, I tried another one
and a third one, but all in vane, it's like there were no tools.
This is weird. But meanwhile I'm writing a contract using Word and it is even
stranger.
I'm running a completly new installed Windows, by the way.
Regards,
Alexander
Original comment by cookie...@web.de
on 29 Jun 2011 at 6:38
About Multivalent: only
http://pdfsizeopt.googlecode.com/files/Multivalent20060102.jar works,
and it does contain tool/pdf/Compress . Please remove all other
Multivalent*.jar files from all of your hard drives before running
pdfsizeopt again.
Where did you get the instructions to use any other Multivalent.jar? I
think http://code.google.com/p/pdfsizeopt/wiki/InstallationInstructions
is clear where you should get Multivalent from.
Also I recommend trying pdfsizeopt on a different computer. Maybe your
computer has a bad Windows installation or a hardware defect.
Original comment by pts...@gmail.com
on 29 Jun 2011 at 7:21
The following information
info: executing Multivalent to optimize PDF: java -cp 'C:\Programme\pdfsizeopt/Multivalent.jar' tool.pdf.Compress -nopagepiece -noalt pso.conv.mi.tmp.pdf
you have provided helped me identify and fix a bug in pdfsizeopt.py. Please
download the newest version of pdfsizeopt.py, remove Multivalent.jar, and retry
with Multivalent20060102.jar in the same directory as pdfsizeopt.py .
Original comment by pts...@gmail.com
on 29 Jun 2011 at 7:37
Sorry, did not wish to annoy you. The output as printed above says:
info: executing Multivalent to optimize PDF: java -cp 'C:\Programme\pdfsizeopt/M
ultivalent.jar' tool.pdf.Compress -nopagepiece -noalt pso.conv.mi.tmp.pdf
So it is the file "Multivalent.jar" in that directory. I've been using your
version all the time, with the exceptions mentioned above.
I'll try on an other machine tomorrow evening here in the office.
Regards,
Alexander
Original comment by cookie...@web.de
on 29 Jun 2011 at 7:51
Please download and try the newest pdfsizeopt.py! You can try it on any
machine, you don't have to wait for another machine.
Original comment by pts...@gmail.com
on 29 Jun 2011 at 9:25
Based on the console logs you provided in this issue I could identify and fix a
bug in sam2p. Thank you for being patient and copying all the console outputs
here, helping me understand and fix multiple bugs.
The newest pdfsizeopt with the newest sam2p should work for you without
modifications. Please try again. First please remove all instances of
pdfsizeopt.py, sam2p.exe and Multivalent.jar from your computer. Then please
download these:
* http://sam2p.googlecode.com/files/sam2p-0.49-win32.zip
* http://pdfsizeopt.googlecode.com/files/Multivalent20060102.jar
* http://pdfsizeopt.googlecode.com/svn/trunk/pdfsizeopt.py (278997 bytes)
In the ZIP file sam2p-0.49-win32.zip please find sam2p.exe (135680 bytes) and
extract it to next to pdfsizeopt.py
Then run the command
pdfsizeopt.py Beispiel2.pdf
as usual. It should succeed now. Should it fail, please attach its console
output to this issue.
Original comment by pts...@gmail.com
on 29 Jun 2011 at 11:41
Yippee! It works! Thank you for your night shift!
For the record:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
U:\>pdfsizeopt.py Beispiel2.pdf
info: This is pdfsizeopt.py rUNKNOWN size=278997.
info: loading PDF from: Beispiel2.pdf
info: loaded PDF of 115275 bytes
info: found 17 obj offsets and 1 obj streams in xref stream
info: separated to 15 objs + xref + trailer
info: found 1 Type1 fonts loaded
info: writing Type1CConverter (100193 font bytes) to: pso.conv.tmp.ps
info: executing Type1CConverter with Ghostscript: gswin32c -q -dNOPAUSE -dBATCH
-sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dColorConversionStrategy=/LeaveColorUn
changed -sOutputFile=pso.conv.tmp.pdf -f pso.conv.tmp.ps
Type1CConverter: using interpreter GPL Ghostscript 902 20110330
Type1CConverter: converting font /JCPLAY+LinLibertine to /Obj0000000014
Type1CConverter: all OK
info: loading PDF from: pso.conv.tmp.pdf
info: loaded PDF of 9092 bytes
info: separated to 15 objs + xref + trailer
info: found 1 fonts in GS output
info: optimized total Type1 font size 100166 to Type1C font size 4912 (5%)
info: optimized Type1 font XObject 14,13: new size=5291 (5%)
info: found 1 Type1C fonts loaded
info: writing Type1CParser (4928 font bytes) to: pso.conv.parse.tmp.ps
info: executing Type1CParser with Ghostscript: gswin32c -q -dNOPAUSE -dBATCH -sD
EVICE=nullpage -sDataFile=pso.conv.parsedata.tmp.ps -f pso.conv.parse.tmp.ps
Type1CParser: using interpreter GPL Ghostscript 902 20110330
Type1CParser: all OK
info: parsed 1 Type1C fonts
info: will optimize image XObject 1; orig width=303 height=171 colorspace=/Devic
eRGB bpc=8 filter=/FlateDecode dp=1 size=12651 gs_device=png16m
info: saving PNG to pso.conv-1.parse.png
info: written 12450 bytes to PNG
info: optimizing 1 images of 12651 bytes in total
info: executing image optimizer sam2p_np: sam2p -pdf:2 -c zip:1:9 -s Gray1:Index
ed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:stop -- pso
.conv-1.parse.png pso.conv-1.sam2p-np.pdf
This is sam2p 0.49.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: writeTTT: using template: p02
sam2p: Notice: applyProfile: applied OutputRule #11
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-np.pdf"
Success.
info: loading image from: pso.conv-1.sam2p-np.pdf
info: loading PDF from: pso.conv-1.sam2p-np.pdf
info: loaded PDF of 7929 bytes
info: separated to 5 objs + xref + trailer
info: loaded PNG IDAT of 7221 bytes
info: executing image optimizer sam2p_pr: sam2p -c zip:15:9 -- pso.conv-1.parse.
png pso.conv-1.sam2p-pr.png
This is sam2p 0.49.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-1.parse.png"
sam2p: Notice: applyProfile: applied OutputRule #14
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-pr.png"
Success.
info: loading image from: pso.conv-1.sam2p-pr.png
info: loaded PNG IDAT of 8961 bytes
info: executing image optimizer pngout: pngout pso.conv-1.parse.png pso.conv-1.p
ngout.png
In: 12450 bytes pso.conv-1.parse.png /c2 /f4
Out: 8563 bytes pso.conv-1.pngout.png /c2 /f4
Chg: -3887 bytes ( 68% of original)
info: loading image from: pso.conv-1.pngout.png
info: loaded PNG IDAT of 8506 bytes
info: optimized image XObject 1 file_name=pso.conv-1.sam2p-np.pdf size=7396 (58%
) methods=sam2p_np:7396,pngout:8731,sam2p_pr:9186,parse:12619,#orig:12651
info: saved 5255 bytes (42%) on optimizable images
info: writing Multivalent input PDF: pso.conv.mi.tmp.pdf
info: saving PDF with 15 objs to: pso.conv.mi.tmp.pdf
info: generated 15405 bytes (13%)
info: executing Multivalent to optimize PDF: java -cp "C:\Programme\pdfsizeopt\M
ultivalent.jar" tool.pdf.Compress -nopagepiece -noalt pso.conv.mi.tmp.pdf
file:/U:/pso.conv.mi.tmp.pdf, 15405 bytes
PDF 1.5, producer=pdfTeX-1.40.11, creator=TeX
additional compression may be possible with:
-compact
=> new length = 15418, saved 0%, elapsed time = 0 sec
info: Multivalent generated pso.conv.mi.tmp-o.pdf of 15440 bytes (100%)
info: compressed xref stream from 34 to 151 bytes (444%)
info: optimized to 15340 bytes after Multivalent (99%)
info: saving PDF to: Beispiel2.psom.pdf
info: generated 15340 bytes (13%)
U:\>
I integrated pdfsizeopt into my .emacs:
;; pdfsizeopt.py zur Befehlsliste
(eval-after-load "tex"
'(add-to-list 'TeX-command-list
'("pdfsizeopt" "pdfsizeopt.py %s.pdf %s.pdf" TeX-run-command t t :help "Run
pdfsizeopt.py") t))
Using a viewer like SumatraPDF, I can compress pdfs without even closing the
viewer.
Regards,
Alexander
Original comment by cookie...@web.de
on 30 Jun 2011 at 9:16
Original issue reported on code.google.com by
cookie...@web.de
on 28 Jun 2011 at 3:03