Archive for the 'Java' Category

How to run iText on Google App Engine

Important update:

The last version itext-gae hosts at GitHub now, with many changes,

  • update to iText 4.2.0
  • fixs many bugs
  • supports Graphics2D now

Have applied Google App Engine (aka GAE) for a long time, recently I thought maybe I can build some PDF manipulation services on GAE, and I am familiar with iText, so I decide to try iText on GAE.

after some search, I got the following solution,

iText has dependencies on certain Java classes (java.awt.Color, java.nio.MappedByteBuffer etc.) which are ** not ** allowed by the Google
App Engine runtime .
Google App Engine throws an exception e.g “java.lang.NoClassDefFoundError: java.nio.MappedByteBuffer is a restricted class. Please see the Google App
Engine developer’s guide for more details.” is thrown for the unsupported class(es).
- Would it be possible to remove the dependency by iText on these Java classes, so as to enable the library to work within Google AppEngine?
See attached (very rough) Subversion patch file, for how I quickly removed some of the dependencies, so as to get iText to process a PDF form within
Google App Engine.

You can download the patch here,iText patch for GoogleAppEngine support.

And if you are very lazy, you can try directly download the modified version iText-2.1.7 (both jar and source)from here,

notice, iText-2.1.7-gae.jar forgot cmap_info.txt and glyphlist.txt, so if you directly use iText-2.1.7-gae.jar, you need add cmap_info.txt and glyphlist.txt to it first.

I have write two little demos and deployed them on my GAE home page, feel free to have a look here,
http://rubypdf.appspot.com

reference,
http://code.google.com/appengine/docs/java/jrewhitelist.html
iTextをGoogle App Engineから利用できるiText-gaeを公開しました
http://1t3xt.info/examples/browse/index.php

P.S.
Dec 21,2009, Release my first Google App Engine Application,Remove PDF Password Online, for introduce, please visit here.

Be Sociable, Share!

Windows Console Version PDF Timestamp Signer is Available For Download

With PDF Timestamp Signer, we can create Timestamp signature on a PDF without the need of Adobe Acrobat.
You can download it from here.
This version has some limited,

  • It only support create visible signature, and put the signature on the left bottom corner(100, 100, 300, 200) of the first page.
  • It use http://tss.pki.gva.es:8318/tsa as timestamp server
  • It only supports PKCS12 certificate file.
  • It run as windows 32 console application, so it has no windows, and only run in Dos command
Be Sociable, Share!

Convert RTF to PDF with Open Source library iText

Version 2.1 of iText has partial support for reading an RTF file and converting it to a PDF. This feature is still under development.

and here is the example on how to parser and convert RTF to PDF(from http://cfsearching.blogspot.com/2009/04/itext-preview-of-things-to-come-someday.html)

import com.lowagie.text.Document;

import com.lowagie.text.DocumentException;

import com.lowagie.text.pdf.PdfWriter;

import com.lowagie.text.rtf.parser.RtfParser;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

public class ConvertRTFToPDF {


public static void main(String[] args) {

 String inputFile = "sample.rtf";

 String outputFile = "sample_converted.pdf";

 // create a new document

 Document document = new Document();

 try {

     // create a PDF writer to save the new document to disk

     PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile));

     // open the document for modifications

     document.open();

     // create a new parser to load the RTF file

     RtfParser parser = new RtfParser(null);

     // read the rtf file into a compatible document

     parser.convertRtfDocument(new FileInputStream(inputFile), document);

     // save the pdf to disk

     document.close();

     System.out.println("Finished");

 } catch (DocumentException e) {

     e.printStackTrace();

 } catch (FileNotFoundException e) {

     e.printStackTrace();

 } catch (IOException e) {

     e.printStackTrace();

 }

}

}

Be Sociable, Share!