Printable and JEditorPane

I've got a JEditorPane displaying html and would like to print it. I'm having a problem though. When painting a JComponent you basically are printing an image. when the component is larger than the ImageableHeight you print on mulitple pages. The JEditorPane is basically a report with text, sometimes the text is cut off because there is no way to determine if there is text in the bottom most part of the image that gets painted in to the imageable Height. I've tried scaling but that scales the entire graphics context of the compoent the first page. does anyone have any suggestions?

This forum addresses my problem exactly, but I'm now unable to print data in html textareas.
http://forum.java.sun.com/thread.jspa?threadID=501660&messageID=2372430
Stumped.

Similar Messages

  • Inserting strings of printable and non printable characters

    I would very much appreciate some help with the following
    To handle an interface with a legacy system I need to create strings containing both printable and non-printabel ascii characters. And with non printable characters I mean in particular those in the range of ASCII 128 to 159.
    It seems it is not possible to insert a string containting both printable and not printable characters from the afore mentioned range into a VARCHAR2 table column as the following demonstrates:
    insert into test values(chr(156)); -- this inserts the 'œ' symbol.
    SQL> select test, ascii(test), length(test), substr(test,1,1), ascii(substr(test,1,1))from test;
    TEST       ASCII(TEST) LENGTH(TEST) SUBSTR(TEST,1,1) ASCII(SUBSTR(TEST,1,1))
    ┐                  156            1That the the character mapped is shown as '┐' and not 'œ' is not really issue for my application, what is important is that the ASCII value is shown as 156, which is the ASCII code of the character I inserted.
    What is however strange (actually probably not strange but has to do with the lack of understanding of the issue at hand) is that substr returns an empty string...
    Now I try to insert a concatenated string, first the "non printable" character then a printable character
    insert into test values(chr(156)||chr(65));
    SQL> select test, ascii(test), length(test), substr(test,1,1), ascii(substr(test,1,1))from test;
    TEST       ASCII(TEST) LENGTH(TEST) SUBSTR(TEST,1,1) ASCII(SUBSTR(TEST,1,1))
    A                   65            1 A                                     65For some reason the not printable character (chr(156)) is now not inserted or at least does not appear when I selected the data from the table, this effect seems to apply to all characters in the range of ASCII 128 to 159 (tried some but not all) However for instance CHR(13) can be inserted as part of a string as shown above .
    For our application I really don't care much what character is shown or not show, what is important is that I can retrieve the ASCII value and that this value matches the one I inserted which for some reason does not seem to work.
    This seems to be, at least to some extent a character set issue. I have also tested this on a database with character sets set as follows
    NLS_CHARACTERSET
    WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET
    AL16UTF16
    With WE8MSWIN1252 the described issue does NOT occur, however unfortunately I must use NLS_CHARACTERSET AL32UTF8 which produces the results as described above!
    As said any insights would be much appreciated as I am slowly but surely starting to despair.
    For completions sake, character sets are set as follows (changing it is NOT an option):
    NLS_CHARACTERSET
    AL32UTF8
    NLS_NCHAR_CHARACTERSET
    AL16UTF16
    The test table is created as follows
    CREATE TABLE TEST
    TEST VARCHAR2(1000 BYTE)
    Database Version 11.2.0.3.0
    Edited by: helios.taraba on Dec 2, 2012 10:18 AM --Added database version
    Edited by: helios.taraba on Dec 2, 2012 10:24 AM Added description of test results using NLS_CHARACTERSET WE8MSWIN1252

    Hello Orafad,
    Thanks for your reply, at least I understand the effects I'm seeing i.e.
    +"For multibyte character sets, n must resolve to one entire code point. Invalid code points are not validated, and the result of specifying invalid code points is indeterminate."+
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions026.htm
    You are absolutely right I could use chr(50579) to get the ligature symbol. However as what we are trying to achieve is to implement a legacy interface to a 20+ years old subsystem we are actually not so much interested in the symbol itself but rather in the ascii value of that symbol (156 as you so rightly point out in the win-1252 characterset), this particular field represents the lenght of the message being sent to the subsystem and can vary from decimal 68 to 164 and is also considered in a checksum calculation which is part of the message.
    As changing the nls_characterset of the database is not an option I guess I only have one reasonable avenue to resolve this namely to push the functionality to added the "encoded" length of the message (and the calculation of the checksum) to the java driver which is responsible for sending the message (tcp/ip) to the subsystem. Here we should not have any issues adding a byte with the value 156 (or any other for that matter) to the datastream.
    Thankfully all other fields have characters with ascii values below 128 and above 31.
    I'm going to leave my question as un-answered for a bit longer in the hopes of someone coming up with a golden bullet, although not getting my hopes up.
    Thanks, Helios

  • Printable and Graphics in JavaFX - future strategy?

    Hi all,
    I need JavaFX for a business application that requires reporting, printing and also a print preview. What would be the best approach for creating complex layouts (text, tables, graphics, images, graphs, various fonts etc.), having the application display a (WYSIWYG!-)print preview and printing them, just as displayed in the preview?
    In Swing, I resort to the Printable/Pageable API and the Graphics/Graphics2D classes - all AWT classes. As far as I can see, JavaFX is not related to AWT in any way. So, can anyone point out how to implement such requirements using JavaFX for the UI - and for createing the print layout?
    Some details on my motivation:
    1) The API of JavaFX would be great for implementing complex layouts.
    2) Using two different graphics APIs & layers (JavaFX + AWT) does not seem to make sense to me. And, AFAIK JavaFX is not only meant to replace Swing, but likewise AWT.
    3) The most important: Printing support is a "must-have", maybe even mission critical.
    Recently, I talked about JavaFX with decision makers at a development company. They make several business applications, built on Java, with several thousands of customers. They asked repeatedly for printing support. They said, customers keep asking how to print all those nice diagrams. They just want to print what the see. The want it, just like they want to print web pages from a browser. And, in a browser, they can - and in JavaFX they cannot (so it seems). At present, that makes JavaFX a difficult topic for decision makers ... :-(
    I would be very glad about opinions, hints and - if possible - some info concerning printing from the JavaFX team :-)
    Best regards,
    R. Rohm
    Edited by: r.rohm on 03.04.2012 09:06

    the viewer components are Swing components, which would require the application to be a swing application (since I cannot embed a Swing component in a JavaFX app.) - correct?I used a Swing pdf viewer in a JavaFX application.
    When I wanted to display a pdf, I just invoked the main method on the Swing pdf viewer which created a Swing JFrame and it all seemed to just work. Of course, it isn't an officially supported integration point. As long as the Swing portions of the app are being rendered in their own JFrame rather than a JavaFX managed Stage and you are careful about any threading callback issues, then displaying a Swing based report from a JavaFX app seems like it should be pretty straight-forward and a pretty quick and low-risk solution.
    http://java.net/projects/pdf-renderer
    http://java.net/projects/pdf-renderer/sources/svn/content/trunk/demos/viewer/com/sun/pdfview/PDFViewer.java?rev=140
    http://code.google.com/p/willow-browser/

  • Html files, images and JEditorPane

    Hello all,
    I've got some HTML file that need be displayed in a JEditorPane. Those HTMLs contain image references and I'm using relative paths to those jpegs, for example:
    <img src="image.GIF">
    ...where image.gif is in the same folder as the HTML file that contains the reference. Now I'm displaying this HTML file inside a JEditorPane and I get only a placeholder instead of the image; only text gets displayed properly.
    Here's how I'm constructing the JEditorPane instance:
              pane = new JEditorPane();
              pane.setEditable(false);
              pane.setContentType("text/html");
              HTMLEditorKit kit = new HTMLEditorKit();
              kit.createDefaultDocument();
              pane.setEditorKit(kit);and later...
          try {
              URL u = new URL("file", "localhost", ivHelpPath);
              pane.setPage(u);
            } catch (IOException iox) {
            }I saw on some other thread that I should be setting the document's base URL for the reference I get from getDocument(), but that does not seem to work when I use "http://localhost/" to make my URL object.
    So... help! :)
    Thanks much.

    Not sure what you're trying to do with new URL( "file" "localhost", ...
    Try this code and see if it helps you - display a page that already exists though - perhaps that's the diff?
        JTextPane() jtp = new JTextPane(); //JEditorPane();
        jtp.setEditable( false );
        JScrollPane jsp = new JScrollPane( jtp,
                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
        ( ( HTMLEditorKit ) ( jtp.getEditorKit() ) ).setLinkCursor( new Cursor( Cursor.HAND_CURSOR ) );
        jtp.addHyperlinkListener( new HyperlinkListener() {
          public void hyperlinkUpdate( HyperlinkEvent hle ) {
            try {
              if ( hle.getEventType() == HyperlinkEvent.EventType.ACTIVATED )
                jtp.setPage( hle.getURL() );
            } catch( Exception e ) {
              // do something;
        });... There's also code here that will activate hyperlinks which you may or may not want. But this will display embedded .gif files.

  • CSS and JEditorPane

    Hi,
    as a project for school, we have to make a rather basic Java webbrowser. I've used the JEditorPane, and this works fine. Although it does seems to have soms problems with applying the css, specifically inline css. For example: if i try to open google.com, it shows the logo image in different pieces, it doenst align the text (or in the wrong direction) etc etc. I've also used a HTMLEditorKit, but this also doen't do the job.
    Perhaps I'm not doing it right, so excuse me then, but if not, could you please give me some alternatifs.
    Thanks in advance!

    well, considering JEditorPane only supports HTML 3.2 and no Javascript and probably only part of CSS 1, then I wouldn't be surprised.

  • Does the default HTMLEditorKit and JEditorPane work with javascript

    Hello all,
    my question is as per title, Ive tried some basic javascript and it doesn't seem to process it. The javascript being
    <html>
      <head>
        <script type="text/javascript">
          location.href = 'someotherpage.html';
        </script>
      </head>
    </html>This doesn't seem to work as the JEditorPane doesn't fire any HTMLHyperLinkEvent events when this page is loaded. I have setEditable(false) and HTMLHyperLinkEvent 's are fired when links a clicked. Is there a flag that needs to be set to use javascript with the defaultHTMLEditorKit or can't it be used.
    thanks

    I have the problem too.
    I tested some pages,JEditorPane doesnot support javascript.
    I am finding how to make it.
    Can anyone help me?
    Thanks in advance!
    I am from China.

  • HTMLDocument and JEditorPanes

    Hey folks -
    So I've been trying to create a window that includes a JEditorPane, of content type "text/html." I would like to provide the skeleton HTML file, something like:
    <html>
        <head>
            <title>Hello World</title>
        </head>
        <body>
            blah blah blah
        </body>
    </html>I would like to load this skeleton HTML document into the JEditorPane (probably set up a new HTMLDocument and read this file), then be able to edit all of the contents of the body tag. See... I would like to edit this document for a few simple purposes, just adding headings (h4 or something of that sort) and so on. The HTMLDocument and the HTMLEditorkit do not provide ample hooks when working with Strings. The HTMLDocument has a nice method: HTMLDocument.setInnerHTML(Element elem, String htmlText), but there is no reciprocal getter: String getInnerHTML(Element elem).
    It seems to me like JEditorPane.getText provides the entire html code, but setText just sets the inner body HTML.
    I think I may be missing something... this is a simple task.
    --TB                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    manipulating html document structure is not a simple task in java. you can start learning about it here: http://java.sun.com/products/jfc/tsc/articles/text/element_buffer/index.html

  • JCombo and JEditorPane Problem

    is there anyone who can solve my problem........
    problem is very pathatic.....
    i am using two things..one is JCombo and the 2nd thing is JEditorPane.
    JCombo includes all the FontFamilyNames..
    and i want that when i select fontfamilyname from JCombo than
    the style of font family must change in JEditorPane...
    i am using the following code..
    comboN = new JComboBox();
    GraphicsEnvironment g=GraphicsEnvironment.getLocalGraphicsEnvironment();
    String names[]=g.getAvailableFontFamilyNames();
    String temp;
    for(int i=0;i<names.length;i++){
         temp=names;
         comboN.addItem(temp);
    comboN.addActionListener(new StyledEditorKit.FontFamilyAction("aaa",(String)comboN.getSelectedItem());
    so the problem is that JEditorPane is not getting the fmailyname.....it uses default...
    i think the problem is that .. when i initilized the action than at this time JCombo is not selected
    and it sends null..so thatswhy i think JEditorPane is not getting FamilyName....
    please solve my problem...

    The Swing tutorial on "Text Component Features" has a working example that does this:
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html

  • Difference between Jtextarea and Jeditorpane

    hi..
    can u pls tell me the difference between editorpane and textarea..
    and which is better to use..
    thx..

    If you refer to the Java API documentation you can find further information about these.
    [http://java.sun.com/javase/6/docs/]
    JTextArea is lightweight and designed for plain text. JEditorPane handles more than just plain text, for example, HTML.
    Steve L

  • I purchased Acrobat pdf 21/11/14 and after adding 2 files from my documents folder (both pdf files) one is printable and the other cannot be printed as the print option on the control bar does not function.I need an email address for support now

    I purchased adobe acrobat 21/11/14 I am already having problems relating to printing and creating a pdf document. I DO NOT want to waste my time reading a multitude of FAQ's I want a direct contact with a person actually in support for Adobe to be able to communicate by email and not automated messages. what is the email address for Adobe support please ?
    Andrew Morris this message dated 21/11/14 London time 14:13

    Can any member of the support team please contact me now ? My email: [email protected]

  • I want to create forms that are printable and not for web usage?

    I need to create forms that are for use in an office setting not only for web usage.  How do i do that?

    Hi,
    You may design a form in FormsCentral and then save the form as submission-enabled PDF form. Please check out this tutorial: Tutorial: Creating and distributing fillable PDF forms.
    Thanks,
    Wenlan

  • Hyperlink and JEditorPane again

    Hi there,
    i know this has been handled a few times but that doesn�t helped me much...
    so i ask it again.
    i want to write a really basic HyperlinkListener, but it does not work.
    heres my code
    HyperlinkListener myListener = new HyperlinkListener()
      public void hyperlinkUpdate(HyperlinkEvent he)
        try
          if(he.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
            editorPane.setPage(he.getURL() );
        catch(IOException ioe)
          System.out.println(ioe);
          ioe.printStackTrace();
    };why does it not work?
    theres no exception, if there would be one i would see in System.out...
    any ideas?
    thx anyway
    cu Errraddicator

    HyperlinkListener works on read-only JEditorPane's.
    Look at the documentation: setEditable(false) has to be set.

  • Best printable and reliable CD-R for professional Audio - Burnspeed

    Imation (sells AppleStore)?
    Verbatim?
    Burn-speed?
    Burn with WaveBurner or iTunes?
    Should RUN on ANY Audio-CD-Player
    Thank You!

    To a certain extent I have to disagree with the previous posts regarding burn speeds.
    If the disc is being used as a general listening copy then the burn speed is not much of an issue provided you are using decent discs and listening back on a player with robust error handling.
    However, I visited a glass mastering facility a while ago and was shown comparative error reports between discs that were written at low and high speeds. There is a massive difference in favour of disc rendered at low speeds. Discs being sent for production should either be written at the lowest permissible speed or, if you have the facility, send a DDP file.
    An interesting test is to write the same content (preferably a full length cd's worth) to two discs. One at the lowest possible speed and the other at the highest. Have a look at the surface of the two discs. The disc written at the higher speed will have a graduated shade. The lighter the shade the more error correction will need doing when the disc is being read. The disc written at the slower speed will have a consitantly dark shade - fewer errors. While this experiment is a bit like Nigel Tuffnell telling you to listen to the sustain on his guitar without strumming it, this visible representation will follow any error reading ouput using the relevant test software.

  • Efficient page size for print and SWF doc?

    I have to create an AR for a client who wishes to have it saved out as a SWF file for online usage, in addition to the printed books. I'm just wondering if there's a more efficient page size, other than 8 1/2 x 11", that would work better for online. As it is, I find the 8 1/2 x 11 size is a bit difficult to turn the pages in SWF. Comments please?
    Thanks in advance.
    Sandra

    You are right and wrong.  It stems from terminology and taking this a bit literally.  Yes, margins do not print.  However, they do print.  Typically you set margins as "guides" for page layout and it ends there.  If, you have elements that print in the margin areas, then they ( the elements ) will print.  Let's say you have a business card layout that equal 2"h x 3.5" w ( horizontal ).  You can set a margin of .25" all the way around the card as a guide. Now you apply a background bleed color of 100% Black at 2.25"h x 3.75"w ( 1/8" bleed all the way around ).  Eventhough you have a margin of .25", the Black will print entirely including the bleed.  Now, Page Margins are different.  Most desktop printers do not include bleed in an 8.5" x 11" page size.  For instance, my inkjet printer has non-printable areas or page margins that do not print.  They equal something like .139" top, left, and right with a bottom margin of .6".  Unless your printer has an option for "borderless" printing, there is a non-printable margin in the Page Setup.  This is different than layout margins which are printable and used as guides.  So, if your desktop printer does not have "borderless" printable areas ( option found in Print > Page Setup ), you'd have to print your 8.5" x 11" layout on a larger page size and then trim it down later.  Let me know if you have any other questions.  I hope I cleared it up for you.  Let me know if I didn't.

  • Pdf creation - can it be set up so the background doesn't print, and text defaults to black?

    Hi, I am creating a portfolio with a black background and white text. I am anticipating that most of the time it will just be viewed on screen, but in-case it gets printed, I want to know if there is a way that you can change the print view so that the background is not printable, and any text defaults to black. I have noticed when printing web pages this often happens, but not sure if it's possible through InDesign.
    Any replies gratefully appreciated.
    Karen

    Here is a way that this can be done: Convert the background into a button, this will allow you to set the background to be visible in PDF, but doesn't print. Note: with the button selected, you can access the visibility options from the flyout menu of the button panel. Copy the frame containing the reverse text and convert it to a button and apply the same visibility (visible in PDF, but doesn't print). Paste text in same position, make it black and send it to back (or create a layer behind everything and place text here). The black text does not have to be a button. When you export, make sure to have interactive elements selected. In PDF, background and reverse type will be viewable, but allowing the black text to print.

Maybe you are looking for

  • Troubles with HP OfficeJet 6500 E710n-z on Arch Linux

    Recently, I have tried to use my printer after five months break. It used to run smoothly on Arch Linux with hplip. However, now, I have not managed to make it print properly with hplip again. This is my configuration, as seen from the CUPS web inter

  • Payload for an exent & Source from where Event Raised

    In Oracle Applications 11.5.10 I want to subscribe to "oracle.apps.ap.event.invoice.approval" event. I want to add a custom "Rule Function", I require to know the payload for this event. And I want to know from where is this event raised in the base

  • (Deployment) Minimum Software required for BUILD server and IIS WebServer

    We have a simple .Net SDK application written using VB-2005 and the Crystal Reports XI (R2) DEVELOPER package. The RPT files are posted on our BOE-XI (R2) server, and are called using the View-On-Demand method from the Page Server (similar to the SDK

  • How to use disk utility with mavericks

    Since I upgraded to Mavericks via download, how do I run disk utility on the startup drive? In the past I'd restart my computer with the system disc but that's not an option. So what's the procedure now? Thanks in advance.

  • Connection finally fixed, thanks BT!

    After weeks and weeks of having a bad connection I had a total loss of connection, after a bad morning with openreach not showing up the nice guy at BT actually got someone out that night to fix my connection. This is the end result http://www.speedt