Help with Java Printing-Custom paper sizes

Hi,
I'm trying to print documents with custom paper sizes out of java.
I can print fine when I don't try to set the MediaSize to a custom size or when I use already named constants like: "MediaSizeName.JIS_B4"
The error message I get is this:
java.lang.ClassCastException
     at javax.print.attribute.AttributeSetUtilities.verifyAttributeValue(Unknown Source)
     at javax.print.attribute.HashAttributeSet.add(Unknown Source)
     at hello.Printy.printDocument(Printy.java:103)
     at hello.Printy.main(Printy.java:135)
The offending line(103) looks like this:
pras.add(new MediaSize(1,10,MediaSize.INCH ));The function that its from looks like this:
public  void printDocument()
try
          System.out.println("input file name is");
     System.out.println(inputFileName);
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
PrintService printPrintService = null;
// didn't work pras.add(new MediaSize(1,10,MediaSize.INCH) );
PrintService service = ServiceUI.printDialog(null, 200, 200,printService, defaultService, flavor, pras);
if (service != null)
     System.out.println("There is a service aunty-may!!");
DocPrintJob job = service.createPrintJob();
FileInputStream fis = new FileInputStream(getInputFileName());
DocAttributeSet das = new HashDocAttributeSet();
//pras.add(new MediaSize((float)3.25, (float)4.75, Size2DSyntax.INCH ) );
// - works
//pras.add(MediaSizeName.JIS_B4);
pras.add(new MediaSize(1,10,MediaSize.INCH ));
//pras.add(new MediaSize(1,10,MediaSize.INCH) );
     System.out.println("Doc has been set to custom size");
Doc doc = new SimpleDoc(fis, flavor, null);
job.print(doc, pras);
     System.out.println("any doc for you?");
catch (Exception e)
e.printStackTrace();
}Any help with this would be greatly appreciated. I'm new to java but I've programmed a bunch in c++.

Hmm ... no real help, but I found this note in the API:
MediaSize is not yet used to specify media. Its current role is as a mapping for named
media (see MediaSizeName). Clients can use the mapping method
MediaSize.getMediaSizeForName(MediaSizeName) to find the physical dimensions of
the MediaSizeName instances enumerated in this API. This is useful for clients which
need this information to format & paginate printing.

