Wednesday 29 August 2007

Using headers in GWT FlexTable

I'm a moron. I've been dicking around with headers in GWT FlexTable for a while. I simply added rows and used a different styleset for the headers. Then I had to subtract and add for each table operation....

The solution is (of course) to insert table headers with the DOM-class in GWT.


/**
* Initializes the table with header rows. The headers are defined by the headerModel
* This adds the header rows directly to the table, using the DOM-class. The current FlexTable implemenetation
* doesn't have headers. This uses the normal html ... syntax
*/
private void initTable() {

Element thead = DOM.createTHead();

DOM.insertChild(table.getElement(), thead, 0);

for (int row = 0; row <>

Element tr = DOM.createTR();
DOM.appendChild(thead, tr);
for (int col = 0; col <>

Element th = DOM.createTH();
DOM.appendChild(tr, th);

// NB!!!! camelback on attributes for IE or despair
DOM.setElementAttribute(th, "colSpan", String.valueOf(headerModel.getHeaderSpan(row, col)));
DOM.setElementAttribute(th, "align", "left");
DOM.setElementAttribute(th, "border", "1");

//set header text
DOM.setInnerText(th, headerModel.getHeaderText(row, col));
}
}

}

Now the number of rows, clear etc works fine. FlexTable uses "correct". The camel back IE "feature" took me a while though.

Saturday 11 August 2007

Printing protected PDF files

Once every year, I need to print a protected PDF-file. Of course I forget what I did in between. The main problem is that you can't print a protected file from the Adobe Reader even if you have the password. They want you to buy the full Adobe product
  1. Download pdfbox from sourceforge. The latest version does not work but version 0.7.0 works fine.
  2. Unzip it and go to the bin directory. Run: Decrypt.exe . And the file is printable!!
While Googling, I found the PDFCrack utility (also on sourceforge), which is used to crack pdf files. It's now running in the background. This may also work