Modify HTML of the document of the rendered page and reload

Currently i am loading a url in javafx through webengine.load(url). My requirement is to keep the styling in tact with the original page. However, once the page is rendered, the fonts are not loaded and i am unable to increase the font sizes. I worked through the following steps to achieve this.
1. Add a listener through getLoadWorker method for web engine and get the document object when the state is SUCCEEDED.
2. Transform the document to a html string which gives me the whole HTML of the page in a string including the css.
3. Then i do a replace on the css part with the actual location of the font files (absolute path url) and reload the html through loadContent method.
With this, i am able to get the fonts loaded properly.
Problem:
1. I end up with a infinite loop when i use the "webEngine.loadContent(string, "text/html")" inside the getLoadWorker method.
2. I tried to do that outside the getLoadWorker method before the webEngine.load(url) but in this case the replace html body string is coming as null.
Any help on how to achieve this?? Below is my code:
      webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
            String htmlBody = null;
            @Override
            public void changed(ObservableValue<? extends Worker.State> observableValue, Worker.State prevState, Worker.State newState) {
                //To change body of implemented methods use File | Settings | File Templates.
                //String htmlBody = null;
                int count = 0;
                if (newState == Worker.State.SUCCEEDED) {
                    browser.requestFocus();
                    // Get the document object from Engine.
                    Document doc = webEngine.getDocument();
                    try {
                        // Use Transformer to convert the HTML Object from the document top String format.
                        Transformer transformer = TransformerFactory.newInstance().newTransformer();
                        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
                        transformer.setOutputProperty(OutputKeys.METHOD, "html");
                        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                        transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
                        StringWriter outWriter = new StringWriter();
                        transformer.transform(new DOMSource(doc),new StreamResult(outWriter));
                        StringBuffer sb = outWriter.getBuffer();
                        htmlBody = sb.toString();
                        // Replace the font-family attribute in the style section to the actual URL of the font being used.
                        htmlBody = htmlBody.replace("font-family: medium", "font-family: url(http://1.10.30.45:8080/fonts/Md.ttf)");
                        // Load the new HTML string to the Engine.
                        //webEngine.loadContent(htmlBody, "text/html");
                    } catch (Exception ex) {
                        ex.printStackTrace();
        webEngine.load(url);
        //add the web view to the scene
        getChildren().add(browser);

James,
I tried the document manipulation but was unable to override the css that was already applied. I downloaded and used jdk 8 which has the latest version of javaFX which fixed the font loading issue. Now i can see all the custom fonts and everything getting loaded as part of css.
However, when i try to capture the state of the worker, it stays in the running and not changing to success. First few instances, the page was loaded successfully but then it stopped. Any idea if this is due to the new javaFX version of jdk8? Below is the code snippet:
       webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
            @Override
            public void changed(ObservableValue<? extends Worker.State> observableValue, Worker.State prevState, Worker.State newState) {
                //To change body of implemented methods use File | Settings | File Templates.
                System.out.println(newState);
                if (newState == Worker.State.SUCCEEDED) {
                    browser.requestFocus();
                    // Get the document object from Engine.
                    Document doc = webEngine.getDocument();
                    System.out.println(doc.getDocumentURI());
        webEngine.load(url);
        //add the web view to the scene
        getChildren().add(browser);
The output is
SCHEDULED
RUNNING
and nothing after that...

Similar Messages

  • I am trying to save a document with the new pages and it will only save as a zip file any ideas on how to change this?

    I am trying to save a document with the new Pages and it is only saving as a ZIP file anyone know how to fix this or choose a different file type?

    Take a look at the FileSelector
    First make sure the FileSelector is expanded so you can see the directory and sidebar. That's what the little disclosure triangle up by the filename is for. Once the FS has been expanded to look like the above picture, look to see what subdirectory has been selected. Use the SideBar to select an appropriate one.

  • I have just upgraded to the new OS X V. 10.10.3 but cannot access my iCloud Drive documents using the resident Pages and Numbers software on my MacBook Pro. Help needed.

    I have just upgraded to the new OS X V. 10.10.3 but cannot access my iCloud Drive documents using the resident Pages and Numbers software on my MacBook Pro. Help is needed to access those documents using the resident software on my MacBook Pro rather than the Beta software on iCloud.com.

    I have iCloud Drive set on the Finder sidebar and use that to open the Numbers Spreadsheet on iCloud.
    OSX 10.10.3
    Best.

  • I am trying to get the artwork for an album. "Artwork Not Modifiable" appears in the artwork box and it doesn't let me drag artwork.  What can I do to fix this?

    I am trying to get the artwork for an album. "Artwork Not Modifiable" appears in the artwork box and it doesn't let me drag artwork.  What can I do to fix this?

    Words simply can't describe what a kludge iTunes has become.  Every time Apple fixes one problem, a dozen more pop up.  It's like trying to hold a bunch of ping-pong balls under water simultaneously.
    The immediate problem is that Lion with iTunes buggers the artwork.  Some it loses, some it can't find, and some appears and disappears like the Flying Dutchman (look it up...).
    The bigger issue is that so MUCH of iTunes is bad, in general.  Apple trys to use iTunes as a Swiss Army knife, using it to synch iPhones, iPads, etc.  The app has become so generic that it is actually good at nothing.
    The interfrace is kludgy; moving the library from one location to another virtually guarantees a wasted day and usually lost art, music, or backups.
    In general, Apple's hardware and software is relatively ergonomically designed.  I-Tunes, however just plain SUUUUUUUUUUUUCKS!

  • When I convert a document from wordperfect to PDF it only converts the 1st page and ignores the othe

    When I convert my wordperfect document to PDF it only converts the 1st page and does not even show the other pages.  This is a new development because in the past it has converted all pages. 

    Hi KP122,
    Is it document specific or occurs with all the documents.
    What is the extension of the word perfect documents?
    You can convert the following File types to PDF
    Microsoft Word (DOC, DOCX)
    Microsoft PowerPoint (PPT, PPTX)
    Microsoft Excel (XLS, XLSX)
    Microsoft Publisher (PUB)
    text (TXT)
    Rich Text Format (RTF)
    Adobe PostScript® (PS)
    Adobe InDesign (INDD)
    image (bitmap, JPEG, GIF, TIFF, PNG)
    OpenOffice and StarOffice presentation, spreadsheet, graphic, and document files (ODT, ODP, ODS, ODG, ODF, SXW, SXI, SXC, SXD, STW).
    To convert a file type not listed above, use Adobe CreatePDF Desktop Printer.

  • Firefox 23.0.1 keeps loading the YouTube page and prevents access to My Profile

    I do not know if this is a problem with the Firefox browser version 23.0.!But the problem of Firefox it keeps loading the YouTube page and even I can not do anything because there was a message saying still loading the YouTube page!
    go to my topic http://support.emsisoft.com/topic/12328-strange-new-problem-in-access-to-youtube/

    here you go
    Application Basics
    Name
    Firefox
    Version
    23.0.1
    User Agent
    Mozilla/5.0 (Windows NT 5.1; rv:23.0) Gecko/20100101 Firefox/23.0
    Build Configuration
    about:buildconfig
    Extensions
    Name
    Version
    Enabled
    ID
    RealDownloader
    1.3.3
    true
    {DF153AFF-6948-45d7-AC98-4FC4AF8A08E2}
    Important Modified Preferences
    Name
    Value
    browser.cache.disk.capacity
    358400
    browser.cache.disk.smart_size.first_run
    false
    browser.cache.disk.smart_size.use_old_max
    false
    browser.cache.disk.smart_size_cached_value
    358400
    browser.places.smartBookmarksVersion
    4
    browser.startup.homepage_override.buildID
    20130814063812
    browser.startup.homepage_override.mstone
    23.0.1
    dom.mozApps.used
    true
    extensions.lastAppVersion
    23.0.1
    network.cookie.prefsMigrated
    true
    places.history.expiration.transient_current_max_pages
    13196
    plugin.disable_full_page_plugin_for_types
    application/pdf
    plugin.importedState
    true
    privacy.sanitize.migrateFx3Prefs
    true
    Graphics
    Adapter Description
    Mobile Intel(R) 945 Express Chipset Family
    Adapter Drivers
    igxprd32
    Adapter RAM
    Unknown
    Device ID
    0x27ae
    Direct2D Enabled
    Blocked for your graphics driver version.
    DirectWrite Enabled
    false (0.0.0.0)
    Driver Date
    2-15-2008
    Driver Version
    6.14.10.4926
    GPU #2 Active
    false
    GPU Accelerated Windows
    0/1 Basic
    Vendor ID
    0x8086
    WebGL Renderer
    Google Inc. -- ANGLE (Mobile Intel(R) 945 Express Chipset Family)
    AzureCanvasBackend
    skia
    AzureContentBackend
    none
    AzureFallbackCanvasBackend
    cairo
    JavaScript
    Incremental GC
    true
    Accessibility
    Activated
    false
    Prevent Accessibility
    0
    Library Versions
    Expected minimum version
    Version in use
    NSPR
    4.10
    4.10
    NSS
    3.15 Basic ECC
    3.15 Basic ECC
    NSSSMIME
    3.15 Basic ECC
    3.15 Basic ECC
    NSSSSL
    3.15 Basic ECC
    3.15 Basic ECC
    NSSUTIL
    3.15
    3.15

  • How do I make a table of contents for a collection of six short stories that is after the legal page and NOT in the front on an unnumbered page?

    How do I make a table of contents for a collection of six short stories that is after the legal page and NOT in the front on an unnumbered page?
    When I first started I made a title page and then pasted in my first story from a .TXT file. After cleaning up I went back to the front a couple of empty lines ahead of the story and typed in the story title.  Unlarged the font size and centered it, then

    You can't do that. This is what the Pages User Guide, downloadable from your Pages Help menu, says:
    Creating and Updating a Table of Contents
    Each table of contents (TOC) you create using a Word Processing template lists only the content that follows it, up until the next table of contents. If you want a master table of contents for the entire document, it must be the only table of contents, and it must be at the beginning of the document.
    You can do it manually though.

  • Issue in Customizing the Logon Page and Replacing the Logon Panel Image

    I have facing problem in Customizing the Logon Page and Replacing the Logon Panel Image in Hyperion Workspace 11.1.2.1. I have tried multiple time.
    First Replacing the Logon Panel Image. I have following the steps given in admin guide of EPM workspace on page 25 and they are as follow
    To replace the image that is displayed on the logon panel:
    1 Create an image file named logon_panel.gif with dimensions that match previous image.
    2 Rename the installed version of logon_panel.gif to logon_panel.gif.original in
    %EPM_ORACLE_HOME% /common/epmstatic/bpmui/themes/<do for each
    theme>/images_global. Move the logon_panel.gif file that you created in step 1 to this
    directory.
    3 Clear your browser cache.
    Note: You do not need to restart the Hyperion Foundation Services - Manager Server.
    But still I am getting the same default image on log in page.
    The other problem I am facing is Customizing the Logon Page.
    I am following the steps given in admin guide of EPM workspace on page 17 and they are as follow:
    To customize the logon page:
    1 Follow instructions in the topic Extract a file in the Workspace Web Application.
    2 Backup file <temp directory>/war/WEB-INF/lib/bpmui.jar.
    3 Extract the contents of <temp directory>/war/WEB-INF/lib/bpmui.jar to <temp
    directory>/bpmui_jar/.. (*)
    4 Backup file <temp directory>/bpmui_jar/WEB-INF/classes/com/hyperion/bpm/
    Resources_en.properties.
    5 Edit file <temp directory>/bpmui_jar/WEB-INF/classes/com/hyperion/bpm/
    Resources_en.properties.
    6 Search for the property bpm.logonCopyright.
    Customizing the Logon Page 17
    7 Modify the text to the right of the equal sign. Use \n to get a new line.
    8 Save your changes.
    9 Repeat step step 1 through step step 8 for all the other Resources_xx.properties files for other
    locales.
    10 Jar the contents of <temp directory>/bpmui_jar/ to <temp directory>/war/WEBINF/
    lib/bpmui.jar.
    11 Continue with the topic, Re-package a file inside the Workspace Web Application.
    For the first part I am following
    Extract a file in the Workspace Web Application
    ä To extract files in Workspace Web Application:
    1 Stop the service for Hyperion Foundation Services - Managed Server.
    2 Backup file <EPM_ORACLE_HOME>/products/Foundation/workspace/
    InstallableApps/workspace.ear.
    16 Administration Tools and Tasks
    3 Using an unarchiving utility, extract the contents of <EPM_ORACLE_HOME>/products/
    Foundation/workspace/InstallableApps/workspace.ear into a <temp
    directory>.
    4 Create <temp directory>/war.
    5 Extract the contents of <temp directory>/workspace.war into <temp directory>/
    war.
    6 Update the file you are patching under <temp directory>/war. as direct in it.
    But I am not able to find file bpmui.jar in step 3 of above one (*). I have marked for your connivance.
    I am able to see these file in that directory
    dynamichelp.jar
    workspace.jar.
    Can anyone provide help on this. Platform I am using is LINUX

    You seem to have posted this in the wrong forum. This forum is for Oracle Enterprise Manager - not Hyperion.

  • I forgot my ipod 5 passcode. i do all the steps itunes tells my to do. when i get to the right page and it says "restore ipod" i click it. it works for about 11minutes left and then it says like 'error cod erXX011210021" PLEASE HELP ME!!!!!!!!!!!

    my iPod is I 5th generation. I forgot my passcode and typed in the wrong thing too many times, so now on the lock screen it says "connect to iTunes" I did all the steps your supposed to. I unplugged all cord from iPod connecting to my computer, I held the home button and plugged my iPod back in, and then I keep holding the home button until the iTunes sign showed up. I got to the right page and then clicked restore. A small window came up saying " restore and update" I clicked it, I agreed to the terms and agreements and the updating started. The updated finished with =out a problem. I t was when I clicked "restore " that I had a problem. The restoring lasted until I had about 10 or 11 minutes left. that is when I saw a alert of my screen saying "iTunes could not finish restoring,. an unknown error occurred. error code: 0xE8000065" I tried restoring and updating my iPod about three or four times now! PLEASE, PLEASE, PLEASE HELP ME!!!!!!!!!!!!!!!!!!!!!!!!!!!

    See this support document, iTunes: Resolve USB-related alerts - Apple Support or this one regarding the same error and Windows. iOS: Unknown error containing '0xE' when connecting to a Windows PC - Apple Support

  • How to make fields grow dynamically within the same page and in column wise

    Hi,
    Like the newspaper format: Where contents of news are shown columns wise.
    We need to make the fields in a page grow column wise within that same page.
    For example, in a page:
    Column 1 Column 2
    ASDASDASDGKASHDGKAA | ASDFASGFHSJFAJKSD
    ASDFASDFASDJFASGJKDFHA | ASDFASDASDFASDFASD
    AFSDFASDFASDHGFKASDFASD | ASDFASDFASDFASDFASDFA
    ASDFSDGFJASHDGFJKASHDGKFAS |
    ASDFAGASDHFKASHDGFHASDJKFHASJKHF |
    ASDFHASGDKFASDJGHFASDFJKSDGFJKAGSDJ |
    If the Column 1 is full with the fields in the page it should start filling the column 2 which is also in the same page.
    If the Column 2 is also full then only it should move to the next page and should continue the same scenario.
    Please suggest a better way to do this in the Adobe Output Designer.
    Thanks and regards,
    Gurunath V.
    E-Mail: [email protected]
    P.S: Please also mail to my e-mail ID.

    Hi Gurunath, if you steel need a solution on this problem, I think this could help:
    1- place two fields on the form (JF01, JF02), one under each other.
    2- Make two subform with them (Sline1, Sline2)
    3- Make the field JF02 expand on same subform.
    4- Modify the preamble in this way:
    ^define group:D_line1 \field$POSITION\reserve"0.333",in\subformSline1.\positionsave,"first_line"
    ^define group:JF01!OnOverflow \groupG_Sline2.\fieldJF02.
    ^define group:G_Sline2!OnBOF \positionrestore,"first_line"\positionright,"3.65",in
    In the data file put all the text in JF01.
    -The first line say:
    When JF01 is called, save it's y position (\positionsave,"first_line")
    -The second line means:
    when the text overflow JF01 put it in JF02.
    (cause JF02 overflow on itself all the remaining data is overflowed in JF02)
    -The third line means:
    if JF02 arrives at the end of the page (OnBOF), restore the saved position ( \positionrestore,"first_line") and move to the right of "3,65" inches (\positionright,"3.65",in).
    In other words, when JF02 arrive at the and of the age, the next field JF02 is positioned at the same height of JF01 and is shifted on the right
    Take care that in this way JF02 cannot anymore go o a new page.
    Hope this help.
    Andrea

  • How do i mail merge with the new Pages and Numbers?

    How do I mail merge with the new Pages and Numbers?
    On Pages 09 I have a document that draws variable data from a spreadsheet created in Numbers.
    With the new Pages and Numbers program update, my links are lost and I am unable to see how to correct this.

    Thanks Peter,
    very disappointing.
    My Pages 09 keeps opening in the new one.
    I dont think they want me to be a loyal customer anymore.
    They changed Final Cut Pro, so now I use Premier Pro
    Aperture 3 has been left behind so now I moved to Lightroom 4.
    And now Pages 5 does not have a vital component, so back to Word.
    Sad day
    Thanks again

  • I have website that on the Home page and the home only. When opened in Chrome or Safari the last 3 menu buttons do not work.

    I have website that on the Home page and the home only. When opened in Chrome or Safari the last 3 menu buttons do not work. But work fine in Explorer and Firefox.Its weird. The site is baystatewiring.com see if you have the same problem. Does anyone have a idea?

    Code errors could explain the problem.  You're missing a closing </div> tag for container.
    [Invalid] Markup Validation of http://baystatewiring.com/index.html - W3C Markup Validator
    Try changing your link CSS from display: inline to display: inline-block.
    Nancy O.

  • My 4630 printer only prints the first page and then cancels

    My 4630 printer only prints the first page and then cancels the rest of the document. I have to manually choose to print one page at a time. If I try to print a document, it prints the first page and then cancels printing the rest of it. It's driving me crazy. I just bought this printer and, other than that, it works fine. I tried the HOTFIX link that was attached to a previous link as well as other microsoft updates, however, am still having no luck.

    Hi @ImaniL,
    I believe I have something that could assist with your printing issue
    My colleague, @JERENDS, has created these instructions to help with issues similar to yours, and I believe his instructions will help resolve your printing issue!
    Let me know how things go, and if that doesn't fix it, I will certainly see what else I can find for you
    Please click “Accept as Solution ” if you feel my post resolved your issue, as it will help others find the solution faster
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    **MissTeriLynn**
    I work on behalf of HP

  • How do I know if my iphone has successfully been backed up to my iTunes? I plugged it in and it said it backed up and I did a sync, but when I am looking through the summary page and I am not sure that all of my data got backed up. Please help!!

    I have never backed up my iphone to my itunes because I always used the cloud. However, a few months ago, my wifi disk in my phone burned out so the Apple Store told me to back up everything to my itunes. I am going today to get the iphone 6 so I connected my phone (iphone 4S) to my itunes and I backed up and synced. However, when I look throughout the summary page and click in different areas (Photos, Movies), I don't see any of my data -- it is still asking me to Sync from iPhoto or to sync from another location. By backing up & syncing my phone, did all of my data get saved? Or do I still need to do more steps?
    Sorry for the long winded question, I am just so nervous to get a new phone and plug it in to be restored and not have any of my pictures, videos or contacts, etc. Any help would be so so appreciated!

    Thank you again for all of your help!! I really appreciate it!
    I think I am following -- I was able to upload to my iPhoto and all photos and videos are there that is a plus! I tried to create an Event in my iPhoto and put all of my photos in that event but for some reason, now my iTunes it not recognizing that Event in my iPhoto. It is not allowing me to import just that event at the moment but I may be doing something wrong. At least all of my pics and vids are in iPhoto so that is a plus and I know they are at least saved somewhere. Just for some reason, my iTunes it not locating the event that I created with only those photos.
    Thank you for letting me know about my contacts! How do I know if I have the contacts app?
    Also, I had no clue that my iCloud could be backed up via cellular data! However, is this a new feature with the most updated iOS?? Unforutnatly I am like 2 iOS updates behind because I don't have enough storage on my phone. I still get the notification that my phone needs to be plugged in and connected to wifi in order to back up to the cloud :-(
    How can I sync using USB? Right now when i click on the info tab for my iPhone in my iTunes this is the answer that I get -- I am a little unclear as to what it means.
    Sync Contacts:
    Your contacts are being synced with you iPhone over the air from iCloud. Over-the-air sync settings can be changed on you iPhone
    Sync Calendars:
    Your calendars are being synced with you iPhone over the air from iCloud. Over-the-air sync settings can be changed on you iPhone

  • I had to change my Apple ID and password in itunes. Now my icloud doesn't work and I can't update my apps on my iPhone. I have looked at suggestions on the community pages and apple suggestions but none of them are relevant to iOS 8.1.2  icloud just

    I had to change my Apple ID and password in itunes. Now my icloud doesn't work and I can't update my apps on my iPhone. I have looked at suggestions on the community pages and apple suggestions but none of them are relevant to iOS 8.1.2
    icloud just keeps bringing up my old email address & asking for my old password which doesn't exist anymore and when I try to sign out of icloud it wants my old password, when I tried to change my primary email back to the old one it wants me to verify it through an email address that doesn't exist. Please can you help me sort out this nightmare.

    Hi skippy2012trev,
    Welcome to the Apple Support Communities!
    I understand that you updated your Apple Id and password but now you are being prompted for the old information in iCloud. You are on the right track by changing the Apple ID back to the previous email address temporarily so that you can sign out. You should not need to verify the email address. After you edit the Apple ID back to the old email address and then sign out of iCloud on your iPhone, edit the Apple ID back to the address you would currently like to use. There is no need to change the password again, only the email address, unless you prefer to update the password again.
    If you're asked for the password to your previous Apple ID when signing out of iCloud - Apple Support
    Change your Apple ID temporarily
    If signing out and back in to iMessage or FaceTime didn't help, try these steps:
    Change your Apple ID to the Apple ID you used previously. You shouldn't need to verify the email address.
    Tap Settings > iCloud. Complete these steps only if the Find My [Device] setting is turned on:
    Scroll down and tap Sign Out, then tap Sign Out to confirm. If you're using iOS 7 or earlier, tap Delete Account, then tap Delete to confirm.
    Tap Keep on My [Device] or Delete from My [Device]. In either case, your data remains in iCloud and will be updated on your device when you sign in to iCloud again.
    Enter the password for your previous Apple ID.
    Change your Apple ID to the new email address that you want to use. You'll need to verify the email address.
    Return to Settings > iCloud and sign in with your new Apple ID.
    Cheers,
    Joe

Maybe you are looking for