I Can Browse webpage by TWebView Component in Delphi. Can Fill Elements by javascript command.
Example:
WebView1.ExecuteScript( 'document.getElementsByName("name")[0].value = "' + Edit2.Text + '";');
How do I get Elements List or Tags List with their attributes (ex. Name, ID, ClassName, ref, ...).
I Googling and read all pages in web but can not found any help for Delphi.
Please Help me.
thanks.
Related
I have a jaspersoft report (line chart built in studio), and I want the data series in the chart to be hyperlinks that drilldown to open a dashboard.
Based on this wiki page I was able to create Reference hyperlinks so that clicking on any data series in the chart opens the correct dashboard. But I cannot get the Input Control parameters to pass correctly.
The URL when I load my dashboard directly from the repository (not by clicking hyperlinks in my line chart report) is
http://ddevrpt:8080/jasperserver-pro/dashboard/viewer.html#%2Fpublic%2FP2%2FMidcap%2FFinancial%2FDashboards%2FWell_Profile
The URL generated when i do not include input controls in my hyperlink reference expression is the same:
http://ddevrpt:8080/jasperserver-pro/dashboard/viewer.html#%2Fpublic%2FP2%2FMidcap%2FFinancial%2FDashboards%2FWell_Profile
JRXML:
<itemHyperlink hyperlinkType="Reference">
<hyperlinkReferenceExpression><![CDATA["./dashboard/viewer.html#%2Fpublic%2FP2%2FMidcap%2FFinancial%2FDashboards%2FWell_Profile"]]></hyperlinkReferenceExpression>
</itemHyperlink>
The URL generated when i do include Input Control parameter values is different, but still loads the dashboard empty (without passing the parameter values):
http://ddevrpt:8080/jasperserver-pro/dashboard/viewer.html?hidden_WellConcatenated_0=49005478.1:%20DILTS%2044-15%20TH&hidden_OccurrenceDate_1=2015-09-28%2000:00:00.0&hidden_OccurrenceDate_2=2015-10-05%2000:00:00.0#%2Fpublic%2FP2%2FMidcap%2FFinancial%2FDashboards%2FWell_Profile
JRXML:
<itemHyperlink hyperlinkType="Reference">
<hyperlinkReferenceExpression><![CDATA["./dashboard/viewer.html#%2Fpublic%2FP2%2FMidcap%2FFinancial%2FDashboards%2FWell_Profile"+"&hidden_WellConcatenated_0=" + $V{WellConcatenated_0} + "&hidden_OccurrenceDate_1=" + $P{RecordDate_0_1} + "&hidden_OccurrenceDate_2=" + $P{TimeStampMinusOneWeek}]]></hyperlinkReferenceExpression>
</itemHyperlink>
I know I am naming the input controls correctly because if i change my link type to report execution and link to a simple report using those input controls the proper report opens and the input control values are passed correctly.
I would also appreciate if anyone has other references they can point me to for drilling down TO a dashboard from a report.
I'm working with 6.3 and was able to resolve the issue with a small modification to the HyperlinkReferenceExpression syntax.
Specifically, I removed the "_hidden" before the input control resource IDs:
HyperlinkReferenceExpression:
original syntax:
"./dashboard/viewer.html#%2Fpublic%2FP2%2FMidcap%2FFinancial%2FDashboards%2FWell_Profile"
+"&hidden_WellConcatenated_0=" + $V{WellConcatenated_0}
+"&hidden_OccurrenceDate_1=" + $P{RecordDate_0_1}
+"&hidden_OccurrenceDate_2=" + $P{TimeStampMinusOneWeek}
modified syntax:
"./dashboard/viewer.html#%2Fpublic%2FP2%2FMidcap%2FFinancial%2FDashboards%2FWell_Profile"
+"&WellConcatenated_0=" + $V{WellConcatenated_0}
+"&OccurrenceDate_1=" +$P{RecordDate_0_1}
+"&OccurrenceDate_2=" + $P{TimeStampMinusOneWeek}
I'm assuming you're running 6.4.0. I'm not sure that approach is still valid.
You will likely need to register a custom hyperlink handler in your report in order to drill-down to a Dashboard. See here for more details: http://community.jaspersoft.com/wiki/how-use-custom-hyperlink-handler-dashboard-jasperreports-server
And here: http://www.helicaltech.com/use-custom-hyperlink-handler-with-a-dashboard-in-jasperreports-server/
Let me know if that works for you on 6.4.0!
My solution is a bad solution., but it worked for me.
In my Dataset - query I used the following:
Select p.printer_name, p.display_name, $P{start_date_1} as start_date_param, ....
Then, use the start_date_param as a field in the hyperlink.
I was reading the source code for tmplayer and MPUI, both media players that use MPlayer as a backend to play media files in Delphi and I noticed here as well as in other older codes that I tried to experiment with that I can't use
Form1.Rectangle1.Handle
or as it is in this example for tmp layer that is trying to pipe the video output at a TPanel
CmdLine := HomeDir + 'mplayer.exe -slave -identify'
+' -wid ' + IntToStr(Form1.Panel1.Handle) + ' -colorkey 0x101010'
+' -nokeepaspect -framedrop -autosync 100' + #32 + Media;
As you may see RAD studio xe6/7 complains that the element does not contain a parameter named Handle. Is this something that used to be valid in older versions but can't be used anymore, and if yes how can I accomplish the same task in a simple Firemonkey form.
EDIT
Ok, so now it is clear to me that the Handle parameter is only applicable for VCL Forms. Trying to rephrase my question,
How can I port that particular line of code (getting the handle of a component) in a Firemonkey form?
Panels and/or Rectangle in Firemonkey doesn't have Handle as member. FireMonkey Handle is member of Form component instead .
You can convert a FireMonkey handle to the platform specific handle with the function : WindowHandleToPlatform, but there is no way to get the handle of a control inside a Form .
Maybe you can replace the Rectangle with another inner form and get the handle of it. Take a look at the FMXEmbeddedForm .
i have this line of code in my mvc 4 pdfsharp project and i cant seem to figure out how to get the decsription field to display just the text when the pdf is generated. all my other lines display fine an they are all set up the same, it is just this one I cant figure out:
graphics.DrawString("" + report.Description, font, XBrushes.Black, new XRect(margin, page.Height - (lineHeight * 35), page.Width, page.Height), XStringFormats.TopCenter);
currentTop += lineHeight;
this is what the pdf displays from that line: Normal;font-weight: bold;font-size: 16px;color: #000000;">Incident API
this is what it should display: Incident API
does anyone know what I can add to this line of code to make it display properly. any advice or support would be greatly appeciated. if you need more info please ask. i have been stuck on this forever and cant seem to figure it out.
thank you so much
I was able to use a simple regex and just display plain text and no tags in the pdf report. Here is the code if anyone else has the same problem:
report.Description = Regex.Replace(report.Description, "<.*?>| ", string.Empty);
I need to set the language in a TWebBrowser component according to some properties of your program.
The problem is that i have to show, for example, dates according to the specific country dateformat. I already tried to find some hints in the docs, but without success.
So my question is:
Is there some possibility to set the language of a TWebBrowser like i can do in a normal instance of Internet Explorer?
We now solved it with a little workaround:
I pass an additional parameter with the URL, describing the language of the User. With this language we decide via Javascript which Formats to use.
Of course this is just a workaround and only possible if you can customize the website to call, but i haven't yet found another solution to manage this with Delphi.
I would be glad to read some other / better / simpler solutions.
Try this e.g. for de = German Language like:
header_string := 'Accept: text/html,application/xhtml+xml,'
+ 'application/xml;q=0.9,image/webp,*/*;q=0.8'
+ chr(13) + chr(10) // Linefeed
+ 'Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4'
+ chr(13) + chr(10); // Linefeed
WebBrowser1.Navigate(url,16,0,header_string);
I have read multiple posts on the issue, and none seem to come to a decent conclusion to my question. (Perhaps I'm trying to see if anything has popped up lately.)
I have a small charity app that handles pledges. In doing so, it needs to work with and print documents.
Thing is, if Word is open in the background, the app thread will hang and won't respond to the closure of Word, and I have to roll back manually and close word. Sure, that all works fine, but I simply cannot guarantee that the end user will close Word, even if I put the instruction in a user manual.
I'm not too fussed about speed, but I guess that if it can be enhanced, it would be a nice little bonus.
Have any libraries been released for Delphi that will allow me to open, edit, print, and save documents? If not, is there a way to use Word Automation in such a way that it will not conflict with another open handle of Word when opened?
If you use GetActiveOleObject, you will get the running instance of Word.
By using CreateOleObject, you will get a new instance and shouldn't be troubled by other running instances.
In case you use the TWordApplication, wrapper you can set ConnectKind to ckNewInstance to accomplish this. By default, TWordApplication will try to connect with a running instance.
If you want to open edit and print Word documents and you don't mind using RTF format for what you're doing, investigate TRichView.
It will generate rich documents that are in RTF format, which is one of the formats MS word supports. I don't think it directly reads .DOC files but you can convert .DOC and .DOCX into RTF, for most simple files, but certain advanced formatting features would be lost in the conversion.
It has the advantage of working without any need for even any copy of MS Word to be installed on the machine that is going to do the document processing. For production of receipts and other simple documents, this would be the most reliable technique; Don't use Word directly, at all.
procedure PrintViaWord (const filename: string);
const
wdUserTemplatesPath = 2;
var
wrdApp, wrdDoc, wrdSel: variant;
begin
wrdApp:= CreateOleObject ('Word.Application'); // create new instance
sleep (5000); // this fixes a bug in Word 2010 to do with opening templates
wrdDoc:= wrdApp.documents.add (
wrdApp.Options.DefaultFilePath[wdUserTemplatesPath] + '\mytemplate.dot');
wrdDoc.Select;
wrdSel:= wrdApp.selection;
wrdApp.Options.CheckSpellingAsYouType:= 0;
wrdSel.paragraphformat.alignment:= 1;
wrdSel.typetext ('This is a program demonstrating how to open Word in the background'
+ ' and add some text, print it, save it and exit Word');
wrdDoc.SaveAs (filename + '.doc');
wrdApp.ActivePrinter:= 'Konica Minolta 211';
wrdApp.PrintOut;
WrdDoc.SaveAs (filename + '.doc');
wrdApp.quit;
wrdSel:= unassigned;
wrdDoc:= unassigned;
wrdApp:= unassigned
end;