Problem Printing Documents - No Doc Flavors Supported

Hello everybody. I've been trying to implement a print feature in my applications and I've had absolutely zero luck. Basically, I'm trying to print the contents of an html file. However, there are no PrintServices that show up on my machine that support DocFlavors text/html, or even text/plain.
I searched all over the Internet, but the only tutorials I found involved printing GUI components. I tried putting everything in a JEditorPane and then printing it, but the table is so large horizontally, it runs off the side, so I don't think that route will work.
I checked IRC, scanned through all of Sun's tutorials and print service API documentation, and even searched around for open source Java word processors so I could check how their print features are implemented, but I can't find anything to help me figure this out. I know there has to be a way, though... or stuff like EIOffice and ThinkFree.com wouldn't be able to work. Can somebody please point me in the right direction?
Here's the current code I have:
          //display print dialog
          DocFlavor df=new DocFlavor("text/html; charset="+DocFlavor.hostEncoding,"java.io.InputStream");
          PrintRequestAttributeSet attributes=new HashPrintRequestAttributeSet();
          attributes.add(new javax.print.attribute.standard.JobName("NutraSmart Menu",null));
          PrintService[] services=PrintServiceLookup.lookupPrintServices(df,attributes);
          PrintService service=null;
          if(services.length>0)
               service=ServiceUI.printDialog(this.getGraphicsConfiguration(), this.getX()+50, this.getY()+50, services, services[0], null, attributes);
          else
               JOptionPane.showMessageDialog(getContentPane(),"No print services could be found to print this menu.","Error printing menu",JOptionPane.ERROR_MESSAGE);
               nutrasmart.debug(nutrasmart.ERROR,"Could not find any services to print menu");
          //print menu
          if(service!=null)
               try
                    //create temporary HTML file to print from
                    File tmpfile=File.createTempFile("nsmenu",".html");
                    tmpfile.deleteOnExit();
                    String tmpfilestr=tmpfile.getPath();
                    export_HTML(tmpfilestr);
                    FileInputStream tmpfilestream;
                    try
                         tmpfilestream=new FileInputStream(tmpfilestr);
                    catch(FileNotFoundException e)
                         JOptionPane.showMessageDialog(getContentPane(),"A problem was encountered while preparing the menu to print.","Error printing menu",JOptionPane.ERROR_MESSAGE);
                         return;
                    //print document
                    DocPrintJob pj=service.createPrintJob();
                    Doc doc=new SimpleDoc(tmpfilestream,df,new HashDocAttributeSet());
                    pj.print(doc,attributes);
               catch(Exception e)
                    JOptionPane.showMessageDialog(getContentPane(),"There was a problem with printing the menu.","Error printing menu",JOptionPane.ERROR_MESSAGE);
                    nutrasmart.debug(nutrasmart.ERROR,"Error printing file",e.getMessage());
          }

Really we have a crazy font management.
We have more than 9000 fonts in the /Library/Fonts
To avoid conficts between the the installed system fonts and the Document font folder, we don't use the document font folder, so that we use always the /Library/Fonts/ fonts installed. Anyway some time ago we also used the Document Font folder and we got the same problem.
I think that your idea about closing the document before the printing process has been finished is very interesting. What I do is :
doc.print(print_preset);
doc.close();
But I don't how can I test if the document is being closed before finishing the printing process.
Regards

