I'm trying to write an application for the game Path of Exile, that lists the items in my stash on trading websites automatically.
For this I have to retrieve the items in my stash from their website. For some reason the ".getText()" functions is behaving very weird on the website. I really can't see any mistakes I did with the x-path Expressions.
Example:
Here you can see a snippet from the HTML file I am working on
screenshot of browser debugg tool
In the screenshot you can see that the x-Path I am using is selecting a element with a text element, however when I iterate over the elements and get the text with the getText() function, it returns a empty String... I really have no clue what I am doing wrong, is it the website, that is denying me to access the field?
In case it helps I add here a screenshot of the source code for outputting the text fields
printing the text of the elements(SourceCode)
5 empty Strings as output
On your place I would try to get value instead of text.
try to replace
e.getText()
with
e.getAttribute("value")
or you can also try to play with .getCssValue()
I'm trying to localize a Swing application with Hebrew punctuation
But Shva (U+05B0) is displayed wrong, should be displayed as:
System.out.println("\u05D9\u05B0\u05E6\u05B4\u05D9\u05D0\u05B8\u05D4");
Will print correctly the first letter with Shva punctuation:
יְצִיאָה
But when added to Swing application using messages.properties file
It display \u05B0 same as \u05B4 (HIRIQ)
יִצִיאָה
I tried other Unicode option but it didn't work, does anyone have a reason or is there a known limitation ?
It shows the as main menu option it looks OK, as a sub menu (can't enlarger component) it look wrong
I am writing lots of whitespaces as you can see the code below.
out.println("new Array('1453 12999 ALPER KOPUZ')");
unfortunately when code compiles and run the code in the screen I am able to see it as
"1453 1299 ALPER KOPUZ".
It means it auto removes whitespaces and put only one whitespace after one word.It works fine at older versions of Internet Explorer but it does show line such like "1453 1299 ALPER KOPUZ" at Internet explorer which I need to fix and our application runs on this server.
I tried css "white-space: pre;" but it is still same.
This problem makes me crazy and ate my 3 hours. I would be glad if you have any idea to fix it.
Cheers
Alper Kopuz
I guess using out.println you are writing the text as HTML on your page as response.
You need to have the text pre formatted once you print it as HTML. Try to put your text in pre tag as shown below.
out.println("<pre>new Array('1453 12999 ALPER KOPUZ')</pre>");
Let me know if this is what you were looking for.
I am developing a small application with SWT Browser widget. I am highlighting a search text word with
<a id="xyz" href=''><mark>test</mark></a>
in a HTML document. and replace all the search words in HTML Text in this way so we get all the search words highlighted.
htmltext.replaceAll("(?i)"+Pattern.quote(searchword), "\\<a id='xyz' href=''> <mark>$0\\</mark></a>
I want to implement functionality that if I click on next button, next highlighted word should get focus and if I click on previous button previous highlighted text should get focus. how can I accomplish Next and Previous Hit using Javascript in Eclipse RCP application.
This is best solved by combining JavaScript with Java code. It depends what kind of HTML content are you going to handle, if it's stateful (e.g. cannot reload), dynamic with lot of JS code, or plain static. In most cases, the best solution would involve most of logic to be written in JS and just minimal code in Java to bind JS actions to SWT GUI.
There's several things you need to implement:
keyword searching
toggling highlighting
toggling highlight from one word to another
1. Search: you realise that you won't be able to search for words that span through many HTML elements, like W<span>o</span>rd? If that's ok then you can just search and replace from Java as you do now. I'd go for individually tagging each word match with id: <span id="match1"> and remembering how many matches in total were found.
You could likely do such search on JS side as well by adding a function that iterates through DOM and searches for specific text and wraps it with another DOM object.
2. Toggling highlighting: It's best done in JavaScript. Append to your HTML a JS code fragment that toggles DOM element style. Something like:
`
function highlight(id) {
document.getElementById(id).className = 'highlighted'
}
You'll be able to call this JS from SWT by invoking swtBrowser.execute("highlight('match1')")
Further you should implement function that takes off highlighting.
3. Toggling highlighting between elements:
This can be done both on Java side and on JS side. I would probably go with JS and add two more functions: highlightNext() and highlightPrev() that would just call highlight() function with proper ids.
Then in Java you could make SWT buttons that call JS functions through SWTBrowser.execute().
In my application I have to fill a predefined PDF form with data from DB. We are using Java and Pdfbox. The filling itself is not a problem.
The problem is that in resulting PDF-file all texts in the form are invisible (or hidden, also grey rectangles) unless field clicked.
How can I solve this problem?
I had the same problem when I tried to programmatically fill PDF forms using pdfbox. I add this answer to a rather old question as all the other answers manipulate the original PDF, which is not always an option.
The problem with invisible form fields just appeared in Acrobat PDF, other PDF renderers showed it fine. If using pdfbox 1.8.x you have to set Need Appearances as explained here:
PDAcroForm form = docCatalog.getAcroForm();
form.getDictionary().setItem(COSName.getPDFName("NeedAppearances"), COSBoolean.TRUE);
If using pdfbox 2 this is simplified to:
PDAcroForm form = docCatalog.getAcroForm();
form.setNeedAppearances(true);
I read this on a forum and worked for me:
Using Adobe Acrobat Pro, I exported the form using "Export Data" to a XML and then imported it back from XML-file with "Import Data". Those commands are under Forms/Manage Forms Data
This is the link to the post: http://forums.adobe.com/thread/637421
I had this exact problem with a form I was filling with PDFBox in Java.
I fixed it by opening the original (blank) PDF form in Acrobat Pro and changing some options for each of the problem text fields. The options might vary for you, but here's what worked for me:
In the Acrobat Pro menu bar go to Forms > Add or edit fields.
Right click the text field in Acrobat Pro and select properties, then:
In the 'Options' tab:
Untick all options except 'scroll long text'
Add a few space characters in to the Default Value box
In the 'Appearance' tab:
Set the font size to 'auto'
Click 'close form editing' and save the file.
I just ran across this and tried a combination of things before one very simple thing worked. I have Adobe Acrobat 9.0 and I couldn't find some of the options written here.
What I ended up doing was a two-pronged process: I went to Forms > Manage Form Data > Export Data; I then saved that file on my desktop. Next, I went back to Forms > Manage Form Data but instead selected Import Data, and selected that file I'd just saved. Bingo! Everything filled in properly.
I don't quite know how you can stop it happening in the future but a resolution to getting the file working, similar to g-eorge is to open it in adobe acrobat pro, in tools on the right hand menu select "Interactive objects" and choose select object.
When you highlight the first field you want to fix, you should then be able to control-a to select all interactive objects. Once all are selected, right click on one field and select properties.
In the "general" tab the bottom option should have "common properties" which has the option "form field" change this to hidden and then back to visible. This will then restore all visibility to the form.
This has worked for me on all the rare instances when I receive this, and hasn't failed me once. Hope it does the same for you,
BoB
in the appearance tab of each erroneously hidden object you will see the "fill color" set to none. set it to none again (just click on it) and save the PDF and these fields will show up normally. I can't believe adobe has let this error persist for so long. It happens constantly when viewing/saving with multiple pdf readers.
Nothing I tried here worked - except to change software.
I was using PDFElement 6 Pro (trial) and couldn't make it work. Tried all sorts of things with PDFBox plus all suggestions above.
Ended up trying https://www.pdfescape.com/ and it all worked just fine.
In my case I solved it by changing the font to Arial (or one of the standard in windows set), in the 'Appearance' tab, in properties.
Before, it was set Helvetica which was not embedded in the file and that I think generated the problem.