Gtkwebkit, save html to pdf - gtk

Last days I search for best and shortest way to convert html files to pdf. Since I create my html files with C program and see them through gtkwebkit which uses cairo it should be some efficient and direct way to convert content of showed page to html with C (I think).
But can't find any example or direction to go on the net.
Until now, among different virtual printers, I find only commandline tools which are maded in perl or which depends on qt what is not wanted.
Please for any suggestion, example or advice to get this functionality from gtkwebkit and if not, maybe something with some tiny C library.

As far as I can tell from reading the documentation (haven't tried it out myself):
Get the main frame with webkit_web_view_get_main_frame().
Create a GtkPrintOperation with gtk_print_operation_new().
Set the export-file property on your print operation to be the name of the PDF you want to export to.
Print the frame with webkit_web_frame_print_full(). Make sure to pass GTK_PRINT_OPERATION_ACTION_EXPORT as the 'action' parameter.

I once wrote some code, to accomplish that without opening a window. But then I ran into a problem with using that code from multiple threads (in a webserver e.g.). I made some research and I figured out that gtk itself is single threaded. So I made my code thread safe, by queuing the print operations to the main thread. Anyway, if it helps, check it out... https://github.com/gnudles/wkgtkprinter

Related

Modern core method of uploading file in Perl

I'm looking to write a script that lets a user upload an image from a webpage, for later use on that website. As per usual, all I can find is examples involving CGI.pm. Are there any core modules that I can use as a replacement?
The Perl core distribution contains no modules for writing web applications. I think you probably want something based on Plack::Request and Plack::Request::Upload (for example Dancer2::Core::Request::Upload).
The solution I ended up going with may not be the best, but it's functioning, and simple.
Using cgi-lib.pl I can simply use
open(VAR, ">output/file.png");
binmode VAR;
print VAR $in{input};
close(VAR);
and it gets the job done.
If there are any notable problems with this, please let me know.

Is it possible to send HTTP GET Requests from a Simulink Block?

basically the title says it all. I'm working on a model that needs (there is no way around it) to load data from a website, parse it and pass it onto another block. I thought I could use an S-Function written in C++, which didn't properly work, then I tried to use webread()
which also didn't work in Simulink because I can't use extrinsic functions on the device this will run on.
I thought I could work around it by downloading the file externally and then reading it through fscanfbut it turned out that Matlab CODER doesn't support that as well.
After putting 2 1/2 days into this now, I'm asking myself whether it is even possible to do something like an HTTP Request through a Simulink block. That's why I went here to ask that question. Thanks for every answer!
I figured out a way to do it with a C++ S-Function by now.
I also created a GitHub Repo for it. If you're stuck with the same problem as I was, try to take a look at this. I'm pretty sure it will help you.

How to debug with createJS's objects

I am using createJS for a game, but when I debug the code with console, I got all objects displayed as an a. Then I have no idea what the object really is.
What does the a here mean? And what's the best way to debug these code?
This is due to the minified source. Instead, use the combined source. You can get a combined version of each library in GitHub, which is one file containing all the classes, but just appended, instead of minified.
If you are using the full combined suite on the CDN, then you can change the path to .combined instead of .min: https://code.createjs.com/createjs-2014.12.12.combined.js
Cheers.

Flash XFL to iOS/XCODE/Interfacebuilder

I am thinking of starting an ambitious project of writing some type of converter to convert the new Flash CS5 XFL format to some type of iOS readable format for building pages. A lot of what I do convert old Flash course over to native applications. They are usually very simple with some basic animations. Some are more complicated than others, obviously.
1) I recently found the XFL format and was wondering if anyone was doing this type of conversion?
2) Has adobe published this file specs yet? I haven't been able to find them, yet.
3) Is this even possible? Has anyone tried and been unsuccessful or would like to work together on this?
I thought of this and wonder if it is a good idea that we insert the code directly in the flash file. That means the tool is written in ActionScript, for example a utility class called SceneExporter. When you want to export a MovieClip, extends it with SceneExporter and when the Flash file runs, it exports the content of that MovieClip to a objective C code text file. Not professional way, but it should work since we have access to all child elements of that MovieClip.

how can I improve iPhone UI Automation?

I was googling a lot in order to find a solution for my problems with UI Automation. I found a post that nice summarizes the issues:
There's no way to run tests from the command line.(...)
There's no way to set up or reset state. (...)
Part of the previous problem is that UI Automation has no concept of discrete tests. (...)
There's no way to programmatically retrieve the results of the test run. (...)
source: https://content.pivotal.io/blog/iphone-ui-automation-tests-a-decent-start
Problem no. 3 can be solved with jasmine (https://github.com/pivotal/jasmine-iphone)
How about other problems? Have there been any improvements introduced since that post (July 20, 2010)?
And one more problem: is it true that the only existing method for selecting a particular UI element is adding an accessibility label in the application source code?
While UI Automation has improved since that post was made, the improvements that I've seen have all been related to reliability rather than new functionality.
He brings up good points about some of the issues with using UI Automation for more serious testing. If you read the comments later on, there's a significant amount of discussion about ways to address these issues.
The topic of running tests from the command line is discussed in this question, where a potential solution is hinted at in the Apple Developer Forums. I've not tried this myself.
You can export the results of a test after it is run, which you could parse offline.
Finally, in regards to your last question, you can address UI elements without assigning them an accessibility label. Many common UIKit controls are accessible by default, so you can already target them by name. Otherwise, you can pick out views from their location in the display hierarchy, like in the following example:
var tableView = mainWindow.tableViews()[0];
As always, if there's something missing from the UI Automation tool that is important to you, file an enhancement request so that it might find its way into the next version of the SDK.
Have you tried IMAT? https://code.intuit.com/sf/sfmain/do/viewProject/projects.ginsu . It uses the native javascript sdk that Apple provides and can be triggered via command line or Instruments.
In response to each of your questions:
There's no way to run tests from the command line.(...)
Apple now provides this. With IMAT, you can kick off tests via command line or via Instruments. Before Apple provided the command line interface, we were using AppleScript to bring up Instruments and then kick off the tests - nasty.
There's no way to set up or reset state. (...)
Check out this state diagram: https://code.intuit.com/sf/wiki/do/viewPage/projects.ginsu/wiki/RecoveringFromTestFailures
Part of the previous problem is that UI Automation has no concept of discrete tests. (...)
Agreed. Both IMAT and tuneup.js (https://github.com/alexvollmer/tuneup_js#readme) allow for this.
There's no way to programmatically retrieve the results of the test run. (...)
Reading the trailing plist file is not trivial. IMAT provides a jUnit like report after a test run by reading the plist file and this is picked up by my CI Tool (Teamcity, Jenkins, CruiseControl)
Check out http://lemonjar.com/blog/?p=69
It talks about how to run UIA from the command line
Try to check the element hierarchy, the table can be placed over a UIScrollView.
var tableV = mainWindowTarget.scrollViews()[0].tableViews()[0].scrollToElementWithName("Name of element inside the cell");
the above script will work even the element is in 12th cell(but the name should be exactly the same as mentioned inside the cell)