Modify the HTML of the document of the rendered page and reload

Currently I am loading a url into javafx through webengine.load (url). My requirement is to keep the style in tact with the original page. However, once the page is rendered, the fonts are not loaded, and I cannot increase the font sizes. I worked through the following steps to achieve this.

1 Add a listener via the method getLoadWorker for web engine and recover the document object when the State is MANAGED.

2 transform a html string that gives me the whole HTML code of the page in a string including the css.

3. then I do a replacement on the part of css by the actual location of the font (absolute path url) files and reload the HTML through loadContent method.

With that, I'm able to get properly loaded fonts.

Problem:

1. I find myself with an infinite loop when I use the "webEngine.loadContent (string," text/html")" inside the getLoadWorker method.

2. I tried to do that, outside the method getLoadWorker before the webEngine.load (url) , but in this case the string replacement body html is coming as null.

Any help on how to achieve this? Here 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 the body of the methods implemented using file | Settings | Templates files.

String htmlBody = null;

int count = 0;

If (newState == Worker.State.SUCCEEDED) {}

browser.requestFocus ();

Get the document of the engine object.

Doc document = webEngine.getDocument ();

try {}

Transformer allows you to convert the object HTML from a string format top of page document.

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} dash-amount","4" ');

OutWriter StringWriter = new StringWriter();

transform. Transform (new DOMSource (doc), new StreamResult (outWriter));

StringBuffer sb = outWriter.getBuffer ();

htmlBody = sb.toString ();

Replace the attribute of the font family of the style section to the actual URL of the font used.