Similar Messages

  • Who can I speak for CS5 technical support. I am having issues with the printing custom paper size! please please please help.

    Is there any one that can help you on Adobe? I have been on hold twice for 30min and I need help. Contact line is for something else not to happy. I downloaded Yosemite and now my CS5 when I custom print it shuts down the whole program and restarts again. Yes I did restart com+shift+op and yes I restarted computer. And yes called 1800-642-3623 no help. What the heck Adobe!!!!! and now this?????

    Provide the name of the program you are using so a Moderator may move this message to the correct program forum
    This Cloud forum is not about help with program problems... a program would be Photoshop or Lighroom or Muse or ???
    >downloaded Yosemite and now my CS5 when I custom print it shuts down
    CS5 was written LONG before Yosemite was available, and CS5 is no longer updated... have you told Apple that their new operating system breaks your old program?
    Yosemite sometimes has problems, often related to "default" permissions needing to be changed
    -one person's solution https://forums.adobe.com/thread/1689788
    -http://blogs.adobe.com/creativecloud/creative-cloud-and-yosemite/
    -https://helpx.adobe.com/x-productkb/global/mac-os-yosemite-compatability.html

  • HP 6510e not printing custom paper sizes

    I have recently purchased a HP Photosmart 6510e printer. I called HP Tech support from the store where I bought the printer and specifically asked if this printer would print custom paper sizes. I was told it would. I tried to print an invitation on a paper size of 5.5  X  8.5. The printer keeps giving me an paper mismatch error. The paper size shows up in the list of paper sizes, but has an exclamation Point beside it. If I click on teh paper size it changes to 8.5 X 11.
    i am using a PC with Windows 7 OS.
    Thanks.

    Hi,
    The Officejet 6510 software drivers for Windows does not have an option for custom paper sizes. I checked for the paper size (5.5x8.5) you were trying to print on and it is not an option under the paper sizes. The only option is probably to have your printer replaced with a comparable Laserjet printer. Laserjet printer have a different software package and the one I checked (Laserjet Pro M275) has a Custom option. 
    Here is a link to a list of Laserjet printers
    http://shopping2.hp.com/en_US/home-office/-/products/Printers/HP%20LaserJet
    Binary_Zen (worked at HP )
    Click the white Kudos star to say thanks
    Please mark Accept As Solution if it solves your problem

  • How to print custom paper size with borderless?

    Hi, I want print in custom peper size (6"x13") and i want print with borderless, but the print properties dont have the options to select custom size, any idea how can I do this work? thanks.

    Hi, Its specs says it supports: Left: 3.3 mm (0.13 inch)
    Right: 3.3 mm (0.13 inch)
    Top: 3.3 mm (0.13 inch)
    Bootom: 3.3 mm (0.13 inch) and 12 mm (.47 inch) for the following list of papers: U.S. Letter
    U.S. Legal
    A4
    U.S. Executive
    U.S. Statement
    8.5 x 13.0 inch
    B5
    A5
    Cards
    Custom-sized media
    Photo media Source: http://support.hp.com/au-en/document/c03565793 Regards.  

  • Incorrect Number of Pages Printing - Custom Paper Size

    Hello Everyone,
    I am new to Crystal Reports but have recently become responsible for supporting a report that my office has been using for several years.  We utilize a fairly simple Crystal Report to create temporary and guest parking passes in the parking services department of my University.  These passes simply take some data from our internal database and add the current and calculated expiration dates - again, pretty simple.  These passes are then printed on a custom paper stock roughly the size of a #10 envelope that has a hole in the paper to hang around a car's rear view mirror.  This solution has been working for years but we have recently run into a very annoying problem.
    The passes are being printed from our four customer service computers.  Each computer is identical - an HP dc7900 workstation running Windows XP SP3 and Crystal Reports 11.  The computers also have identical printers; HP DeskJet 6940s.  A couple of weeks ago the customer service representatives who handle the parking passes started experiencing a problem.  When they would print a the report (the temporary or guest pass) the printer would occasionally pick up the custom page, make a strange grinding noise, and spit the page out without printing.  It was only by putting the paper back in a second or third time that the pass would actually print.  This problem seems to happen randomly with some people experiencing the problem more than others.
    Like I mentioned before, this method of creating the passes has been working for several years.  We have been using the same Crystal Report and the same printers.  One of the four CSRs has not experienced any problems with her printing - the passes come out of the printer correctly every time.  Other CSRs are able to specify only printing page 1 and the pass will print correctly; even though it is only a one page report to start with.  There is only one CSR who has the problem most frequently - about 80% of the time - and she cannot use the "print page 1" technique.  We have tried to figure out what sets her apart from the others but they should all have identical machines.
    In troubleshooting the problem I have attempted everything I could think of.  Our first thought was to clean the printer or swap it out with a spare, but this did not solve the problem.  Since it was happening on multiple computers, we thought the report was to blame.  We checked to make sure all of the data was fitting withing the margins, there were no extra sections or section breaks, and that the report had not been corrupted somehow.  We also tried to create a new report from scratch - again none of these actions helped.  I then tried to upgrade one computer to all of the latest updates available for Crystal Reports 11 from the website.  These updates did not solve the problem either.  The final straw was to re-image the computer to a known good state, but this did not help.
    Since we are still not sure of the root cause of the problem I have posted a similar topic on HP's customer support forum.  I was hoping that someone in the Crystal Reports community may have some insight into my problems as well.  I have searched through the forums previously and that's where I got many ideas including updating, checking for hidden/over sized text, changing the print engine, and turning of Data Execution Prevention.  However, none of these suggestions improved our situation.  Does anyone have any insights as to what could be causing our problem?  It is getting very annoying for the CSRs and I feel bad that I have not been able to come up with a solution for them.
    To recap, here are my environment specifications:
    -Crystal Reports 11
    -Windows XP Service Pack 3 + all available Windows Updates
    -HP dc7900 Workstations
    -HP DeskJet 6940 printers connected through USB
    -Microsoft Office 2007
    -McAfee Anti-Virus 8.7i
    I appreciate any help or guidance anyone can provide.  Thank you in advance for your support.
    Jeff

    The "strange grinding noise" leads me to believe it is the printer or paper stock.  I know you said you changed printers, but did you swap the printer having the problem with the one that never does?  My HP color laserjet makes a strange grinding noise now that the fuser needs to be replaced (which I will be doing this weekend).  Usually the louder the noise, the worse the printout looks...
    Nothing in Crystal should cause a printer noise...
    HTH,
    Carl

  • Custom Paper sizes not saving

    Hi everyone
    Our IT department has just installed Acrobat X Pro on our PC and I have downloaded the instructions for printing custom paper sizes, but they don't save. I go to the printers and faxes, right click on the pdf printer, click on add under the PDF settings tab, add the name, dimensions etc ... click on modify/save ... and nada. When I go to print it isn't there. What am I doing wrong. I know it's going to be something really simple and I'm being a numpty.
    It's so much simpler on the mac. lol

    Hi Daniel. Thanks for that. It will let me gang up, but not repeat the page so I have a full page of the same thing. I read somewhere on here that I need a plug in for that. Is this correct? The thing is, I'm their graphic designer and they're making me redundant in a couple of months so I won't be here to keep on top of things for them. I use a mac which works perfectly, but they're wanting everything set up on the PC before I go because no-one other me uses macs and they want to put the system to bed. I expect they're going to have keep it going if they don't get the admin rights. To be fair, I really shouldn't care ... but I do. I'm such a sad sack. lol
    Thanks for all your help with this.

  • Problem with custom paper size on dot matrix printer

    Hi All,
    I'm using CR2008 with updated to SP2. I have a problem with custom paper size (W=21; H=14), the CR Viewer show report with custom paper size correctly but when I print it to a dot matrix printer (Epson LQ 300+) the content was rotated to landscape. If print to a laser printer the content was printed correctly. My report was printed correctly by CR10 or previous versions I got this issue when upgraded to CR2008. I aslo tested my computer and printer with orther application like MS Word the printing have no problem with custom paper size.
    Thanks for any advice for me.
    Han

    Looking at the Epson LQ 300+ driver, I see that the latest update is from 2002. In my experience, most matrix printer drivers are not unicode. Crystal Reports is designed to only work with unicode printer drivers. See the [How Printer Driver Options Affect a Report|https://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/a09051e9-721e-2b10-11b6-f9c65c64ef29&overridelayout=true] article, page 6 for details. Also, see [this|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_dev/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] note.
    Finally, see if you can print from the CR designer to this printer and if you get the correct results here.
    Ludek

  • I hooked my P4014n printer up to a new computer with windows 7. I defined my custom paper size

    I hooked my P4014n printer up to a new computer with windows 7.  I defined my custom paper size AND WHEN i PRINT TO IT IT PRINTS AS THOUGH IT IS TRYING TO USE LETTER SIZE PAPER

    See this <br />
    http://support.mozilla.com/en-US/kb/Recovering+important+data+from+an+old+profile

  • Custom paper size with HP Officejet 7500A Wide Format e-All-in-O​ne Printer

    I am wanting to print on a paper size 12x18.  I do not find a "Custom" paper size on my printer HP Officejet 7500A Wide Format e-All-in-One Printer.  Is there another driver which I can download which would allow me to enter custom paper sizes?

    I am wanting to print on a paper size 12x18.  I do not find a "Custom" paper size on my printer HP Officejet 7500A Wide Format e-All-in-One Printer.  Is there another driver which I can download which would allow me to enter custom paper sizes?

  • Photosmart C410: How do I associate a custom paper size with the photo tray?

    Our Photosmart 3310 recently broke down and I purchased a C410 to replace it.  I sell a small item online that I ship in 3 5/8 x 6 1/2 envelopes.  With the 3310, I had figured out a way to print the envelopes from the photo tray.  While Word 2007 allows me to select the photo tray, the printer would not print from there until I created a custom paper size in the printer preferences dialog box.
    One of the reasons I got the C410 was for the photo tray.  It's a real pain to have to swap out the regular paper and stick in one evelope every time I want to print another envelope.  Well, unfortunately, that's what I've been doing.  I select the photo tray in Word, but the printer goes right ahead and prints from the main tray.  I had forgotten what I did to make it work on the 3310, so I experimented with that printer's drivers until I figured it out.
    My problem is that the software interface for the C410 is different than that for the 3310.  I can't figure out how to associate a custom paper size with the photo tray.  To test my theory this evening, I told Word that my envelope size was 5 x 7.  The printer didn't hesitate to take an envelope from the photo tray.  Of course the return address went into a dark void because the envelope is not 5 x 7.
    The difference between the two interfaces is that the 3310 has both printing shortcuts as well as "Print Task Quick Sets."  The C410 only has printing shortcuts.
    If anyone can help me, I'll be very grateful!  I've probably spent hours trying to get this figured out, and I have no idea what to do.

    Hi,
    Which Microsoft product (application) are you using ? Printer supports the following custom sizes:
    From ADF: Custom-sized media (ADF) between 127 to 216 mm wide and 241 to 305 mm long (5 to 8.5 inches wide and 9.5 to 12 inches long)
    From input tray: Custom-sized media between 76.2 to 216 mm wide and 101 to 762 mm long (3 to 8.5 inches wide and 4 to 30 inches long)
    You need to select right custom size from the application.
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • How do I print on a greeting card in landscape when I can't save custom paper size?

    I have a J6450 running on XP SP3 with the latest drivers and patches installed.  I have greeting card stock measuring 6.5 by 10.0 inches and a Microsoft Word document with a custom paper size matching the that stock prints in landscape mode.  The printer error is "Paper Mistmatch.  Paper size or type is incorrect."  I have followed the suggestions on the HP support page, changing the Print, Properties, Features options to show "Other greeting card", but can't define a custom paper size to match the stock.  The Save option is not available.  What do I need to do to make this work? 

    Here is a link to a HP document for adjusting several settings that may help with your issue.
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c01824353&tmp_task=solveCategory&cc=us&dlc=en&la...
    Dave M.
    Say Thanks by clicking the Kudos Star in the post that helped you.
    Please mark the post that solves your problem as Accepted Solution.
    I am an HP employee.

  • How to add a new custom paper size? I am using a HP Deskjet 1000 J 110a printer.

    How to add a new custom paper size? I am using a HP Deskjet 1000 J 110a printer. I am using Windows XP home edition. The Custom option itself is not appearing in the process of selecting paper sizes in Printing preferences. I have installed this printer just today, but I bought it eight months back in Dubai. Could there be chance that since I purchased it in Dubai and I am using it in India, the software's not functioning properly. 
    Can you please help me with this problem immediately? Reply soon...

    Hi RajeshPujara,
    Please refer the link below to know the paper size supported by this printer.
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c02231304&tmp_task=prodinfoCategory&cc=us&dlc=en...
    May I know the size of paper you are trying to print.
    Although I am an HP employee, I am speaking for myself and not for HP.
    --Say "Thanks" by clicking the Kudos Star in the post that helped you.
    --Please mark the post that solves your problem as "Accepted Solution"

  • Photosmart Duplex with Custom Paper Size

    I've recently bought a Photosmart Premium C310a for a personal project where I needed a photo printer that could handle duplex printing and custom sized paper, which according to the spec this printer does. 
    However, when you try to do this the printer driver in Windows Vista tells me that custom sizing is not compatible with duplex printing, rendering the Photosmart Premium a large lump of plastic and wiring that I have no use for.
    Has anyone got any ideas of how I can make this work?
    Thanks,
    Mark

    Radlett wrote:
    I am looking to print on 160mm x 160mm using 250 gsm paper.  Any ideas of how I could do this or can you suggest a photo printer (or similar quality) that would print duplex using this paper?
    Thanks,
    Mark
    OK, the paper weight is outside that "supported" for duplexing as shown in the user manual but it might work.
    I do not have a c310a set up to test with but I tried with a c309a I have here.  What exactly did you try?  I set a custom paper size in the Printing Preferences, Features tab and then selected automatic two sided printing and it seems to work.  Are you trying to print full borderless photo's in duplex mode?  That is not supported and I do not know any way to make it work.  It is also not supported (and will not work) to print with photo media selected and printing in duplex mode.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • How do I get OS X to ask printer for custom paper size

    I am printing postcards.  These are 1/4 of a letter sheet, or 5.5" wide x 4.25" tall.   
    I have a commercial grade HP Laserjet 4350, and I've configured that size in its custom menu for tray 1 (the envelope feeder tray). The printer is happy.
    I've also set a custom paper size in the MacOS, that I've called "Postcard Quarterpage" and I have that selected in the print dialog.  In fact I made it default.
    However, under Paper Handling, it says "Destination paper size: Suggested paper: US Letter" and this is greyed out.  If I check "Scale to fit paper size" which I Do Not Want, then I can pick a variety of sizes.  However my custom size is not in the list. 
    This happens on all applications, so it is definitely OS X Mountain Lion (latest patch).
    Anyway, the upshot is MacOS requests US LETTER size from the printer, so the printer goes "Take this postcard stock out and gimme US LETTER".    The printer can detect paper sizes.  If I try to give it postcards anyway, it blows an error and won't print, which is what it should do.
    How do I get OS X to tell the printer "Gimme 5.5x4.25" like I've instructed it? 

    Hi there Wolf!
    I have a couple of articles here that I believe will help you out with your question. First, here is an article with some information on custom paper sizes:
    OS X Mountain Lion: Manage custom paper sizes
    http://support.apple.com/kb/PH10748
    Note that in that article, it states:
    Custom paper sizes aren’t available for some printers.
    The reason for that is because this is controlled by the driver for the individual printer. You will want to make sure you have the latest version of the printer driver installed on your computer. More information on this can be found in the following article:
    Printer and scanner software available for download
    http://support.apple.com/kb/HT3669
    It might also be helpful to reset your printing system to see if that will resolve the issue. More information on this process can be found here:
    Mac OS X: How to reset the printing system
    http://support.apple.com/kb/HT1341
    Take care, and thanks for visiting the Apple Support Communities.
    -Braden

  • CS6 Problem with Custom Paper Sizes

    When printing on Epson printers (4800,4880,4900) in the Photoshop print settings dialogue box it won't allow me to print at a custom paper size using the sheet or manual feed settings. The paper feed option defaults to Roll Paper when I create the custom paper size, and then when I change it and try and save the settings it just reverts back to roll paper. If I try and send a print after this then the printer won't accept it because it's being told to print on a roll instead of sheet. Why is this?? I'm using CS6 and OS 10.7 and I've never experienced this problem with any previous Photoshop/ Mac OS X before. Please help!

    I use a pc therefor Windows and PC Photoshop.  Anyway The way this works in Philosophy windows print dialog you have to set both Photoshop print settings and the printer driver settings.  And if Photoshop is to handle colors you must set off the device drivers color management. Photoshop Dialog has a printer setting button. I use that to set the device driver setting like color management off, print quality and custom paper size and source roll paper.
    I also wrote a script to tile image into a document for printing on roll paper and eliminate paper  waste. http://www.mouseprints.net/old/dpr/PasteImageRoll.html

Maybe you are looking for

  • Email and SMS Alerts - Solution Manager - PI and EP

    Hi All, I am trying to do the below scenario.....But somehow i am lost in the process. I have a three system PI landscape and a Solution Manager. I have included the DEV PI in solution manager for CCMS,the CCMS agents are online and it also reflects

  • Difference in Pricing of Credit memo Inovice AND Credit memo

    We have difference in prices when we create a return credit memo. We have scale price and for 500 product the scale price is 92 rs. the basic price is 112. We have created an order for 500 items where 92 rs has piced and in the invoce for 500 92 rs h

  • FF68 house bank and account id detail update - table

    Hi, we are doing the process of FF68 for customer incoming payment. here i need to know which table house bank, account id and check number will update. govind

  • How to deploy Office 2010 with different OCT settings ?

    Let say my company has 2 departments. One department needs all the Office features, while another department needs only Excel and Word. Can I place 2 different OCT msp files inside the Updates folder, and install the Office for different department b

  • Problem installing formsReports server after HTTP Only install

    Hi all, Well I have finally got the http only install to run and work correclty but when I go back to install the Forms / Reports server I get an error: "Specified key was not found while trying to GetValue" I hit the Retry button but no success. If