itext JavaScript version - itext

first time here posting, though I have benefited many times from other postings on stackoverflow. I am the principal developer of Jmol, which I have recently ported to JavaScript/HTML5. The Jmol applet interfaces with another applet, JSpecView, which in its current form as a Java applet utilizes a slimmed down version of itext.1.4.5.jar to create PDF files of spectra.
I am interested in converting iTtext Java code to JavaScript so that a JavaScript version of the JSpecView applet can create PDF files directly.
Q: Has this already been accomplished?
Q: JSpecView is an Open-Source project licensed under LGPL. All our source code is available. Is this a problem?
Bob Hanson
Principal Developer, Jmol/JSmol

A: I don't think such a port has been done before. But why would you not use an existing JavaScript pdf library? Or what is wrong with doing the PDF generation on the server side? Why would you do more work than is necessary? I've done a quick google on JS PDF libraries and found:
http://jspdf.com/
https://github.com/mozilla/pdf.js
And the following stackoverflow question:
Generating PDF files with Javascript
A: I think it shouldn't be a problem porting it to JavaScript as you'd be porting to the same license (of course, if you're using a version of iText before the license switch to AGPL), but IANAL.

Related

is there a way to convert a scratch 3.0 file into a .swf file?

I tried scratch 2.0 but I use Sinhala language because l am Sri Lankan. So I can't use Sinhala in scratch 2.0 So I can't convert using scratch 2.0
Is there any other way we can convert an Sb3 file to a Swf file?
I hope I understood correctly. You want to convert a Scratch project to SWF. Scratch 2.0 is not an option due to lack of language support; you feel obliged to create the project in Scratch 3.0.
I guess it should be possible to convert SB3 to SWF in two steps: first convert SB3 to SB2, then convert SB2 to SWF.
This wiki article explains both steps:
https://en.scratch-wiki.info/wiki/Porting_Scratch_Projects
SB3 to SB2
Scratch user -Rex- made a .sb3 to .sb2 converter here.
Run sb3tosb2.py (requires Python) to run the converter.
After the .sb2 is saved, the guides below can be followed (.mp3 files will not be converted to .wav to be used in the .sb2).
Note: it wasn't clear to me what 'guides' the last sentence refers to.
SB2 to SWF
You can download an SB2 to SWF converter or use an online converter at this site.
Note: the link above now redirects to: https://asentientbot.github.io/converter/
I've been struggling with this as well but only because when I go to the converter on asentienbot.github.io it tells me this "Quite a few years ago, I wrote a tool to port Scratch projects to SWF files and standalone applications. It is now obsolete and unsupported." And doesn't let me press any buttons just tells me I can download the source code. Does this happen to you?
As #Ruud Helderman said, you can convert SB3 to SB2 using this converter made by -Rex-.
For the SB2 to SWF part, you can use the Wayback Machine to access older versions of the website.
Here, I linked the latest available version of the page.
EDIT: You have to download the converter since the online version redirects you to: https://asentientbot.github.io/converter/

iText digital signature using javax.smartcardio

I'm trying to sign a pdf with belgian eId smart Card. I've installed Eclipse, downloaded Java SDK 1.6, added the itext 5.4.5 jars smardcardsign-1.0 jars as external jars to the building path.
I want to test example "4.6 signing a string for authentication" from Bruno's whitepaper "Digital Signature for PDF documents".
I copied C4_05_SignWithBEID.java file from itext download site.
I've got an error "AUTHN_CERT_FILE_ID can not be resolved or is not a field"
for line X509Certificate cert = card.readCertificate(BeIDCertificates.AUTHN_CERT_FILE_ID);
When I check the properties for class BeIdCertificates the "AUTHN_CERT_FILE_ID" is not available.
Has someone a complete source for the example 4.8 signing a document using the EidSignature class ?
Please don't copy/paste from examples I have written without reading the accompanying book, in this case the free eBook "Digital Signatures for PDF documents".
The example you mention is taken from section 4.2.2 from that book, entitled "Extracting data from the Belgian eID using smartcardsign."
Allow me to quote myself (page 105):
We can use the javax.smartcardio API to access any smart card, but
unfortunately it's usually not that simple. Every card has its own
file structure, its own applications, its own data definitions, and so
on. Apart from the ISO/IEC specification, you'll always need the
specifications of the card you want to use. I've written a small
library that wraps the generic Java API classes in objects such as
CardReaders, SmartCard and SmartCardWithKey. I wrote a special
class for the Belgian eID, named BeIDCard. You can find this library
on SourceForge. It’s meant as a light-weight library that
supports only the basic functionality.
You can find the link to that library in the footnotes: http://sourceforge.net/projects/smartcardsign/
The class BeIDCertificates is part of this library, and it has a constant named AUTHN_CERT_FILE_ID.

Deploy GWT Application as Single JavaScript File

The compiled JavaScript output of a GWT application is divided into various files, for instance
*.cache.html
*.gwt.rpc
hosted.html
*.nocache.js
...
I know this is done with the purpose of minimizing the size of the JavaScript, which has to be downloaded by users. For instance so that a Firefox user does not have to load the JavaScript specifically compiled for IE6.
However, especially for small GWT applications it might often be faster to download a single file of say 500kb rather than make two sequential requests first for the 5kb *.nocache.js script and then for the rest of the app (cache.html files, etc.).
This leads me to the question: Is there any framework or procedure to bundle the output of the GWT compiler into a single JavaScript file?
First, you can merge all permutations in a single file by using so-called "soft permutations".
Then, you can inline your *.nocache.js into the HTML host page (e.g. using a JSP's #include directive) to cut one additional request (you might have to add a <meta name=gwt:property content='baseUrl=myapp'> where myapp is the subfolder where the .nocache. files are located).
AFAIK that's what Google are doing for their GWT apps.
Alternatively, you can run the permutation selection on the server-side if you can totally replace the selection script (*.nocache.js) with server-side content negotiation (based on User-Agent and Accept-Language request headers for instance) that can directly generates a <script> tag for the appropriate *.cache.js file (provided you use the xsiframe linker).
AFAIK, Google use all these techniques for their GWT apps (such as Google Groups). For a small app, though, I'm not sure it's worth the effort…
Also, the last two techniques work best when your HTML host page is already dynamic and therefore already non-cacheable; otherwise you're mostly moving the problem, not solving it.
I wonder whether the sso linker can be used when you collapse all properties and soft-permutations down to a single hard permutation.
Yes, but it's maybe not something you want. See this answer: https://stackoverflow.com/a/4453716/66416 to this stackoverflow question: Merge GWT generated files.
I found another way to accomplish this: Writing a custom Linker for GWT. Two examples for linkers which compile into a single JavaScript file are:
GwtNodeLinker.java from Gwt Node project
ServerSingleScriptLinker.java from Env.js project

how can previous versions of office files be accessed using open xml sdk 2.0

I suppose office files(prior MS office 2007) cannot be accessed using open xml sdk2.0 or if they cannot be programmatically accessed using the open xml format.
so is there any way to work or these older version files or can i view the xml content of these files.
or is it that open xml sdk isnt designed for that purpose
See the answer to a similar question I asked when I just started learning this SDK.
No but the open source project POI provides an API to most of the old formats. Warning POI is a bit (not a lot) buggy, does not fully implement the specs, and support is catch as catch can (ie it's open source).
You can use Office File converters to convert to open xml formats and start processing it.
See here:
http://technet.microsoft.com/en-us/library/cc179019(v=office.14).aspx
I'm using this for my application. This works for me.
Hope this helps.

GWT Toolkit: preprocessing files on client side

If there's a way for the client side GWT code to pre-process a file on the client computer?
For example, to calculate a checksum of it before submitting the file to the server.
No it is not possible. The manipulation of the file is done by the browser, not the HTML code.
Think about it, GWT is 100% javascript. And javascript has no access whatsoever of the file in your computer. That would be an pretty big security risk! GWT "wraps" the file input box so it can be displayed inside the GWT panel. But once you press the "upload" button, the upload is done by the browser.
You could do file manipulation with another technology however. Java applets for example. But that is outside of GWT area...
Using GWT, there is no way to read files on the client side yet. However, in HTML5, you can read files without uploading to a server using the "File API".
Links are provided below.
File API tutorial on html5rocks.com
Example of how to use File API in GWT via JSNI
I'm pretty sure that because GWT code compiles to pure JavaScript, there isn't a way without requiring some third-party browser plugin.
Do you mean from an <input type="file"...> file upload field in a form?
The short answer is no-- file uploads are handled by the browser, and are sent directly to the server (as an ENCODING_MULTIPART POST). And security restrictions on JavaScript mean there's no way to workaround that restriction.