htmlBody = htmlBody.replace ("font family: way", "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 display of web pages to the scene

getChildren () .add (browser);

What is a single page load?

If so, you should be able to solve the problem with

observableValue.removeListener(this);

just before calling

webEngine.loadContent(htmlBody, "text/html");

Otherwise, you may have to do something pretty ugly: for example, to have a "loadingTransformedHTML" that is false at the start flag. Then in your method changed (...) do

if (newState == WorkerState.SUCCEEDED) {
     if (loadingTransformedHTML) {
          loadingTransformedHTML = false ;
     } else {
          browser.requestFocus();
          // ...
          loadingTransformedHTML = true ;
          webEngine.loadContent(htmlBody, "text/html");
          // ...
     }
}

Tags: Java

Similar Questions

  • Normally, when you open the page palette in InDesign, it is divided into two. The upper part is where is the master page (and a page named none), while the lower part is where are the actual pages of documents. Unfortunately, when I opened my palette of p

    Normally, when you open the page palette in InDesign, it is divided into two. The upper part is where is the master page (and a page named none), while the lower part is where are the actual pages of documents. Unfortunately when I opened my palette (InDesign CS 6 on a Mac), there is no upper and lower part of the page-only the lower part is displayed. When I put my cursor on my pages, it tells me that I "Applied A-master".

    Why not my top shows (A-master and none)? The pages that I don't "Act" like master pages - for example, I can't get past page numbering.


    Any help is appreciated. Thank you!

    It looks like the upper part may be in a State reduced - the line was pulled up.

    Just of the cursor on the line that separates the upper and lower sections, and drag it to the bottom.

  • I'm about to lose my mind.  All the scenario had it.  Is returned to modify the cover page to include copyright, address and e-mail submission to a contest.  It was after that, that page is moved a whole page, so my Page 1 was empty.  I tried t

    Is there someone with a clue out there, who can help me at all?

    As the title of this post is a little truncated, I guess the question here is the blank page just after the title page and delete this page.

    Workarounds may be:

    -You can try to delete blank lines in the top (title page) page to see if it removes this page

    -This page is an extension of the title page, it can be removed through Production-> remove the title Page. (please copy the contents of the title page also before removing)

  • I clicked on the source page and remove nodes with the web developer and removal became permanent. EBay does not load pictures. How to fix?

    The problem is on my desktop and my laptop. I got a little happy click on my desktop and click the Web Developer. I tried to remove an ad really annoying flash on the side of the screen. I think I entered in the source page and remove the node. I really don't know what happened, but stopped loading for ebay pictures and everything is a list written on the side of the page. I deleted the cache and cookies. I have reset mozilla. I uninstalled and reinstalled mozilla. Laptop is not immediately affected, but now having the same problem.

    It is a very strange problem.

    Any changes made with the web developer tool will save and should be cleared when the page is reloaded.

    Try disabling graphics hardware acceleration. As this feature has been added to Firefox, it has gradually improved, but there are still some problems.

    You will have to perhaps restart Firefox for it to take effect, so save any work first (e.g. you compose mail, documents online that you are editing, etc.).

    Then perform the following steps:

    • Click on the orange top left Firefox button, then select the 'Options' button, or, if there is no Firefox button at the top, go to tools > Options.
    • In the Firefox options window, click the Advanced tab, and then select 'General '.
    • You will find in the list of parameters, the checkbox use hardware acceleration when available . Clear this check box.
    • Now restart Firefox and see if the problems persist.

    In addition, please check the updates for your graphics driver by following the steps in the following knowledge base articles:

    This solve your problems? The report please come back shortly.

  • Win 10 update placed on the updates page, and does not update us '.

    We have a HP while a win 7 64-bit home premium.  We do not want to win 10 and hid all the updates that relate to what we know.  Now, to win 10 placed itself on the update page and wants to be installed.  It will not install to us of new updates of win 7.  What can we do?  Don't really like how microsoft has tried to impose it on everyone.  Please give us an answer.  Thanks Mammy37

    I had the same problem and used http://blog.ultimateoutsider.com/2015/08/using-gwx-stopper-to-permanently-remove.html

    I tried to hide the upgrade, but it came back in return. Finally forced to use the above with 'success' on the computers that I don't want to upgrade to Windows 10.

  • I am trying to download CS2 to a new IMAC (no access to the old) I was on the download page and have all the instructions, but not able to actually download?

    I am trying to download CS2 to a new IMAC (no access to the old) I was on the download page and have all the instructions, but can't see a way to actually download?

    See the following...

    CS2: Error: unavailable activation server | CS2, Acrobat 7, hearing 3 -.

    l http://helpx.adobe.com/x-productkb/Policy-Pricing/Creative-Suite-2-activation-end-Life.htm

    https://helpx.Adobe.com/Creative-Suite/KB/CS2-product-downloads.html

  • How to create the new page in the master page and make reference to the reference text framework previous page id?

    I have problem to apply/create an element of the master page and how to run the previos page text block to create the page text

    InterfacePtr<IPageSetupPrefs> iPageSetupPrefs (,static_cast<IPageSetupPrefs * > (:QueryPreferences() IID_IPAGEPREFERENCES, docRef)));

    if (iPageSetupPrefs is nil) {

    Assert (iPageSetupPrefs);

      break

    }

    InterfacePtr<ICommand> iNewPageCmd (CmdUtils:kNewPageCmdBossCreateCommand());

    if (iNewPageCmd is nil) {

    Assert (iNewPageCmd);

      break

    }

    InterfacePtr<IApplyMasterCmdData> iApplyMasterCmdData (iNewPageCmd, IID_IAPPLYMASTERCMDDATA );

    if (iApplyMasterCmdData is nil) {

    Assert (iPageCmdData);

      break

    }

    InterfacePtr<IPageCmdData> iPageCmdData (iNewPageCmd,UseDefaultIID());

    if (iPageCmdData is nil) {

    Assert (iPageCmdData);

      break

    }

    Int32 numPagesToInsert = 1;

    PMRect pageSizeRect = iPageSetupPrefs->GetPageSizePref();

    Int32 pos = iPageCmdData->GetNewPageInsertPosition();

    ISpreadGeometry InterfacePtr<IGeometry> (spreadList->QueryNthSpread(0));

    if (iSpreadGeometry is nil) {

    Assert (iSpreadGeometry);

      break

    }

    spreadUIDRef =:GetUIDRef(iSpreadGeometry);

    PMRect dfltPMRectPageSize = iPageSetupPrefs->GetPageSizePref();

    PMReal pageWidth is dfltPMRectPageSize. Right () - dfltPMRectPageSize. Left ();

    PMReal pageHeight is dfltPMRectPageSize. Bottom () - dfltPMRectPageSize. Back to top ();

    PMRect usrDefPMRectPageSize (0, 0, pageWidth, pageHeight);

    K2Vector< PMRect> pageBoundingBoxes;

    for ( int32 i = 0; i < numPagesToInsert; ++ i) {

    pageBoundingBoxes. push_back (usrDefPMRectPageSize);

    }

    iPageCmdData->SetNewPageCmdData(spreadUIDRef, numPagesToInsert, pos +1, & pageBoundingBoxes, nil);

    / / CreateSpreadFromSpread (docRef, spreadUIDRef);

    InterfacePtr<IBoolData> iBoolData (iNewPageCmd,UseDefaultIID());

    if (iBoolData is nil) {

    Assert (iBoolData);

      break

    }

    bool16 allowShuffle;

    if (this->GetShufflePref(allowShuffle, docRef) iskFailure) {

      break

    }

    iBoolData->Set(allowShuffle);

    CmdUtils:ProcessCommand(iNewPageCmd);

    Above code, able to create a page but the problem in applied master page?

    Using document Pages face?

    I think that your posToInsertAt for IPageCmdData::Set is incorrect.

    If the doc does not have facing Pages, posToInsertAt = 1;

    If doc is facing Pages and page insertion is the left-hand Page, posToInsertAt = 2;

    If doc is facing Pages and insert page is the right Page, posToInsertAt = 1;

    posToInsertAt = spread-> GetNumPages();

    newDocCmd and newDocCmdData are not used, you can delete these.

  • What on Earth is the lego man ' click me ' on the home page, and why he doesn't something when I click on?

    What on Earth is the lego man ' click me ' on the home page, and why he doesn't something when I click on?

    Click Me logo is part of the promotion of the Humble Mozilla Bundle - clicked once you should be able to control the character with the "WASD" and "IJKL" key.

    Citing the-edmeister https://support.mozilla.org/en-US/questions/1025706

    Who click Me the game is part of the promotion of the Humble Bundle of Mozilla on the default Home Page [topic: Home], which loads from the Mozilla servers in the "Brand Logo" section (DIV) of about: House. A feature that has been used in Firefox 29 [IDE] just before the start of the Olympic Games.

    Also, part of this promotion is addressed in the "excerpt" under the container of the research on the topic: homepage.

    If you want to prevent the section "Brand Logo" (and the "snippet" under the reservoir of research) never to be seen again, you can install this UserStyle and elegant. https://userstyles.org/styles/104673/about-home-hide-snippets-and-hide-brand-logo

  • Update of Firefox, and now all of the web pages and icons are inflated. How do I put back it as it was?

    Update of Firefox, and now all of the web pages and icons are inflated. How do I put back it as it was?

    Hello

    Firefox on Windows is now after display, scaling options that can make the biggest text on screens at high resolution.
    You can adjust the resolution of your screen.
    To change it follow these steps:

    • Type of topic: config in the Firefox address bar and hit the Enter key.
    • If the warning that this might void your warranty , click I'll be careful, I promised.
    • Search for layout.css.devPixelsPerPx

    • Double-click layout.css.devPixelsPerPx to edit its value. The default value is - 1.0 in Firefox 22 and above. Change it to 1.0 to run as in previous versions of Firefox.

    If necessary, further adjust the value of 0.1 or 0.05. Values between 1.0 and around 0.5 to reduce the size of the elements. Use a value greater than 1.0 to increase the size. For example, a value of 1.25 will increase the font size of the 125% to account for the default DPI setting in Windows 8. Check the value that you enter. Definition of a value that is too small will take everything away and too high will explode things.

    If the web pages should always be adjusted so you can watch the extension Default FullZoom Level or NoSquint .

    To adjust the font size for the user interface, you can use the extension of theme font & size changer .

    This solve your problems? Please report to us!

    Thank you.

  • I downloaded Firefox 5 and discovered that it disabled my McAfee SiteAdvisor of incompatibility becauce. How do I remove the Firefox 5 and reload my old Firefox 4, so I can reactivate the SiteAdvisor.

    I downloaded Firefox 5 and discovered that it disabled my McAfee SiteAdvisor as inconsistent. No compatible version of the SiteAdvisor has been found. How do I remove the Firefox-5 and reload my old Firefox 4 so I can reactivate the SiteAdvisor?

                          Thank you
    

    McAfee Site Advisor 3.3.1 expansion was the number 2 cause accidents in one of the versions beta Firefox 5.0 and Mozilla Blocklisted it. This extension is disabled in Firefox 5, Firefox 6.0beta and Firefox 7.0alpha versions. McAfee is working on a new version of re-written extension of the Site Advisor to solve their problems - ETA is mid to late July.

    https://Bugzilla.Mozilla.org/show_bug.cgi?id=660111

    Thanks to the-edmeister

  • Printer Photosmart 5520 problem:, I have access to the secure page and cannot open a session

    My printer does not print in black. I followed all the instructions to fix it. I can't go down loard that assistance because it is a Vista. I get to the secure page and he asked my name and my password. I am the administrator, but it does not accept my names or passwords and blocking me. What name and password it seeks?

    Hi @arts4pat,

    Welcome to the Forums of HP Support!

    I see that you get a secure page and that you are unable to print black on your HP Photosmart 5520 e-all-in-one printer. I'd be happy to help you with this.

    I like that you get the login screen for the Built-in Web server for the printer. Is this correct? This seems to indicate that someone has put a username and password on the printer, for security reasons. If you don't know what are the connection information, the only way to remove this is to do a factory reset on the device. I can send you this information in a private message. In the forum next to your handle name simply click on the envelope to see.

    That being said, I would like to start here. Please, try the steps in this guide, the printer prints blank Page or fact not printing black or color ink for HP Photosmart 5520 and Deskjet Ink Advantage 5520 series e-all-in-one printer.

    NOTE: This problem may be caused by problems with the ink cartridge print head or with the printer ink system.

    If you have completed all the above steps and your product still has a problem, the printer service.

    Contact HP for service in all countries except Asia-Pacific.
    First, check your product warranty to check your warranty printer status and then go to contact HP support to find an authorized dealer or to schedule a repair.
    Cost of repair out-of-warranty printers may apply.

    What you can do, is to use the following link to create yourself a file number, then call and it can help to expedite the appeal process:
    Step 1. Open the link: www.hp.com/contacthp/
    Step 2. Enter the product number or select Auto detection
    Step 3. Scroll up to "still need help? Fill out the form to choose your
    contact options»
    Step 4. Scroll down and click on: contact HP options - click Get phone
    number
    File number and phone number are displayed.

    I hope this helps. Good luck!

  • When I turn on my computer it tells me that I need to activate windows. I click on 'YES' it takes me to the activation page and says that Windows is already activated.

    Windows XP Activation loop.

    When I turn on my computer it tells me that I need to activate windows. I click on 'YES' it takes me to the activation page and says that Windows is already activated. All I can do is, click 'OK' and he takes me into a log on screen with my name on it and goes through the same process, as described at the beginning of this statement. I'm in a loop. The only way out is to wipe my hard drive and reload windows new who, within 30 days, it will do no doubt once again. How to do this?
    For 3 years I rebooted my computer. That's why I reloaded it in the first place. I sent this version of Windows XP by Microsoft and have recharged the system at least 4 times in the past 10 or 11 years.

    Ken

    Hello

    1. don't you make changes to the computer until the problem occurred?

    I suggest you to see link below and check if it helps.

    You are prompted to activate Windows XP or Windows Server 2003 every time that you start the computer:

    http://support.Microsoft.com/kb/312295

    Hope this information is useful.

  • Duplex printing on letterhead on the wrong Page and backwards!

    Hi all

    I googled this question and it seems that many have the same problem, but none of the solutions seem to work for me!

    I have a LaserJet P2055dn.  In 'tray 3', I have paper with a letterhead on one side.  It is in the status bar with letterhead down and towards the front edge of the printer, which works fine when I print a page.

    However... When I tried to print the pages back to back, it prints pages 1 to the last page, page 2 on the first page, and the two pages are in reverse!

    I realize I could exceed a flip manually the paper in the tray, but I'm evolving as to if I need to single page and pages back to back.

    I made sure the latest driver has been downloaded and installed, and I tried to change the following settings:

    Printing options > advanced > header Alternative Mode 'On '.

    Paper source: plain / header / pre-printed (have tried all)
    Print on both sides: Yes, Flip on

    Is there a way to change the settings so that I don't have to keep exchanging the paper around the status bar?

    See you soon

    Glenn

    With many printers. the 'face' paper must be loaded in the trays in a way for Simplex jobs, but in a different way to work two-sided .

    Some printers offer Alternative letterhead Mode (according to your comments, your printer seems to be one of them), in which case media that are declared with a Type of paper , letterhead can always be loaded in a sense (the necessary way for double-sided work).

    With the work front, the printer then automatically manage switching sides (probably by adding a blank page and print front and back of each front page).

  • Protection of the system. Responding file or directory is not a reparse point: (0 X 80071126) if please close the property page and try again.

    Three weeks ago, I got a problem of compatibility with nero premium 7 that I installed it, so I had to remove my laptop with great difficulty! I tried restoring the system by removing, and it failed. Whenever I open the system restore, I get a message... "There was an unexpected error in the property page. "The file or directory is not a reparse point: (0 X 80071126) if please close the property page and try again. For the protection of the system disks can not be re-analyzed for the same reason.
    What is the problem and how can I solve it? System repair not even managed to solve!

    Hello
     
    We will first check if the system restore services are set to automatic and started. To do this, follow these steps.
    1. Click Start, type services.msc and press to enter.
    2. from the list of services, double-click Windows backup and Volume shadow copy services.
    3. in the Properties window, select the automatic startup type and click Start.
    4. apply the changes.
    5. try to open the system restore and check the result.
     
    If the problem continues, check if the system of protection is disabled. To do this, follow these steps.
    1. Click Start, right-click computer and click Properties.
    2. click on Protection of the system under tasks.
    3. on the System Protection tab, be sure to place a check mark under all available disks to enable system restore or to market.
    4. apply the settings and check the result.
     
    For more information, see this link: http://windows.microsoft.com/en-us/windows-vista/System-Restore-frequently-asked-questions
     
    I hope this helps.

    Kind regards
    Syed
    Answers from Microsoft supports the engineer.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • R12.2.4 data lost after using the dialog Page and return to the calling page. (Help please!)

    Hi team,

    I'm new to OAF and works on a requirement to add some custom validation when the user clicks a button in a seeded standard page.

    The approach I took was to extend the seeded controller object managed this press event button and put my custom logic in the extended controller and substitute the standard controller through customization.

    The standard rate which was pressing the Complete button A Page, the user was taken to the next and epepinee page (Page B) some operations based on records that have been chosen Page A.

    Part of the custom validation requirement that was if some postings were not met, the user must be a pop-up asking if they really wanted to move forward and if they have selected Yes then continue with the seeded standard flow (transition to page B) and if they have NOT selected then just remain on the current page.

    I have used OADialogPage and to do this, in part, the question , I am running into is that when the user selects one or more records using a check box in a region of several record (table) and click the full page and if the validation fails then a modal page and the user made a selection i.e.either Yes or no modal page and when they return to the calling page (ex. Page A), all data (records) they chose previously is lost (the Page is refreshed). Based on what I see on this forum, I suspect it's because after having click Yes on the modal page and then return to the original page the processRequest fires again and the VO data is queried again and has all the parts on the page are lost. Since I am changing the flow in seedlings pages based on the intervention of the user I'm confused as to how this problem can be solved. that is, prevent the page refreshes or preserve the selections that were made before you navigate to modal page. Any help is really appreciated!

    My Code:

    ' Public Sub processFormRequest (OAPageContext oapagecontext, OAWebBean oawebbean)

    ...

    ...

    If (oapagecontext.getParameter ("completeOps")! = null) {}

    ...

    ...

    If (warnCount > 0) {}

    OAException message = new OAException ("not in order...", OAException.WARNING);

    oapagecontext.putDialogMessage (message);

    OAException message = new OAException ("XYZ Violated rule. Do you want to continue? ", OAException.WARNING);

    DialogPage OADialogPage = new OADialogPage (OAException.WARNING, message, null, "","");

    String Yes = oapagecontext.getMessage ("AK", "FWK_TBX_T_YES", null);

    String number = oapagecontext.getMessage ("AK", "FWK_TBX_T_NO", null);

    dialogPage.setOkButtonItemName ("ConYesButton");

    dialogPage.setNoButtonItemName ("ConNoButton");

    dialogPage.setOkButtonToPost (true);

    dialogPage.setNoButtonToPost (true);

    dialogPage.setPostToCallingPage (true);

    dialogPage.setOkButtonLabel (yes);

    dialogPage.setNoButtonLabel (no);

    oapagecontext.redirectToDialogPage (dialogPage);

    }

    If (oapagecontext.getParameter ("ConYesButton")! = null) {}

    Write Yes button Action code

    oapagecontext.putParameter ("completeOps", "Continue");

    }

    If (oapagecontext.getParameter ("ConNoButton")! = null) {}

    Write the code of the Action for the No button

    Dim errormsg = ' rule Violations have occurred. "

    throw new OAException (errormsg);

    }

    super.processFormRequest (oapagecontext, oawebbean);

    }

    I managed to work around this problem by adding a simple control in my controller processRequest method extended to avoid the call to super.processRequest incase lhen control returns to the page once the user has made a selection on the Page of the dialog box

    If ((oapagecontext. (GetParameter ("ConYesButton") == null) & (oapagecontext.getParameter ("ConNoButton") == null)) {}

    super.processRequest (oapagecontext, oawebbean);


    }


    Thank you!

