Bug in pdftoraster filter
Hi,
I have integrated your filters in the CUPS package on Ubuntu and now we have a complete PDF printing workflow there:
https://www.linuxfoundation.org/en/OpenPrinting/PDF_as_Standard_Print_Job_Format
https://blueprints.launchpad.net/ubuntu/+spec/pdf-as-standard-print-job-format
Thank you again for your great work.
Unfortunately, your pdftoraster filter has a bug. It seems to output a broken CUPS Raster stream. The "SpliX" driver (a CUPS Raster driver for Samsung laser printers, http://splix.ap2c.org/, http://openprinting.org/show_driver.cgi?driver=splix2) produces black printouts or even crashes when your pdftoraster is used:
https://bugs.launchpad.net/ubuntu/+source/splix/+bug/261363
https://bugs.launchpad.net/ubuntu/+source/splix/+bug/268510
https://bugs.launchpad.net/ubuntu/+source/splix/+bug/269691
To check whether pdftoraster is really the culprit, I have written an alternative pdftoraster, a very simple shell script:
#!/bin/sh
set -e/usr/lib/cups/filter/cpdftocps "$@" | \
/usr/lib/cups/filter/pstoraster "$@"
cpdftocps is a filter which converts PDF to PostScript and injects PostScript commands from the PPD into the resulting PostScript according to the option settings. It is originally intended to support PostScript printers in the PDF workflow. You can download it here:
http://www.openprinting.org/download/printing/pdf-printing/cpdftocps
I have asked the reporters of the above-mentioned bugs to use this alternative filter and they told that when they use it the problems with "SpliX" disappear.
So I assume that something is broken with your pdftoraster driver. Can you check and fix this as soon as possible, as we are shortly before release of Ubuntu Intrepid and it would be great to not have to use a script which converts the PDF to PostScript to be able to get CUPS Raster data.
For investigating the problem, feel free to get in contact with the reporters of the three above-mentioned bug reports, by adding comments to the reports.
I have also tried the alternative of a Ghostscript-based pdftoraster driver where PDF is directly fed into Ghostscript, but it seems that there is a bug in the "cups" output device of Ghostscript. See
http://bugs.ghostscript.com/show_bug.cgi?id=690101
This problem does not occur when feeding PostScript into Ghostscript. Anyone who could help here is welcome, too.
Thank you in advance for your quick help.
Till
Thank you very much for the fixes. I will apply them to Intrepid in the next days and forward the SpliX fix upstream.
Till
Quoted 140 lines · Koji Otani
Hi
I'm Koji Otani.I've investigated this problem.
There are 2 problems in fact.
1. splix crashes
https://bugs.launchpad.net/ubuntu/+source/splix/+bug/261363
https://bugs.launchpad.net/ubuntu/+source/splix/+bug/268510
This happenes when page size is Letter.2. yield completely black pages
https://bugs.launchpad.net/ubuntu/+source/splix/+bug/269691*** CAUSE ***
1. splix crashes
This is cauesed by several filters' behaviors.
(1) pstopdf
pstopdf produces Only A4 size PDF even when Letter is specified. This behavior seems a bug, I think.
This is because no page size option is specified for ps2pdf.
(2) pdftopdf
pdftopdf doesn't change PDF page size in this case. So, the produced PDF is A4 size.
(3) pdftoraster
pdftoraster produces image which size is same as PDF page size. So, the produced image size is A4 size.
(4) splix
splix crashes when height of image size is larger than expected. In this case, input image size is A4 and expected image size is Letter. So, splix crashes.
This is a bug of splix.
On 64bits AMD, splix doesn't crash luckily although accessing wrong area.2. yield completely black pages
When color space is K, pdftoraster uses wrong paper color (Black). Images in PDF are reversed video.
And splix requires color space K.
This is a bug of psdtoraster.******** Solution *********
1. splix crashes
(1) Fix pstopdf to produce PDF has specified Page size.
Using pstops as cpdftocps, setpagedevice operators are passed to ps2pdf. Attached the patch.
(2) Fix splix not to crash.
Attached the patch.
This fix is optional in this case.
(3) Change pdftoraster to produce cups specified size image. Attached the patch.
In this case, this fix is not needed. But in other case this is needed. please apply this patch.(4) Change pdftopdf to produce cups specified size PDF. Attached the patch.
In this case, this fix is not needed. But in other case this is needed. please apply this patch.2. yield completely black pages
・Fix pdftoraster
Attached the patch. this is merged in solution 1-(3) patch.---------------
I have applied patches for pdftopdf, pdftoraster to the sourceforge jp repository.-------------------------
Koji OtaniFrom: Till Kamppeter <[email protected]>
Subject: Bug in pdftoraster filter
Date: Tue, 30 Sep 2008 15:48:56 +0200
Message-ID: <[email protected]>till.kamppeter> Hi,
till.kamppeter>
till.kamppeter> I have integrated your filters in the CUPS package on Ubuntu and now we till.kamppeter> have a complete PDF printing workflow there:
till.kamppeter>
till.kamppeter> https://www.linuxfoundation.org/en/OpenPrinting/PDF_as_Standard_Print_Job_Format
till.kamppeter> https://blueprints.launchpad.net/ubuntu/+spec/pdf-as-standard-print-job-format
till.kamppeter>
till.kamppeter> Thank you again for your great work.
till.kamppeter>
till.kamppeter> Unfortunately, your pdftoraster filter has a bug. It seems to output a till.kamppeter> broken CUPS Raster stream. The "SpliX" driver (a CUPS Raster driver for till.kamppeter> Samsung laser printers, http://splix.ap2c.org/,
till.kamppeter> http://openprinting.org/show_driver.cgi?driver=splix2) produces black till.kamppeter> printouts or even crashes when your pdftoraster is used:
till.kamppeter>
till.kamppeter> https://bugs.launchpad.net/ubuntu/+source/splix/+bug/261363
till.kamppeter> https://bugs.launchpad.net/ubuntu/+source/splix/+bug/268510
till.kamppeter> https://bugs.launchpad.net/ubuntu/+source/splix/+bug/269691
till.kamppeter>
till.kamppeter> To check whether pdftoraster is really the culprit, I have written an till.kamppeter> alternative pdftoraster, a very simple shell script:
till.kamppeter>
till.kamppeter> #!/bin/sh
till.kamppeter> set -e
till.kamppeter>/usr/lib/cups/filter/cpdftocps"$@" | \
till.kamppeter>/usr/lib/cups/filter/pstoraster"$@"
till.kamppeter>
till.kamppeter> cpdftocps is a filter which converts PDF to PostScript and injects till.kamppeter> PostScript commands from the PPD into the resulting PostScript according till.kamppeter> to the option settings. It is originally intended to support PostScript till.kamppeter> printers in the PDF workflow. You can download it here:
till.kamppeter>
till.kamppeter> http://www.openprinting.org/download/printing/pdf-printing/cpdftocps
till.kamppeter>
till.kamppeter> I have asked the reporters of the above-mentioned bugs to use this till.kamppeter> alternative filter and they told that when they use it the problems with till.kamppeter> "SpliX" disappear.
till.kamppeter>
till.kamppeter> So I assume that something is broken with your pdftoraster driver. Can till.kamppeter> you check and fix this as soon as possible, as we are shortly before till.kamppeter> release of Ubuntu Intrepid and it would be great to not have to use a till.kamppeter> script which converts the PDF to PostScript to be able to get CUPS till.kamppeter> Raster data.
till.kamppeter>
till.kamppeter> For investigating the problem, feel free to get in contact with the till.kamppeter> reporters of the three above-mentioned bug reports, by adding comments till.kamppeter> to the reports.
till.kamppeter>
till.kamppeter> I have also tried the alternative of a Ghostscript-based pdftoraster till.kamppeter> driver where PDF is directly fed into Ghostscript, but it seems that till.kamppeter> there is a bug in the "cups" output device of Ghostscript. See till.kamppeter>
till.kamppeter> http://bugs.ghostscript.com/show_bug.cgi?id=690101
till.kamppeter>
till.kamppeter> This problem does not occur when feeding PostScript into Ghostscript. till.kamppeter> Anyone who could help here is welcome, too.
till.kamppeter>
till.kamppeter> Thank you in advance for your quick help.
till.kamppeter>
till.kamppeter> Till
Thank you very much for the patches.
I have integrated the filter patches into the CUPS package of Intrepid now.
In principle it works, but I had to apply additional fixes:
1. In pdftoraster.cc I had to apply the attached patch, as otherwise the margins were not taken into account in your mediabox addition and that leads to shifted output. With my patch the output is correctly centered. Can you apply this patch upstream? Thanks.
2. The patch for pstopdf did not work on my pstopdf. I have a new pstopdf attached which merges the functionality of mine and yours.
Till
Quoted 131 lines · Koji Otani
Hi
I'm Koji Otani.I've investigated this problem.
There are 2 problems in fact.
1. splix crashes
https://bugs.launchpad.net/ubuntu/+source/splix/+bug/261363
https://bugs.launchpad.net/ubuntu/+source/splix/+bug/268510
This happenes when page size is Letter.2. yield completely black pages
https://bugs.launchpad.net/ubuntu/+source/splix/+bug/269691*** CAUSE ***
1. splix crashes
This is cauesed by several filters' behaviors.
(1) pstopdf
pstopdf produces Only A4 size PDF even when Letter is specified. This behavior seems a bug, I think.
This is because no page size option is specified for ps2pdf.
(2) pdftopdf
pdftopdf doesn't change PDF page size in this case. So, the produced PDF is A4 size.
(3) pdftoraster
pdftoraster produces image which size is same as PDF page size. So, the produced image size is A4 size.
(4) splix
splix crashes when height of image size is larger than expected. In this case, input image size is A4 and expected image size is Letter. So, splix crashes.
This is a bug of splix.
On 64bits AMD, splix doesn't crash luckily although accessing wrong area.2. yield completely black pages
When color space is K, pdftoraster uses wrong paper color (Black). Images in PDF are reversed video.
And splix requires color space K.
This is a bug of psdtoraster.******** Solution *********
1. splix crashes
(1) Fix pstopdf to produce PDF has specified Page size.
Using pstops as cpdftocps, setpagedevice operators are passed to ps2pdf. Attached the patch.
(2) Fix splix not to crash.
Attached the patch.
This fix is optional in this case.
(3) Change pdftoraster to produce cups specified size image. Attached the patch.
In this case, this fix is not needed. But in other case this is needed. please apply this patch.(4) Change pdftopdf to produce cups specified size PDF. Attached the patch.
In this case, this fix is not needed. But in other case this is needed. please apply this patch.2. yield completely black pages
・Fix pdftoraster
Attached the patch. this is merged in solution 1-(3) patch.---------------
I have applied patches for pdftopdf, pdftoraster to the sourceforge jp repository.-------------------------
Koji OtaniFrom: Till Kamppeter <[email protected]>
Subject: Bug in pdftoraster filter
Date: Tue, 30 Sep 2008 15:48:56 +0200
Message-ID: <[email protected]>till.kamppeter> Hi,
till.kamppeter>
till.kamppeter> I have integrated your filters in the CUPS package on Ubuntu and now we till.kamppeter> have a complete PDF printing workflow there:
till.kamppeter>
till.kamppeter> https://www.linuxfoundation.org/en/OpenPrinting/PDF_as_Standard_Print_Job_Format
till.kamppeter> https://blueprints.launchpad.net/ubuntu/+spec/pdf-as-standard-print-job-format
till.kamppeter>
till.kamppeter> Thank you again for your great work.
till.kamppeter>
till.kamppeter> Unfortunately, your pdftoraster filter has a bug. It seems to output a till.kamppeter> broken CUPS Raster stream. The "SpliX" driver (a CUPS Raster driver for till.kamppeter> Samsung laser printers, http://splix.ap2c.org/,
till.kamppeter> http://openprinting.org/show_driver.cgi?driver=splix2) produces black till.kamppeter> printouts or even crashes when your pdftoraster is used:
till.kamppeter>
till.kamppeter> https://bugs.launchpad.net/ubuntu/+source/splix/+bug/261363
till.kamppeter> https://bugs.launchpad.net/ubuntu/+source/splix/+bug/268510
till.kamppeter> https://bugs.launchpad.net/ubuntu/+source/splix/+bug/269691
till.kamppeter>
till.kamppeter> To check whether pdftoraster is really the culprit, I have written an till.kamppeter> alternative pdftoraster, a very simple shell script:
till.kamppeter>
till.kamppeter> #!/bin/sh
till.kamppeter> set -e
till.kamppeter>/usr/lib/cups/filter/cpdftocps"$@" | \
till.kamppeter>/usr/lib/cups/filter/pstoraster"$@"
till.kamppeter>
till.kamppeter> cpdftocps is a filter which converts PDF to PostScript and injects till.kamppeter> PostScript commands from the PPD into the resulting PostScript according till.kamppeter> to the option settings. It is originally intended to support PostScript till.kamppeter> printers in the PDF workflow. You can download it here:
till.kamppeter>
till.kamppeter> http://www.openprinting.org/download/printing/pdf-printing/cpdftocps
till.kamppeter>
till.kamppeter> I have asked the reporters of the above-mentioned bugs to use this till.kamppeter> alternative filter and they told that when they use it the problems with till.kamppeter> "SpliX" disappear.
till.kamppeter>
till.kamppeter> So I assume that something is broken with your pdftoraster driver. Can till.kamppeter> you check and fix this as soon as possible, as we are shortly before till.kamppeter> release of Ubuntu Intrepid and it would be great to not have to use a till.kamppeter> script which converts the PDF to PostScript to be able to get CUPS till.kamppeter> Raster data.
till.kamppeter>
till.kamppeter> For investigating the problem, feel free to get in contact with the till.kamppeter> reporters of the three above-mentioned bug reports, by adding comments till.kamppeter> to the reports.
till.kamppeter>
till.kamppeter> I have also tried the alternative of a Ghostscript-based pdftoraster till.kamppeter> driver where PDF is directly fed into Ghostscript, but it seems that till.kamppeter> there is a bug in the "cups" output device of Ghostscript. See till.kamppeter>
Quoted 9 lines
till.kamppeter> http://bugs.ghostscript.com/show_bug.cgi?id=690101
till.kamppeter>
till.kamppeter> This problem does not occur when feeding PostScript into Ghostscript. till.kamppeter> Anyone who could help here is welcome, too. till.kamppeter>
till.kamppeter> Thank you in advance for your quick help. till.kamppeter>
till.kamppeter> Till
pdftoraster.cc renamed from pdftoraster.cc.orig +4 -3
@@ -208,9 +208,10 @@ Page *page = catalog->getPage(i); PDFRectangle *mediaBox = page->getMediaBox(); - mediaBox->x1 = mediaBox->y1 = 0; - mediaBox->x2 = header.PageSize[0]; - mediaBox->y2 = header.PageSize[1]; + mediaBox->x1 = header.ImagingBoundingBox[0]; + mediaBox->y1 = header.ImagingBoundingBox[1]; + mediaBox->x2 = header.ImagingBoundingBox[2]; + mediaBox->y2 = header.ImagingBoundingBox[3]; } /* fix NumCopies, Collate ccording to PDFTOPDFComments */
#!/bin/sh
# $Id: pstopdf,v 1.3 2003/02/15 15:21:00 gurubert Exp $ #
# This is a Postscript to PDF filter for CUPS
#
# (C) 2003 Robert Sander <[email protected]> #
# Released under GPL
#
# NO WARRANTY AT ALL
#
set -e
# These options are *not* passed through to pstops, since pdftopdf or
# equivalent has already processed them. MASK=' brightness Collate cupsEvenDuplex fitplot gamma hue landscape mirror multiple-document-handling natural-scaling number-up number-up-layout orientation-requested OutputOrder page-border page-bottom page-label page-left page-ranges page-right page-set page-top position saturation scaling sides '
# Convert MASK to a regexp.
MASK_RE=$(
set -- $MASK
IFS='|'
printf "%s" "$*"
)
# Annihilate all forms of the masked options from $5:
# - <option>=parameter
# - <option> (boolean)
# - no<option> (boolean)
MASKED_OPTS=$(
printf "%s" "$5" | \
sed -r -e 's/(^|\s+)(no)?('"$MASK_RE"')(=\S*)?//g' -e 's/^\s+//')
PS2PS=/usr/bin/ps2ps
PSTOPS=/usr/lib/cups/filter/pstops PS2PDF=/usr/bin/ps2pdf13 PS2PS_OPTIONS="-dAutoRotatePages=/None -dAutoFilterColorImages=false
-dNOPLATFONTS -dPARANOIDSAFER -sstdout=%stderr"
PS2PDF_OPTIONS="$PS2PS_OPTIONS -dColorImageFilter=/FlateEncode"
echo "DEBUG: pstopdf argv[$#] = $@" >&2
if [ $# -lt 5 -o $# -gt 6 ]; then
echo "ERROR: $0 job-id user title copies options [file]" >&2 exit 1
fi
# Read from given file.
if [ -n "$6" ]; then
exec <"$6"
fi
tempfiles=
trap 'rm -f $tempfiles' 0 1 2 13 15
infile=$(mktemp -t pstopdf.XXXXXX)
tempfiles="$tempfiles $infile"
cat >"$infile"
# Apply PPD settings.
resolution=
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)Resolution=([0-9.]+(x[0-9.]+)?).*/resolution="${resolution:-\2}"/p')" if test -e "$PPD"; then
eval "$(sed -nre 's/^\*DefaultResolution:\s+([0-9.]+(x[0-9.]+)?).*/resolution="${resolution:-\1}"/p' "$PPD")"
fi
pagesize=
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)(media|PageSize)=(\S+).*/pagesize="${pagesize:-\3}"/p')" if test -e "$PPD"; then
eval "$(sed -nre 's/^\*DefaultPageSize:\s+(.+)$/pagesize="${pagesize:-\1}"/p' "$PPD")"
fi
width=
height=
tl_x=
tl_y=
br_x=
br_y=
if test -n "$pagesize" && test -e "$PPD"; then
eval "$(sed -nre 's|^\*PaperDimension\s+'"$pagesize"'/[^"]+:\s+"(\S+)\s+(\S+)"$|width="\1"; height="\2"|p' "$PPD")"
eval "$(sed -nre 's|^\*ImageableArea\s+'"$pagesize"'/[^"]+:\s+"(\S+)\s+(\S+)\s+(\S+)\s+(\S+)"$|tl_x="\1"; tl_y="\2"; br_x="\3"; br_y="\4"|p' "$PPD")"
fi
margin_l=
margin_b=
margin_r=
margin_t=
if test -n "$width" && test -n "$height" && \
test -n "$tl_x" && test -n "$tl_y" && \
test -n "$br_x" && test -n "$br_y"; then
margin_l="$tl_x"
margin_b="$(printf "scale=8; (%s)-(%s)\n" "$height" "$br_y" | bc)" margin_r="$(printf "scale=8; (%s)-(%s)\n" "$width" "$br_x" | bc)" margin_t="$tl_y"
fi
inject_ps=
if test -n "$margin_l" && test -n "$margin_b" && \
test -n "$margin_r" && test -n "$margin_t"; then
inject_ps="<</.HWMargins[$margin_l $margin_b $margin_r $margin_t] /Margins[0 0]>>setpagedevice"
fi
ppd_opts=
if test -n "$resolution"; then
ppd_opts="${ppd_opts:+$ppd_opts }-r$resolution"
fi
if test -n "$width"; then
ppd_opts="${ppd_opts:+$ppd_opts }-dDEVICEWIDTHPOINTS=$width"
fi
if test -n "$height"; then
ppd_opts="${ppd_opts:+$ppd_opts }-dDEVICEHEIGHTPOINTS=$height"
fi
# Injection
if test -n "$inject_ps"; then
echo "DEBUG: Injecting PostScript: $inject_ps" >&2
orig_infile="$infile"
infile=$(mktemp -t pstopdf.XXXXXX) tempfiles="$tempfiles $infile"
perl -p -e 'if (! $did) { s:(^%!.*)$:\1\n'"$inject_ps"': && $did++; }' "$orig_infile" > "$infile"
fi
# DRM
DRM_MATCH='^%.*Removing the following.*lines is illegal.*Digital Copyright Act' if egrep -q "$DRM_MATCH" "$infile"; then
# This PS is DRM-infested. Normalize it with ps2ps first.
echo "DEBUG: Normalizing Adobe Reader PostScript with ps2ps" >&2
DRMFILTER="$PS2PS $PS2PS_OPTIONS $ppd_opts - -"
else
DRMFILTER=cat
fi
$PSTOPS "$1" "$2" "$3" "$4" "$MASKED_OPTS" "$infile" | $DRMFILTER | $PS2PDF $PS2PDF_OPTIONS $ppd_opts - -
[Printing-architecture] Bug in pdftopdf filter: N-Up with manual duplex does not work
In reply to a message not in the archiveHere is another patch, this time for pdftopdf. It corrects a problem when using N-Up printing and manual duplex. To save paper you do at first N-up printing, for example 2 pages per sheet (number-up=2). Then you get sheets with 1+2, 3+4, 5+6, ... For manual duplex you use the page-set=even option, turn over the paper and then use page-set=odd. You expect to get 3+4, 7+8, 11+12, ... at first and then 1+2, 5+6, 9+10, ... What you get with your filter when using page-set=even is 2+4, 6+8, 10+12, ... which is pretty useless. The attached patch corrects this bug and makes pdftopdf behaving exactly like pstops.
Till
Quoted 137 lines · Koji Otani
OK.
I have made sure that pstoraster behaves as your patch. I have applied this patch the source in sourceforge.jp repository.
Thank you.
-----------------
Koji OtaniFrom: Till Kamppeter <[email protected]>
Subject: Re: Bug in pdftoraster filter
Date: Sat, 04 Oct 2008 21:43:21 +0200
Message-ID: <[email protected]>till.kamppeter> Thank you very much for the patches.
till.kamppeter> till.kamppeter> I have integrated the filter patches into the CUPS package of Intrepid now.
till.kamppeter> till.kamppeter> In principle it works, but I had to apply additional fixes:
till.kamppeter> till.kamppeter> 1. In pdftoraster.cc I had to apply the attached patch, as otherwise the till.kamppeter> margins were not taken into account in your mediabox addition and that till.kamppeter> leads to shifted output. With my patch the output is correctly centered. till.kamppeter> Can you apply this patch upstream? Thanks. till.kamppeter> till.kamppeter> 2. The patch for pstopdf did not work on my pstopdf. I have a new till.kamppeter> pstopdf attached which merges the functionality of mine and yours.
till.kamppeter> till.kamppeter> Till
till.kamppeter> till.kamppeter> till.kamppeter> Koji Otani wrote:
till.kamppeter> > Hi
till.kamppeter> > I'm Koji Otani.
till.kamppeter> > till.kamppeter> > I've investigated this problem.
till.kamppeter> > till.kamppeter> > There are 2 problems in fact.
till.kamppeter> > till.kamppeter> > 1. splix crashes
till.kamppeter> > https://bugs.launchpad.net/ubuntu/+source/splix/+bug/261363
till.kamppeter> > https://bugs.launchpad.net/ubuntu/+source/splix/+bug/268510
till.kamppeter> > This happenes when page size is Letter.
till.kamppeter> > till.kamppeter> > 2. yield completely black pages
till.kamppeter> > https://bugs.launchpad.net/ubuntu/+source/splix/+bug/269691
till.kamppeter> > till.kamppeter> > *** CAUSE ***
till.kamppeter> > till.kamppeter> > 1. splix crashes
till.kamppeter> > This is cauesed by several filters' behaviors.
till.kamppeter> > (1) pstopdftill.kamppeter> > pstopdf produces Only A4 size PDF even when Letter is specified. till.kamppeter> > This behavior seems a bug, I think. till.kamppeter> > This is because no page size option is specified for ps2pdf.till.kamppeter> > (2) pdftopdf
till.kamppeter> > pdftopdf doesn't change PDF page size in this case.
till.kamppeter> > So, the produced PDF is A4 size.
till.kamppeter> > (3) pdftoraster
till.kamppeter> > pdftoraster produces image which size is same as PDF page size.
till.kamppeter> > So, the produced image size is A4 size.
till.kamppeter> > (4) splixtill.kamppeter> > splix crashes when height of image size is larger than expected. till.kamppeter> > In this case, input image size is A4 and expected image size is till.kamppeter> > Letter. So, splix crashes. till.kamppeter> > This is a bug of splix. till.kamppeter> > On 64bits AMD, splix doesn't crash luckily although accessing till.kamppeter> > wrong area.till.kamppeter> > till.kamppeter> > 2. yield completely black pages
till.kamppeter> > When color space is K, pdftoraster uses wrong paper color (Black).
till.kamppeter> > Images in PDF are reversed video.
till.kamppeter> > And splix requires color space K. till.kamppeter> > This is a bug of psdtoraster.
till.kamppeter> > till.kamppeter> > ******** Solution ********* till.kamppeter> > 1. splix crashes
till.kamppeter> > (1) Fix pstopdf to produce PDF has specified Page size.
till.kamppeter> > Using pstops as cpdftocps, setpagedevice operators are passed to ps2pdf.
till.kamppeter> > Attached the patch.
till.kamppeter> > (2) Fix splix not to crash.
till.kamppeter> > Attached the patch.
till.kamppeter> > This fix is optional in this case.
till.kamppeter> > (3) Change pdftoraster to produce cups specified size image.till.kamppeter> > Attached the patch. till.kamppeter> > In this case, this fix is not needed. But in other case this is till.kamppeter> > needed. please apply this patch. till.kamppeter> > till.kamppeter> > (4) Change pdftopdf to produce cups specified size PDF. till.kamppeter> > Attached the patch. till.kamppeter> > In this case, this fix is not needed. But in other case this is till.kamppeter> > needed. please apply this patch.till.kamppeter> > till.kamppeter> > 2. yield completely black pages
till.kamppeter> > till.kamppeter> > ・Fix pdftoraster
till.kamppeter> > Attached the patch. this is merged in solution 1-(3) patch.
till.kamppeter> > till.kamppeter> > till.kamppeter> > ---------------
till.kamppeter> > I have applied patches for pdftopdf, pdftoraster to the till.kamppeter> > sourceforge jp repository. till.kamppeter> > till.kamppeter> > -------------------------
till.kamppeter> > Koji Otani
till.kamppeter> > till.kamppeter> > From: Till Kamppeter <[email protected]>
till.kamppeter> > Subject: Bug in pdftoraster filter
till.kamppeter> > Date: Tue, 30 Sep 2008 15:48:56 +0200
till.kamppeter> > Message-ID: <[email protected]>
till.kamppeter> > till.kamppeter> > till.kamppeter> Hi,
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> I have integrated your filters in the CUPS package on Ubuntu and now we till.kamppeter> > till.kamppeter> have a complete PDF printing workflow there:
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> https://www.linuxfoundation.org/en/OpenPrinting/PDF_as_Standard_Print_Job_Format
till.kamppeter> > till.kamppeter> https://blueprints.launchpad.net/ubuntu/+spec/pdf-as-standard-print-job-format
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> Thank you again for your great work.
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> Unfortunately, your pdftoraster filter has a bug. It seems to output a till.kamppeter> > till.kamppeter> broken CUPS Raster stream. The "SpliX" driver (a CUPS Raster driver for till.kamppeter> > till.kamppeter> Samsung laser printers, http://splix.ap2c.org/,
till.kamppeter> > till.kamppeter> http://openprinting.org/show_driver.cgi?driver=splix2) produces black till.kamppeter> > till.kamppeter> printouts or even crashes when your pdftoraster is used:
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> https://bugs.launchpad.net/ubuntu/+source/splix/+bug/261363
till.kamppeter> > till.kamppeter> https://bugs.launchpad.net/ubuntu/+source/splix/+bug/268510
till.kamppeter> > till.kamppeter> https://bugs.launchpad.net/ubuntu/+source/splix/+bug/269691
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> To check whether pdftoraster is really the culprit, I have written an till.kamppeter> > till.kamppeter> alternative pdftoraster, a very simple shell script:
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> #!/bin/sh
till.kamppeter> > till.kamppeter> set -e
till.kamppeter> > till.kamppeter>/usr/lib/cups/filter/cpdftocps"$@" | \
till.kamppeter> > till.kamppeter>/usr/lib/cups/filter/pstoraster"$@"
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> cpdftocps is a filter which converts PDF to PostScript and injects till.kamppeter> > till.kamppeter> PostScript commands from the PPD into the resulting PostScript according till.kamppeter> > till.kamppeter> to the option settings. It is originally intended to support PostScript till.kamppeter> > till.kamppeter> printers in the PDF workflow. You can download it here:
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> http://www.openprinting.org/download/printing/pdf-printing/cpdftocps
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> I have asked the reporters of the above-mentioned bugs to use this till.kamppeter> > till.kamppeter> alternative filter and they told that when they use it the problems with till.kamppeter> > till.kamppeter> "SpliX" disappear.
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> So I assume that something is broken with your pdftoraster driver. Can till.kamppeter> > till.kamppeter> you check and fix this as soon as possible, as we are shortly before till.kamppeter> > till.kamppeter> release of Ubuntu Intrepid and it would be great to not have to use a till.kamppeter> > till.kamppeter> script which converts the PDF to PostScript to be able to get CUPS till.kamppeter> > till.kamppeter> Raster data.
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> For investigating the problem, feel free to get in contact with the till.kamppeter> > till.kamppeter> reporters of the three above-mentioned bug reports, by adding comments till.kamppeter> > till.kamppeter> to the reports.
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> I have also tried the alternative of a Ghostscript-based pdftoraster till.kamppeter> > till.kamppeter> driver where PDF is directly fed into Ghostscript, but it seems that till.kamppeter> > till.kamppeter> there is a bug in the "cups" output device of Ghostscript. See till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> http://bugs.ghostscript.com/show_bug.cgi?id=690101
Quoted 9 lines
till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> This problem does not occur when feeding PostScript into Ghostscript. till.kamppeter> > till.kamppeter> Anyone who could help here is welcome, too. till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> Thank you in advance for your quick help. till.kamppeter> > till.kamppeter>
till.kamppeter> > till.kamppeter> Till
till.kamppeter> > till.kamppeter>
P2PCatalog.cxx renamed from P2PCatalog.cxx.orig +5 -0
@@ -68,6 +68,11 @@ return pageTree->nup(n,box,borderFlag,layout,xpos,ypos); } +void P2PCatalog::select(const char *pageSet, const char *pageRanges) +{ + pageTree->select(pageSet,pageRanges); +} + void P2PCatalog::fit(PDFRectangle *box, double zoom) { pageTree->fit(box,zoom);
P2PCatalog.h renamed from P2PCatalog.h.orig +1 -0
@@ -48,6 +48,7 @@ virtual void output(P2POutputStream *str, int copies, GBool collate);int nup (int n,PDFRectangle *box,unsigned int borderFlag,unsigned int layout,int xpos,int ypos); +void select (const char *pageSet,const char *pageRanges);void fit (PDFRectangle *box,double zoom);void mirror ();void rotate (int orientation);
P2PDoc.cxx renamed from P2PDoc.cxx.orig +5 -0
@@ -174,6 +174,11 @@ return catalog->nup(n,box,borderFlag,layout,xpos,ypos); } +void P2PDoc::select() +{ + catalog->select(options.pageSet,options.pageRanges); +} + void P2PDoc::fit(PDFRectangle *box, double zoom) { catalog->fit(box,zoom);
P2PDoc.h renamed from P2PDoc.h.orig +1 -0
@@ -108,6 +108,7 @@ bool deviceCollate = false);int nup (int n,PDFRectangle *box,unsigned int borderFlag,unsigned int layout,int xpos,int ypos); +void select ();void fit (PDFRectangle *box,double zoom);void mirror ();void rotate (int orientation);
P2PPageTree.cxx renamed from P2PPageTree.cxx.orig +20 -7
@@ -86,18 +86,13 @@ P2PPageTree::P2PPageTree(Catalog *orgCatalogA, XRef *xrefA) { int i; - int n; xref = xrefA; numPages = orgCatalogA->getNumPages(); pages = new P2PPage *[numPages]; - for (n = 0, i = 0;i < numPages;i++) { - if (checkPageRange(i+1,P2PDoc::options.pageSet, - P2PDoc::options.pageRanges)) { - pages[n++] = new P2PPage(orgCatalogA->getPage(i+1),xref); - } + for (i = 0;i < numPages;i++) { + pages[i] = new P2PPage(orgCatalogA->getPage(i+1),xref); } - numPages = n; } void P2PPageTree::cleanPages(P2PPage **pagesA, int size)
@@ -244,6 +239,24 @@ return 0; } +void P2PPageTree::select(const char *pageSet, const char *pageRanges) +{ + P2PPage **newPages; + int i,j; + + newPages = new P2PPage *[numPages]; + for (i = 0,j = 0;i < numPages;i++) { + if (checkPageRange(i+1, pageSet, pageRanges)) { + newPages[j ++] = pages[i]; + } else { + delete pages[i]; + } + } + delete pages; + pages = newPages; + numPages = j; +} + void P2PPageTree::fit(PDFRectangle *box, double zoom) { int i;
P2PPageTree.h renamed from P2PPageTree.h.orig +1 -0
@@ -49,6 +49,7 @@ virtual void output(P2POutputStream *str, int copies, GBool collate);int nup (int n,PDFRectangle *box,unsigned int borderFlag,unsigned int layout,int xpos,int ypos); +void select (const char *pageSet,const char *pageRanges);void fit (PDFRectangle *box,double zoom);void mirror ();void rotate (int orientation);
pdftopdf.cxx renamed from pdftopdf.cxx.orig +2 -0
@@ -659,6 +659,8 @@ p2pdoc->position(&box,xposition,yposition); } + p2pdoc->select(); + /* set all pages's mediaBox to the target page size */ p2pdoc->setMediaBox(&mediaBox);