Similar Messages

  • Problem printing documents four up in lanscape?

    I have a problem printing documetnts 4 up in landscape.
    The first page will print 4 cells to the first page in portrait mode, even though I have selected landscape, the rest of the document will print 4 up in landscape.
    When I have to produce more than 1 copy, all cpoies will have the same fault.  To get around this I have to print 1 copy, which will have the error then, without leaving the print setup screen, print the other copies which will be fine, i.e 4 up in landscape on all pages including the first page.

    what are you trying to print using which printer and from which application.

  • Problem Printing document properties from Word to PDF

    Hello all,
    This is wierd, I need to print from MS Word doc 2002 SP2 to PDF version 9.3.4.  When I do so, I need to pass the document properties from the word file to the PDF such as author, subject, title, etc.  What is strainge is when i click the pdf button in word they do pass over but when I go to >>File>>print and select PDF they do not, and yes I did select the "Add document information" check box in the Adobe PDF settings dialog.  I need to print this because I am doing a batch print process that requires it to be printed.
    HELP.

    Hello all,
    This is wierd, I need to print from MS Word doc 2002 SP2 to PDF version 9.3.4.  When I do so, I need to pass the document properties from the word file to the PDF such as author, subject, title, etc.  What is strainge is when i click the pdf button in word they do pass over but when I go to >>File>>print and select PDF they do not, and yes I did select the "Add document information" check box in the Adobe PDF settings dialog.  I need to print this because I am doing a batch print process that requires it to be printed.
    HELP.

  • Problems printing small documents

    Hi everyone,
    I am a digital printer and I am running into an odd problem printing document that are smaller than 8.5 by 11. Typically I don't print from Acrobat. I usually just import directly into Command work station and then print from Fiery. However every so often I need to "print as image" to make sure the document prints as it should. I create a custom page size and make sure to choose the correct printer to format for. When I view it in my rip software the document reads as 8.5 by 11. So for example I can send business cards over at 2.25 by 3.75 and use the custom page size that matches but it still comes over as business card placed on a 8.5 by a 11 page. Does any one know how to remedy this? I am using Acrobat XI on a Mac running OS 10.9.3. I use Command Workstation 5.5 printing using Fiery rip software on a Xerox 700 digital press.

    Yes, that shoild be fine.
    At this point I think you should get Applejack...
    http://www.versiontracker.com/dyn/moreinfo/macosx/19596
    After installing, reboot holding down CMD+s, then when the DOS like prompt shows, type in...
    applejack AUTO
    Then let it do all 5 of it's things.
    At least it'll eliminate some questions if it doesn't fix it.
    The 5 things it does are...
    Correct any Disk problems.
    Repair Permissions.
    Clear out Cache Files.
    Repair/check several plist files.
    Dump the VM files for a fresh start.
    First reboot will be slower, sometimes 2 or 3 restarts will be required for full benefit... my guess is files relying upon other files relying upon other files!
    Disconnect the USB cable from any UPS so the system doesn't shut down in the middle of the process.

  • How can I fix a printing problem: message cannot print document: "no pages selected to print" when printing a pdf file.

    I am having problems printing a pdf document. When I select a file to print and try to print it says that "no pages selected to print". The default all pages was selected by me but the message keeps coming up. I recently installed adobe reader version 11. Rebooted the computer but sitll having issues printing docs.
    Jerseyguy

    Hi Pat.
    Yes, both of them lead to the very same error.
    I have a workaround, kind of, where I preview the document and select all the pages that are correct (read showing on the pages preview) as included in the 1st screenshot.
    As you can see in the first screenshot, the 5th page seems to be non-existandt, however as I try to preview it from the 3rdP software, it comes up just fine and from there I can print it individually... just annoying when you have 50 pages and 6 of then are randomly not showing up.
    If I try to print the whole document, it simply gives me the 2nd, 3rd and 4th screenshots.
    As for the 3rdP software, as stated in prior posts, it has been working flawlesly for the last 5 years, and has not been updated in any way, shape of form... As you said, maybe it wouldn't be a bad idea to look into that, however I don't believe the contract for the software maintenance is still in effect...
    Thanks.

  • Problem printing Report Document Draft

    Dear support,
    our customer has problem printing its Document Draft Report, because
    the "DRAFT DOCUMENT" string on the background of the page is too large.
    The printer can manage this dimension and prints an empty second page
    (also when the document has more pages).
    See attached file.
    If we disable the "Print Draft Watermark on Draft Document" flag in the
    Print Preferences, the customer hasn't the problem printing the draft
    document.
    The customer need to distinguish the print of draft document.
    Is it possible in the report designer to know if a document is a Draft or
    a Definitive one?
    If we can understand the type of the document, we could add a text box
    "DRAFT DOCUMENT" in the report and disable the "Print Draft Watermark on
    Draft Document" flag.
    Can someone help us, please?
    Regards,
                  Emanuele
    TC Systems SA - Mendrisio - CH
    Emanuele Croci
    +41 (0)91 960 2525

    hi Emanuele Croci,
    For example paper format which default as Letter,but in PLD
    if y'r paper format is A4 then definitely it will be printed more than 1 page.
    Go to File --> Page Set Up --> Change paper format as in PLD.
    Also reduce the font by 1 point.
    If problem not get solved,You can print Water mark as DRAFT from printer properties.
    Start --> Printer and Faxes > Select Printer you want to print,Right Click it>Select Properties>Select Printing Preferences>Select Effects Tab> Select Water mark option as Draft>Click Apply.
    Test print it let me know.
    Hope above solution will solve problem.
    Jeyakanthan

  • Problem printing scanned PDF document from iPad to HP Photosmart Plus B209a

    Hi,
    I'd like to report a problem printing a scanned PDF document from iPad via HP ePrint application to my HP Photosmart Plus B209a printer. The document was sent to the printer without any issue. However, the printer only prints out the
     screenshot image in the center of the PDF page, and the image is enlarged and rotated to fit in an A4 paper. The rest of the document is simply ignored by the printer. The document with the problem can be downloaded in the link below:
    Download PDF document with the problem
    What could be wrong? Thank you in advance!

    Thanks for the reply.
    I received the document from my teacher, so I don't know what program she used to scan it.
    I tried to print the document directly from my PC which works fine though, so I guess the document is OK.
    My HP printer is an old model which doesn't support eprint or air print, so I used the eprint application on iOS to print the document. I tried both color and black/white which gave me the same result: only the center screenshot image is printed out, and the image is enlarged and rotated to fit an A4 paper, the rest of the document is just ignored.
    What do you mean by saving it as a document?

  • Major problem saving and printing documents on two computers

    This is a bizarre problem that seems to have been transferred from my old MDD to my new Mini when I migrated all my old data and it has me baffled. My apologies if this explanation seems long and complicated but I want to be pretty thorough.
    About a month ago I started experiencing a problem with printing. I noticed when printing a sheet of business cards that the page was getting compressed, for lack of a better word, vertically. This was very noticeable because the trim marks on the side of the page were not lining up with the perforations and each row of cards was getting progressively closer to the top as each row was printed. In other words, the first row of cards was okay but then the next row was a little too far "north", the next row a little more, the next row a little more, etc. The bottom of the page was not cut off, it was just squeezed up a bit but not enough that you could tell that the proportions were off. Now I see that many of my documents are like that no matter what application I've use to create them – Pages, Illustrator, Avery DesignPro. What's even worse, I've used Pages to create a sheet of business cards for a friend and Illustrator to make packaging labels and she's having the same problem printing the PDFs of the labels on a different computer. What this seems to tell me is that something has been corrupted and the computer is saving messed up files.
    So, about ten days ago I got a Mini and migrated my data using Migration Assistant. And the problem has now been transferred to the Mini. So I now have two Macs connected to two different HP printers that are both incapable of printing (and apparently saving) documents in the proper proportions.
    Now, a truly weird thing is that I printed a test sheet of business cards from the Mini on the printer connected to the MDD (via printer sharing) and it appeared that the document printed at the correct length. However, another document, a sheet of labels created in Illustrator, printed at the right length but one edge was slightly cropped off. Grrr.
    Anyway, as I said, until about a month ago everything worked fine so something got messed up at that time to cause this problem with saving and printing documents. I need to get this resolved for business reasons – I'm an aspiring designer – but the only thing I can think of doing is wiping out my Mini and reloading everything except my account settings from Time Machine unless someone has advice on what to do. Help! (And yes, I've checked to see that page scaling was always set at 100%.)

    Well, I've just about had it. I erased the disk, reinstalled the OS, Adobe CS4, and iWork. I did not use Migration Assistant this time to restore my settings but still my Mac prints documents in the wrong dimensions. Could this be a sudden HP problem? It seems to me some system setting somewhere is making my computer save and print documents in the wrong size. I now have a computer that is almost useless for designing. Lucky me.

  • I'm having a problem sending a word doc via email. I have Mac for Office 08, when I save the document as a .doc or .docx, and send it to someone, they receive it as a blank document. Yet, when I open it on my Mac, it has a "word" icon. How do I fix?

    I'm having a problem sending a word doc via email. I have Mac for Office 08, and I'm using Mavericks OS. When I save the document as a .doc or .docx, and send it to someone, (doesn't matter if its safari, chrome or firefox or on my yahoo or gmail accounts) they receive it as a blank document. Yet, when I open it on my Mac, it has a "word" icon and I can read it. How do I fix?

    I suggest you post on the Microsoft Mac forums since it's their software you're having issues with.
    http://answers.microsoft.com/en-us/mac

  • I am having trouble printing a PDF document. Whenever I click print nothing happens but when I am printing documents from Word, Excel etc they print without a problem. I've tried printing as image but that did not work. I uninstalled Adobe Reader XI and d

    I am having trouble printing a PDF document. Whenever I click print nothing happens but when I am printing documents from Word, Excel etc they print without a problem. I've tried printing as image but that did not work. I uninstalled Adobe Reader XI and downloaded Adobe Reader X instead and that still doesn't work. I have Windows 7.

    Hello,
    Please follow the link to troubleshoot the printing issues with Adobe Reader:- Troubleshoot PDF printing | Acrobat, Reader.
    Regards,
    Nakul

  • Problems printing a high qaulity PDF from a document

    Hello,
    Recently I have had some problems printing a high qaulity pdf (acrobat 9 pro) from a document made in 2010 word.
    Every time I have tried to print these documents there is information missing in the pdf incuding text, pictures, shapes etc.. This was never a problem untill I installed 2010 word.
    I sent it to a friend, and he was able to print the document into a pdf just fine.
    What can I do to fix this? It is very important that I tackle this problem asap!
    If you need to know any additional information, please ask.
    Thanks

    Have you  checked to see if Acrobat 9 or any version of Acrobat works with Office 2010?
    Adobe product operating system compatibility
    This issue has been discussed many times. Until Adobe releases the next version of Acrobat, there is very little you can do.

  • Problem Scanning Duplex Printed Document

    I would appreciate help with the problem described below. Problem: Scanning duplex printed document scans first page Perfectly but second page comes out solid black. OS: Windows 7
    Printer: Canon PIXMA MX860
    Software App: Canon MP Navigator EX - mx860 series I would appreciate your help in solving this problem.Thank you,
    --Dennis--

    Thank You for the advice. I called technical help and Jesse spent considerable time and effort to help me solve the problem. The final verdict is that their is a hardware glitch, not software, The nearest Canon repair center is apparently in some place called Lake Forest, CA.  I was born and lived all my life in Southern CA and never heard of Lake Forest. It must be in Northern CA so I can't simply take it in to the shop for repairs. Jesse informed me of a consumer loyalty discount available if I should wish to purchase a new printer. 

  • Problem printing when spool print documents is selected as apposed to print direct

    I have an officejet 6500 and I'm having a problem printing a label created using Label Factory Deluxe software.  The job will not print if spool print documents so that printing finishes faster is selected under the printer properties.  The job appears to be sent to the printer.  The printer icon appears in the task tray for less than a second and the printer makes a trill sounding beep but nothing prints.  In addition there is nothing in the print que.  It will print however, if print directly to the printer is selected.  Any ideas???

    Hello,
    Well with out any info on versions the easiest way is to check the Not Printer Option on in the Page Setup of the Report.
    Don

  • I've just upgraded to OS 10.8.6. Now when I try to export an ipages 09 document to .doc, I get the message "character borders are not supported and were removed," and the file is saved as .pages.

    I've just upgraded to OS 10.8.6. Now when I try to export an ipages 09 document to .doc, I get the message "character borders are not supported and were removed," and the file is saved as .pages.

    I think you would get more expert advice if you asked this in the iWork forum - its really an iWork question
    G

  • Problem printing Adobe Reader documents (PDF). Text files and MS-WORD print fine. Help?

    I cannot get my ePrint to work with Adobe Acrobat (ReaderX) and pdf files.  I get a "Failed to send" message.  I have NO problems printing text or MS-WORD files so I know my Internet, printer, and local intranet are working.  Help?

    When you say the bottom right of you screen, are you talking about your computer screen?  If you are then, you are not using ePrint, which is fine.  You may just be having some wireless network issues.  Try this.  When it asks for the DNS information on step six, enter Google's public DNS (Preferred = 8.8.8.8 | Alt = 8.8.4.4).  If that does not help, let me know  and I will see what I can do.
    By the way, if you are emailing the documents to your printer, which is ePrint, you are right about the file size limit, however, the limit is 5 MB.  Most likely you are not Creating PDF or Docx documents that are anywhere near that size, so that should not be the issue if you are using ePrint.  If you are using ePrint, try turning the router and printer off.  Turn the router on and let it become stable.  Turn the printer back on.  Turn off and on any other devices that are connected to your wireless network as well, so they can re-establish network connection.  Now retry the ePrint job.  If that does not work, let me know.
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------

Maybe you are looking for

  • Can I install windows 8 on a macbook?

    Earlier today I installed windows 7 home, on my Macbook.  The installation went ok. I decided to to install Windows 8 pro. My dilemna is: I cannot choose a cd option to boot from. I have been unable to bootup either eject the installation disc. How d

  • Sending mail with attachment, SAP R3, Sunsolaris, Oracle 9i

    Hi Experts, I have a HR requirement in which i need to send the Appraisal Form via mail to the corresponding supervisor. The form is basically a script.When i run a report this form should be converted to pdf file(format) and the mail should be sent

  • Using Word doc after converting from PDF

    I have just purchased Adobe Export PDF purely to complete a Job Aaplication form in Word rather than PDF but the Word document does not allow me to edit it properly - i.e. I cannot expand the text boxes to make them bigger and when I try to add in in

  • Flash Project Management System

    I was wondering if there has been a UI built in flash for a project management system. What Im looking for is an app where the managers would drag and drop their resources into a timeline for projects and they would be able to stretch resources along

  • Is concatenation of numbers is possible in the loop??

    Hi All, We have used the following code for our requirement in the rtf template.Here AMOUNT is a field name.But the following code is erroring out. <?xdoxslt:set_variable($_XDOCTX, 'A',1)?> <?xdoxslt:set_variable($_XDOCTX, 'Payout',0)?> <?xdoxslt:set