Maybe you are looking for

  • Wireless on my laptop does not work

    The wireless on my laptop will not work. There are two other laptops in the House that work well and I already talked to my broadband provider who confirmed that the internet connection was working fine, but for some reason that my laptop can not fin

  • Problem of closing IdeaPad black 300

    I'm under W10 V1607 OS 14393.187 and I can't get off the computer correctly. I get the standard Windows message stop then the whites of the screen on. However if the keyboard is connected, the led remains power on and it is certainly still on. I chan

  • Pilot of the T61 wireless adapter

    My T61 adapater is the Intel Pro/Wireless 3945ABG. the driver is Version 11.1.1.11 [probably the same driver as the day I bought it]. I recently received a message from ThinkVantage saying that it could not connect to a wireless network and I might "

  • iTunes does not work for Vista

    I continue to try to sync my ipod and it says: "itunes has stopped working. a problem caused the blocking of the program works correctly. Windows will close the porgram and notify you if a solution is available. "I don't know what to do. I checked th

  • [CME 9.1] Phone IP 3905 fails to send DTMF tones to the external network.

    Hi all! We have three types of SIP phones in our CME 9.1: 3905, 6941 and 8941. All phones except 3905 send DTMF tones successfully through our operator. Here is "debug voice ccapi detail" what "206" (ip phone 3905) extension 93274343 external phone c