Hello, Jeremias!
You wrote to <[EMAIL PROTECTED]> on Mon, 21 Jul 2003 19:59:19 +0200:

 JM> I hear you. Incidentally, I've had the same problem reported to me
 JM> via a different channel. Funny things happen.

 JM> I've checked the PPD of the HP Laserjet 5. It supports the PageSize
 JM> setting. So my reservation was a bit premature. Looks like your
 JM> proposal shouldn't hurt.

We runs HPLaserJet III Si, HPLaserJet 5si and a few older models.
And we just got Xerox Phaser 7300.
All of them doing well with PageSize.

The PostScript reference says:
[begin]
Matching Requests with Attributes
The page device parameters include a special dictionary, InputAttributes, that 
describes
the attributes of all physical media available on the current output device.
Depending on the device, this information may either be discovered automatically
by the PostScript interpreter or configured manually by a human operator or
system administrator. The setpagedevice operator matches the media requirements
specified by the page description against the attributes described in the
InputAttributes dictionary to determine which media source to select.
The keys in the InputAttributes dictionary are integer position numbers representing
media sources on the device. The value associated with each key is a subdictionary
whose entries describe the attributes of the medium currently
available from that source. Entries in this subdictionary include PageSize,
MediaColor, MediaWeight, MediaType, MediaClass, and InsertSheet. These keys
have the same meanings as the correspondingly named page device parameters,
but they describe the actual attributes of the medium instead of the requirements
of the page description.

Note: All implementations of setpagedevice support input media selection by means
of the PageSize, MediaColor, MediaWeight, MediaType, MediaClass, and Insert-
Sheet attributes, whether or not the device can sense these attributes automatically.
On some devices, other attributes may also influence media selection; those attributes
can appear in the InputAttributes dictionary as well.
[end]

I propose to make following changes:
Class PSRenderer:
    /**
     * String with additional Page Device parameters.<br/>
     */
    protected String pageDeviceParameters;

    /**
     * Return Page Device Parameters string or null if not set.
     *
     * @return Page Device Parameters
     */
    public String getPageDeviceParameters() {
        return pageDeviceParameters;
    }

    /**
     * Set Page Device Parameters.<br/>
     * The string will be added to the page setup section.<br/>
     * For Example:<pre>/Duplex true<br/>/Tumble true</pre>
     * Set the printer to print the document with duplex mode flipping it on the short 
edge.<br/>
     * <strong>Note:</strong><br/>
     * <i>Refer to the PostScript reference for your PostScript device for more 
details about
     * additional Page Device options. </i>
     *
     * @param pageDeviceParameters String with parameters or null.
     */
    public void setPageDeviceParameters(String pageDeviceParameters) {
        this.pageDeviceParameters = pageDeviceParameters;
    }

    /**
     * Overloaded method.<br/>
     * The page will be rendered as usual, but instead of the PageOrientation
     * the proper page width anf height will be set. Together with user defined
     * [EMAIL PROTECTED] #pageDeviceParameters}.
     *
     * @param page page to render.
     */
    public void renderPage(Page page) {
        this.pagecount++;
        this.idReferences = page.getIDReferences();

        write("%%Page: " + page.getNumber() + " " + page.getNumber());

        final long pagewidth = page.getWidth();
        final long pageheight = page.getHeight();
        final double pspagewidth = pagewidth / 1000f;
        final double pspageheight = pageheight / 1000f;

        write("%%BeginPageSetup");
        // write page device parameters
        write("<<");
        // write user defined parameters, if not null
        if (null!=pageDeviceParameters) write(pageDeviceParameters);
        // write page size
        write("/PageSize ["+pspagewidth+" "+pspageheight+"]");
        // set PS variable
        write(">> setpagedevice");

        write("FOPprocs begin");
        write("FOPFonts begin");
        write("0.001 0.001 scale");
        write("%%EndPageSetup");
        renderRegions(page);
        write("showpage");
        write("%%PageTrailer");
        write("%%EndPage"); //This is non-standard, but used by Adobe.
    }

After this changes, the ps file could be directly send to the printer.
pageDeviceParameters gives a way to specify additional page parameters, like page 
weight, duplex, etc.

---
Yours sincerely, Ivan Latysh.
Ivan[a]yourmail.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to