Unit testing PDF is hard. You can, for example, use the
SimpleTextExtractor to suck out all the text from your ouput PDF, but
you don't know what font it's in, what the table borders look like, or
if the text is even visible. Off the bottom of the page? Covered by
something else? Same color as its bacground? No way to know with just
that text extractor. And finding out becomes exponentially more
difficult.
Even iText's unit tests generally involve running a program and checking
the output by opening it in a PdfReader and querying the page count.
Searching for the right text is an improvement, but it still leaves some
gaping holes.
Repeat after me: "Unit testing PDF is hard."
--Mark Storer
Senior Software Engineer
Cardiff.com
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
________________________________
From: King Goldman [mailto:king.gold...@gmail.com]
Sent: Tuesday, November 23, 2010 3:02 PM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] writing junit tests for a class that
writes atable to the pdf
Can somebody guide me in writing a junit test for the following
class?
import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
public class tablePDF{
public static void main(String arg[])throws Exception{
Document document=new Document();
PdfWriter.getInstance(document,new
FileOutputStream("tablePDF.pdf"));
document.open();
PdfPTable table=new PdfPTable(2);
table.addCell("City");
table.addCell("State");
table.addCell("Jersey City");
table.addCell("New Jersey");
document.add(table);
document.close()
}
}
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php