Ok, I have a html doc viewer component. If I do a “select all” and copy the window contents to a text document (i.e. to TextPad or WordPad), I get a plain text copy of what I see on the screen.
Is there a way to automate this? I tried the fpmi.print function, and I can create a pdf document, but that doesn’t help me because the resulting file has to be an editable text file. If I select the “generic/text only” driver and print to file, I just get an empty file. I assume there must be a way to print the clipboard contents or programatically select the contents, but I’m not getting it. Ideas?
I could do that, but there is an awful lot going on behind the scenes with adding hyperlinks, highlighting, and hrefs on the fly. For instance, there are a lot of mathematical symbols, and as I create the html version, I have to make hex equivilents of things like ‘<’ and ‘>’’ so the html comes out right. I guess I coould build two files at once, but man, it was hard enough the first time. I guess you’d have to see it.
I don’t know much about what is actually happening during a “select all”, so I just thought the doc component contents must be easily accessible somehow. If is isn’t, no big deal. I’ll see how much work it is to rip through my html doc and convert it to text. Maybe it’s easier than I thought.
That is just so cool. I even added it to my quasi-tree control in the other thread, and can also now print html list output. I can’t say here exactly what I’m doing with this, but I just got done showing it to someone and it’s a real head-turner.
Ok, to take this one step further, I now have to write to the clipboard. Looking at the Java API, I have to use java.awt.datatransfer.Clipboard, but need an instance to pass in as the third argument. getDefaultToolkit() is used to satisfy this in the getSystemClipboard code, but I don’t know what to use with setContent. Here’s what I have so far:
Faults = 'This is a fault'
from java.awt import Toolkit
from java.awt.datatransfer import DataFlavor
from java.awt.datatransfer import Clipboard
clipboard=Toolkit.getDefaultToolkit().getSystemClipboard()
Clipboard.setContents(Faults,clipboard)
This is to replace a VB program that passes fault data to another program via the clipboard (hey, I didn’t design it). My fpmi project already had the fault data, so it really made sense to replace the VB app and get rid of the second Kepware instance.
Yep, but it’s also nice to prove that I can replace any legacy stuff out there with minimal effort and without telling the customer “Sorry, but I can’t interface to that thing”.
Having access to the java libraries really opens up possibilities. I just have to get better at it.