I'm trying to make PDF forms (aka AcroForms) editable in Java.
So far i got the GUI editing and printing working using Bruno Lowagie's iText and Sun's pdf-renderer.
But now i'm close to scrapping it all, because after switching from try & error to reading the PDF specification, i realized that it's all worthless unless i can make the multitude of possible JavaScript actions work as well. I don't think iText can do that.
So in short: are there any Java libraries that do proper form handling including actions?
Or maybe even a Java GUI component to edit form data?
Does Suns PDFRenderer support Javascript? ARAIK, only JPedal and BigFaceless offer Javascript support.
You might take a look at Mozilla Rhino: http://www.mozilla.org/rhino/
I haven't used it, but it looks promising, if you already have the GUI in Java.
Related
Recently I am working on commercial project which requires to generate a PDF based on some dynamic HTML content, now I have implemented that with a java library called WKHTMLTOPDF (http://wkhtmltopdf.org/).
This library is a command line tool which user browser webkit as rendering engine, since I am new to java development, I am not sure whether there is any security or performance issue when using this library.
If this is not a good solution, is javascript plugin an alternative?
Sorry for my english!:)
I've worked on the same sort of thing recently. I used iText and found it immensely useful. I haven't used WKHTMLTOPDF but I'm answering since you seem to explore more on other options which could be better, safer. iText has been here for a long while now, and it's pretty simple to use.
Follow these links for more info on iText,
How to convert HTML to PDF using iText
And,
Converting HTML files to PDF
A small/sleek tutorial http://hmkcode.com/itext-html-to-pdf-using-java/
If you are concerned about any sort of licensing issues follow,
Is iText 5.4.2 open source?
I found iText quite handy and is supported by a most of the browsers too. (Chrome, IE, Firefox, I haven't tested on res of them) Hope this helps.
I would suggest you to use PD4ML library available purely in JAVA .It is easy to use and generates PDF from HTML (dom) quickly.
http://www.pd4ml.com/
I want to write a text editor in JavaFX which acts similar to Eclipse/Netbeans IDE to highlight the Java code.
Can anyone suggest as to how it can be achieved or anyone has done this previously.
Thanks.
There's no pure JavaFX libraries for the code highlighting / editing as far as I know, so if you want to implement it in JavaFX you're going to be translating from a similar Swing (or other) project, or you're on your own.
However, you can use such a Javascript library and wrap it in a WebView if you want to achieve this - Jewelsea (who often swings by here) has done just this and explained it rather nicely here.
RichTextFX let's you specify style classes for ranges of text. Take a look at the Java keywords demo and its source code.
For any current searchers with this question, MonacoFX is a very nice, convenient, and EASY to use library that offers feature-rich code editing with at least 50 or 75 languages that it can properly syntax highlight, code fold, and all that good stuff. It is the same code editor that is used in the open-source version of Visual Studio. When I built my app and integrated MonacoFX, it was literally the most effortless portion of my project.
You can use eclipse text framework as posted
They also have a javafx code editor component called compensator
you can use intellij's swing code editor, with javafx swing interoperability
the component is com.intellij.openapi.editor.impl.EditorComponentImpl
you can check details running with intellij integrated ui inspector
I'm new to Java and Java Swing, and I'm creating an application that requires the presentation of web pages. I program for iOS a lot, and the simple solution here would be to load the page in a UIWebView. Is there an easy component for Java Swing? Or, is there an easy way to create something of the sort either in or outside of Swing?
I'm basically looking for something where you put in a URL, and a page loads in the application that looks like a normal page in a web browser.
If your Java program is a desktop application, the browse() method of java.awt.Desktop accepts a URI that may be obtained form a URL. The feature was added in Java SE 6. It's not embedded, but the user's chosen browser may be more appealing.
Addendum: See also How to open a URL in the default browser.
There's no single useful solution. There is the JEditorPane class, but it supports only HTML 4 and my experience with it is awful. For example, HTML comments showed up as plain-text.
If, however, you broaden the search to something outside Swing, there are plenty components that will do the job well. See this related question for a detailed discussion of these.
My task is to create a simple web browser in Java.
So far it can only read HTML pages.
I'm using standard JEditorPane component to display webpages.
Now I was wondering is there any way you could explain me how can I manage to display at least some simple pages that contain CSS/Javascript.
If you could point me to some useful links or appropriate examples I would be very happy.
Well, my advice would be to look at open source rendering engines such as Gecko - https://developer.mozilla.org/en/Gecko_FAQ
You can embed Gecko with Java using the JREX library - http://jrex.mozdev.org/
Starting from scratch with a problem like this is a very big task, and as your username is AmateurProgrammer, I wouldn't recommend it.
There alrady is some prior art for the Java browser segment.
concerning javascript, you will have to use a javascript interpreter in Java. A renowned one is Rhino (by Mozilla). Its integration may reveals to be an interesting challenge.
concerning CSS, it seems the question has already been asked ...
I am interested to create a drag-and-drop layout designer using only JavaScript, HTML and CSS. The designer will allow the user to drag the page elements from one place to another (something like Blogger's layout designer) to create a site layout. But I don't want to hand code everything in JavaScript, I would prefer to write my application in .NET (preferably) or Java and rely on a compiler to compile it to JavaScript and HTML.
What are the .NET or Java to JavaScript compilers that you have used and can recommend? For Java to JavaScript I know GWT is available. What about .NET to JavaScript? Microsoft did come out with Volta, but the project seems to be no longer available.
Look no further, you already mentioned GWT pick that!
It has a very good API and many good applications have use them.
Even JavaScript frameworks like http://extjs.com/ have GWT support.
I use it for an small JavaScript calendar recently.
To be honest, I don't really like JavaScript that much. Most of the times the errors are hard to track (specially for a non JavaScript guy as me) and the workarounds included some plug-ins for the explorer just to get exactly what a compiler should do. Catch silly error early.
In the other hand I'm very familiar with the Java Programming language, and many of the libraries (if not the most important) such as java.lang and java.util have been ported to GWT.
Plus, the guy who wrote relevant parts of java.util is the same behind GWT (google Joshua Bloch.)
Check out Nikhil Khotari's Script# project. It allows you to write C# code and compiles it to JavaScript.
Script# has already been mentioned. It hasn't been updated since August 2008.
Milescript is another, but also has seen very little for 6 months.
Extsharp for the Ext library. Adds Ext support for Script#
Javascript compiler to Java (going the wrong way for you)
Java to script Eclipse plugin
My issues with Script# (a known issue) is it doesn't support jQuery yet. However it comes with a very lightweight library to tie in with the .NET framework, in Nikhil's sscorlib.js file and ssfx.core.js files. And also has support for lots of other Javascript APIs (mostly Microsoft, seeing as he is in the ASP.NET team).
I'd love to see a Script# extension for jQuery (I'm thinking about writing it if it's easy enough). As it stands, most don't provide full compilation yet but they're certainly getting there.
Update: I wrote a small extension to enable JQuery support Script# a few months ago. The project can be found here.
I'm going to second the use of GWT. I've used it for several projects and, when used in combination with a modern editor like Eclipse or IDEA, it really makes the mess manageable.
It's important to note that not only does it allow you to write in Java and have that transformed into optimized and obfuscated Javascript it also comes with a substantial subset of the core Java API. In addition to this they provide lots of additional classes for doing things like parsing and working with JSON and XML and communicating with a server via asynchronous HTTP. You can check out the docs to get an idea of what else they offer.
Another feature that might be of special interest to you for implementing drag and drop functionality is it's integration with javascript libraries like Ext and scriptaculous. Either through pre-built interfaces or via JSNI
Also for Java there is J2S.
Java2Script (J2S) Pacemaker provides
an Eclipse Java to JavaScript compiler
plugin and an implementation of
JavaScript version of Eclipse Standard
Widget Toolkit (SWT) with other common
utilities, such as java.lang.* and
java.util.*. You can convert your
SWT-base Rich Client Platform (RCP)
into Rich Internet Application (RIA)
by Java2Script Pacemaker.
This means that if you use the SWT IDE (drag and drop) you can then convert the generated code to JS + HTML.
I wouldn't hand write any Javascript for UI. This can lead to maintenance disaster. jQuery is what I am using but I still wouldn't use it to write full UI Javascript code. ExtJS is also another good option if you plan to write in Javascript. In general what I am saying here is that it's so much easier to main in Java/C# than Javascript. Check out cappuccino framework and Atlas. Never used GWT. Script# is similar to GWT but for ASP.NET framework. Also depends on the requirement, if your site is public facing then RIA isn't a good option. It's all about which extreme end you pursuit (hand written and web standard, or RAD or libraries like jQuery/ExtJS as the middle option).
Check out Axial, a .NET to JavaScript converter that works well in ASP.NET. It supports WebForms, jQuery and canvas. It's not very mature, but it's worth a look.
http://jsc.sourceforge.net/ is a C# to JavaScript, Java, Flash and PHP compiler.
JscriptSuite offers another free .NET to Javascript compiler. There is a big difference to Saltarelle (jsc, SharpKit# etc.). Developer write down and debug only C# code (or any other .NET langauge), like in GWT. Javascript will be generated für deployment only.