Change page size for PostScript file?

Hi,
While trying to stream Java2D objects to a PostScript file using Java Printing API, I found I couldn't change the page size, it always gives me ISO_A4 size. In the following modifed sample from printing doc, even if I changed the book's page size and printer media size attribute, it still gave me ISO_A4 size.
thanks for your help
Frank
==== Code ====
import java.io.*;
import java.awt.print.*;
import java.awt.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import java.util.Date;
public class Print2DToStream2 implements Printable {
public Print2DToStream2() {
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
String psMimeType = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();
StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, psMimeType);
if (factories.length == 0) {
System.err.print("No suitable factories");
System.exit(0);
try {
FileOutputStream fos = new FileOutputStream("C:/WUTemp/out.ps");
StreamPrintService sps = factories[0].getPrintService(fos);
DocPrintJob pj = sps.createPrintJob();
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.NA_LEGAL); // no effect
aset.add(OrientationRequested.LANDSCAPE);
Book book = new Book();
PageFormat pf = new PageFormat();
Paper p = new Paper();
//p.setSize(595, 842);
//p.setImageableArea(0,0,595,842);
p.setSize(612, 1008); // didn't take it
p.setImageableArea(0,0,612,1008); // didn't take it
pf.setOrientation(PageFormat.LANDSCAPE);
pf.setPaper(p);
book.append(this, pf);
Doc doc = new SimpleDoc(book, flavor, null);
pj.print(doc, aset);
fos.close();
System.out.println(new Date());
} catch (PrintException pe) {
System.err.println(pe);
} catch (IOException ie) {
System.err.println(ie);
public int print(Graphics g,PageFormat pf,int pageIndex) {
if (pageIndex == 0) {
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pf.getImageableX(), pf.getImageableY());
g2d.setColor(Color.black);
g2d.fillRect(0,0,200,200);
g2d.drawString("example string", 250, 250);
System.out.println("printing ... ...");
return Printable.PAGE_EXISTS;
} else {
return Printable.NO_SUCH_PAGE;
public static void main(String args[]) {
Print2DToStream2 sp = new Print2DToStream2();
}

It turned out that it was the PS viewer mislead me. There is nothing wrong in generating PS file.
Frank

Similar Messages

  • How to increase page size for balance file upload in Workspace.

    Hi All,
    Please suggest how to increase page size for balance file upload in shared Workspace pages.
    Thanks,

    A word of caution is in order regarding changing from facing to non-facing and back again. If you have overridden master page items, you'll get a second, non-overridden copy on all the even-number pages when that half of the master page is re-applied. This applies to master text frames which override automatically when text flows into them as well as to objects you manually override. I think you'll find this particular technique also only works for master text frames, whereas the Layout Adjustment should work in all situations where frames snap to guides.

  • Set Paper Source by Page Size for multi files

    I have over 500 pdf files. How can I batch set "Paper Source by Page Size" in Print Dialog Preset for these files.
    Thanks!

    Hi Andrew,
    Apple made some pretty significant changes to the way that printers function when they released 10.6.
    The setting you're looking for is completely controlled by the OS.
    Choose Apple > System Preferences > Print & Fax.
    Click on your printer and use the drop-down menu to change the default page size for your printer.
    -David

  • Changing "normal size" for QT file?

    I am not sure what this is but I guess it is the default size of the movie when it opens. Is there a way to change this value for a movie? I have looked at the AppleScript dictionary, but cannot see it listed.

    I come from the "old" Internet where file size is important. Big files don't work well with my dial-up so I've learned some tricks to keep my file sizes small.
    http://developer.apple.com/samplecode/samplemakeeffectmovie/samplemakeeffectmovi e.dmg
    I don't know how this app may work on an Intel machine. Rosseta is required.
    Its purpose was to combine two movie files and allow a transition (millions of combinations). Since I was using still image files I first had to give them "time". I added them "scaled" to a ten second sound file then extracted this new 10 second video. Still file sized as if a single image.
    Once I had merged two of these new files it became a new .mov file. Then it was copy/add scaled to add them all into a new file (the sound track). Last was the Texas map over the entire file.
    Try doing that with iMovie!
    And an iMovie file would have measured fifty times larger in file size.
    Tips and tricks can be found in my book.
    Terms of these Discussions require I state I may receive compensation from the link above.

  • Can I change iTunes & iPod display font (not font size) for selected files only?

    I loaded a Russian classical music CD into iTunes and iPod. On the original CD, titles, names etc. are written in cyrillic alphabet.  Once I loaded the CD into iTunes and on iPod this info was displayed unreadably in western alphabet.  Example:  "Èæå õåðóâèìû..." (Í. Ãîëîâàíîâ)Õîð È.
    I have cyrillic font on my Windows 7 computer.  Can I change the display font--for only these selected iTunes music files--to the cyrillic font?  Thanks!

    Does any one know how you can adjust the font size (point size) for the file
    names.
    Sadly enough you can't chance that, feel free to add a feature request for
    that, the more there ask for the bigger chance it will be realized.
    It would be great if the colors for the image name (background and font color)
    could be changed so the contrast could also be increased so it is also easier
    to read.
    And this the cheerful part, go to Bridge preferences General tap and play
    with the sliders for user interface and Image Backdrop until your satisfied.
    BTW using the slider for thumbnail size bottom right of the Bridge window to
    increase the thumbs does not increase the font but makes it nevertheless a
    little clearer.

  • Cannot change page size with acrobat

    I am able to convert my manuscript in Mac word(2011) to adobe acrobat (XI); unfortunately the 6 X 9 " page size does not convert. I spent a few hours on the phone with adobe support and the final resolution was to upload the file to them and they converted it for me. however, they used distiller which reduced the file size and appears to have affected the many images. Does anyone have any advice? The best I have been able to glean online is work with inDesign to change page size.

    Thanks.
    The problem was with the paper size. In addition to change the page size I needed to change the paper size in the print option before selecting save Adobe PDF.
    From Word go to File> Print
    Open the Copies & Pages dropdown
    Select Paper Handling
    Check the Scale to fit paper size box
    Open the Destination Paper Size list
    Select your custom 6x9 Preset
    Click the PDF button
    Select either Save as PDF or Save as Adobe PDF
    The unfortunate thing is that I was able to do this initially, but when I went back to replicate it adobe is creating 2 files one with my cover page and the rest to the manuscript. Luckily my initial copy was good. Thanks again for your help.

  • Getting the page size in PDF file

    i want know how do get the page size in PDF file befor placing every page in document
    for example height=297 mm And width=210mm

    This script:
    http://indesignsecrets.com/zanelli-releases-multipageimporter-for-importing-both -pdf-and-indd-files.php
    answers all your questions.
    Peter

  • Change page size in Acrobat Pro 6.0

    Hello, I'm wondering if there's a way to change page sizes in Acrobat Pro 6.0 for Windows. We are receiving manuscripts which have been assembled from various documents. They're going to be printed at 8.5 x 11, but sometimes some of the pages are 7 x 10. Is there an automated way to change all the 7 x 10 pages to 8.5 x 11? We don't want to have to do each page individually because there are too many of them.
    Many thanks,
    Coral

    You could try printing to a new PDF with the PDF printer, setting the page size to 8.5 x 11 and setting the page scaling option to 'Fit to Printable Area'.  This will hopefully leave the existing 8.5 x 11 ones about the same size (it may shrink them slightly) and scale the other sizes.

  • Introduce left/top margin: Change Page Size ignored

    I have a vector drawing of a technical schematic in PDF.  The drawing is an extract of a much larger schematic, so it is very small: 2.2" by 1.648".  However, when I print it out, it is resized to fill up a Letter size paper (8.5" by 11") and the size is then perfect for viewing.  Also, the PDF has no white space around the edges, so the same PDF is perfect for importing into documentation packages.
    However, for hard copy printing, depending on the exact aspect ratio of the drawing, I will sometimes want to introduce white space along one edge for hole-punching purposes.  I am opening the PDF and printing it from Acrobat 8 Professional.  I cannot use Document->Cropping because I am trying to introduce a margin rather reduce an existing margin.  I tried using the Change Page Size controls in the cropping dialog panel.  Originally, it was set to Fixed Sizes and Page Sizes was set to None.  I selected Custom instead of Fixed Sizes, then I entered in the Width and Height in inches, with the Height being about 0.5" more than the original 1.648" (it's landscape, so the holes will be at the top).  However, the illustrative diagram does not change, and neither do the dimensions shown on it.  I click OK and the PDF as viewed did not change -- no white space.  When I go back into the Change Paper Size dialog, all the size data that I entered is gone and the control have reverted back to Fixed Size with a Page Size of None.  I explored the dropdown list for Page Sizes, and none of them are appropriate for such a small diagram.
    What I'm trying to achieve is a pretty simple effect, and I thought it would be straightforward.  It has to be *very* simple as I expect to do this regularly.  Is there actually a way?  Ideally, it doesn't involve calculating all sorts of bounding boxes and offsets.  Who knows what the assumed reference points for those are.  In fact, the most direct way would be to enter a negative Margin Controls in the Crop Margins region of the dialog.  That is not possible, of course.

    Actually, I found a way.  The reason why the page size was being ignored is because the numbers were too small.  If I enter a big enough number, it sticks.  It would be nice to get a message to that effect though.......sigh.
    I can then adjust the cropping margins to get the gutter.
    Thanks.

  • XI Pro: How to change page size?

    I have a letter-sized document where each page has extremely large margins and text in a tiny font size. Can I use the 'Remove White Margins' function (Crop pages > Set Page Boxes) to remove the large margins and then resize what remains back to 8.5" x11" using the 'Change Page Size' function?
    When I try this, I can do the first step and I'm left with pages about 5.5"x8". But the Change Page Size function does not allow me to resize the page.
    It this possible?

    Hi J Kart,
    Please refer the doc: https://acrobatusers.com/tutorials/how-to-resize-pages-in-a-pdf-file
    Regards,
    Rave

  • Set custom page size for printing

    I want to set a custom page size for printing some PDF three and four-page musical scores to roll paper on an Epson 1290 using Adobe Reader 9.3.4 on Ubuntu 10.04. The printer properties in the print dialog has a media size option, and one of the choices is "custom", but having chosen "custom", the dialog does not allow me to add the actual page size to the lpr printer command. I can see that when I choose "custom", the lpr command is
    lpr -P Stylus-Photo-1290 -o PageSize=Custom etc
    but what I need for a three page output, for example, is
    lpr -P Stylus-Photo-1290 -o PageSize=Custom.297x630mm etc
    and I can't see how to add the actual custom paper size. If I Ok the media size choice dialog with it just set to PageSize=Custom, I can see from the output preview in the print dialog that the actual page size that has been chosen is letter. The online Adobe doc for Reader 9 printing (http://help.adobe.com/en_US/Reader/9.0/content.html#heading2.3) says "For documents that are larger than the standard page size, go to File  > Page Setup.  Create a custom page size before you print your  document". The problem with that is that there is no "Page Setup" option on the File menu in the Unix version of Adobe Reader, only a "Print" option, which is where I already am.
    If I open the PDFs in Evince, it allows me to add the custom page sizes I want, but as Evince doesn't have the option to print multiple pages per sheet I can't use it either...

    Yes, it used to work, and the resize zoom bar used to work too (now its grayed out). I don't know if this is a "who's to blame for it" thing, but its not getting fixed and its pretty bad that no one seems to care enough even to respond. I found my own solution by opening it in Gimp. Just right click and select open with other ...Gimp and it will import into it. In the Gimp Print dialog, you have a scaling percentage in the "Page Setup" tab, and size settings in the "Image settings" plus loads of other stuff including multiple copies.

  • How can i change the size of PDF files ?

    how can i change the size of PDF files? when i convert documents in the acrobat browser it seems the files become larger then normal pdf files, this is, i compare with other files that people send to me and i realise that they are smaller than my converted files, even if they have more pages.

    A lot depends on the form of the PDF. Is it graphics, a scan of a text file, pure text, or other? What version of Acrobat are you working with.
    You can do a save as to get a WORD file, but do not expect great results. The ability to get a decent WORD file depends on what the form of PDF you are working from. If it was created from WORD with tags and all, you might get good results. If not, you might get a lot of messed up results.
    Explain what you are starting with and your ultimate goal. Also check the audit of the file (should be under PDF Optimize) to see where the file information is concentrated (text, fonts, graphics, other).

  • Create coustom page size for Smartforms

    Dear All
    How to create coustom page size for smartforms.
    rgds
    pramod

    HI
    To define a new page format, choose
    Administration -> CCMS -> Print->® Spool Administration.
    Choose Full Administration and then Page Formats on the Device Types tab page. On the next screen choose Change and  Create or  Create with Reference. Fill out the fields on the next screen.
    Activating a New Page Format
    Before using a new page format, you must specify it as a page format in a SAPscript form. Be careful when replacing a page format in a standard SAPscript form as the form may not necessarily fit on the new page format.
    You also have to define a format and device type format for the new page format before you can use it.
    Thanks and Regards
    Santosh   Kate

  • Possible to enlarge white space by changing page size?

    Greetings.  I'm using Acrobat 10 pro now, but in 9  it was possible to enlarge the white space around the text by changing the page size as part of the crop command.  This was very handy for creating an area large enough for text box comments.  I can't find this capability in 10.  Am I, hopefully, mistaken?

    Select: Tools > Pages > Crop
    and then double-click on the page. You'll then get the Crop dialog and you can select a larger page size in the CHange Page Size area.

  • PIXMA MG8220 default page size for printing is set incorrectly to 6x4, need Letter

    I have a PIXMA MG8220, and the default page size for printing is set incorrectly to 6x4, I need it to be Letter paper size. I'm wasting a lot of paper, and cannot figure how to reset the defaults on the printer vs. individual laptops using the printer?Simon

    Hi simonp, To set the paper size to be printed on, please follow these steps: 1.  Open an application such as TextEdit. 2.  Go up to File and select Print, or press the CMD+P keys on your keyboard. 3.  Locate the PAPER SIZE field, then select the LETTER paper size. 4.  Look for the drop-down menu labeled PRESETS, then expand this menu and choose SAVE AS.
    5.  Type in a name of your choice for this default setting, then click OK.
    You will now be able to select the above created preset from any application you print from, with the default paper size being Letter.  Hope this helps!

Maybe you are looking for

  • Expert for hire needed

    I am in charge of rapidly building a large database-driven website using Dreamweaver/PHP/MySQL.  I am familiar with data-driven sites for many years with GoLive.  Now I'm using Dreamweaver CS3 and am getting a pretty good handle on it.  But I am havi

  • Java xslt mapping

    hi,   could any one please forward me java and xslt mapping step by step screen shots. I would be thankful to you ,if you do this. with regards, [email protected]

  • Problem when getting resultset when using connection pooling in weblogic

    Hello, I am new to database connection pooling. I am using weblogic server, Java 1.6, MySql database. I have done connection pooling in weblogic server. The problem arise when I try to run select query I cannot fetch data in ResultSet. For insert it

  • Not able to Close PO or Mark deleted

    Hi All, I have to close a PO but system doesnt allow to close it or mark the line Item as Deleted. The reason for the error is IR value is more than GR value. We dont have GR based IV. How can I close the PO. Thanks Nsandeep

  • Preparing PI 7.1 Server

    Dear All, I am having a newly installed PI 7.1 Server with no configurations in it. Kindly help me in preparing the server as I am not able to open SLD also in the server. Regards, N.J.