Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Remove relentless printer settings in Pages Apps
I needed to get rid of this behavior in Pages when it came time to format the document for printing on different printers.

I've submitted bug report upon bug report to Apple and received no satisfaction. So finally, I created a solution myself in the form of a shell script that will remove the printer settings associated with each Pages document that prevents printing to the default printer.

I don't know AppleScript that well, but maybe some entrepreneurial hacker can make a drag-n-drop app out of this. (See this article and this tech note for possible starting places.)

The script is called rm_pages_sticky_printer.sh.

#!/usr/bin/env bash

PROG_NAME="$(basename "${0}")"
PROG_DIR="$(cd "$(dirname "${0}")" && pwd)"
XSLT="$(cat <<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sl="http://developer.apple.com/namespaces/sl">
    <xsl:template match="sl:NSPrinter" />

    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()" />
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>
EOF
)"

for i in unzip xsltproc zip ; do
    if ! which >/dev/null "${i}" ; then
        echo 1>&2 "${PROG_NAME}: missing ${i}"

        exit 1
    fi
done

if [ "${#}" -eq 0 ] ; then
    echo "usage: ${PROG_NAME} [PAGES_FILE...]"

    exit
fi

basewd="${PWD}"

for i in ${1+"${@}"} ; do
    echo -n "working on ${i}..."
    idir="$(cd "$(dirname "${i}")" && pwd)"
    ibase="$(basename "${i}")"

    if [ -d "${i}" ] ; then
        inplace=1
    else
        inplace=''
    fi

    if [ -z "${inplace}" ] ; then
        iwdir="$(mktemp -d)"
        unzip -d "${iwdir}" -q "${i}"
    else
        iwdir="${i}"
        gunzip > "${iwdir}/index.xml" -c "${iwdir}/index.xml.gz"
    fi

    echo "${XSLT}" \
        | xsltproc >"${iwdir}/index.xml.tmp" - "${iwdir}/index.xml"

    if [ -z "${inplace}" ] ; then
        iorig="$(TMPDIR= mktemp -p "${iwdir}" index.xml.orig.XXXXXX)"
        cp -Rfp "${iwdir}/index.xml" "${iorig}"
        cat "${iwdir}/index.xml.tmp" >"${iwdir}/index.xml"
    else
        iorig="$(TMPDIR= mktemp -p "${iwdir}" index.xml.gz.orig.XXXXXX)"
        cp -Rfp "${iwdir}/index.xml.gz" "${iorig}"
        gzip >"${iwdir}/index.xml.gz" -c "${iwdir}/index.xml.tmp"
    fi

    rm -f "${iwdir}/index.xml.tmp"

    if [ -z "${inplace}" ] ; then
        inew="${idir}/${ibase%.*}.noprinter.${ibase##*.}"
        cd "${iwdir}"
        zip -9qry "${inew}" .
        cd "${basewd}"
    fi

    echo done
done


[crarko adds: I haven't tested this one. The script is mirrored here.]
    •    
  • Currently 1.43 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (7 votes cast)
 
[5,128 views]  

Remove relentless printer settings in Pages | 2 comments | Create New Account
Click here to return to the 'Remove relentless printer settings in Pages' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Remove relentless printer settings in Pages
Authored by: alextm on Jun 09, '10 01:05:05AM

Looks like there are some problem with the script download and with the selectable field in the post.

both have issues with calls to mktemp, and the view gives issues with the angle brackets

line 47 of the download scpt should be: iwdir="$(mktemp -d /tmp/printerfix.XXXXXX)"
lin 58: iorig="$(TMPDIR= mktemp -d "${iwdir}"/index.xml.orig.XXXXXX)"
line 62: iorig="$(TMPDIR= mktemp -d "${iwdir}"/index.xml.gz.orig.XXXXXX)"

I also created a droplet: I think it works fine. (this all judged by the fact it outputs a second file if given a compressed file and there are no errors in the log. I don't have more than one printer anymore)

For lack of a better place to put the droplet: http://random.alex.ferrouscanine.com/Pages Printer Fix Droplet.app.zip



[ Reply to This | # ]
Remove relentless printer settings in Pages
Authored by: Apple Magic on Oct 09, '10 04:58:43PM