Archive for the ‘Uncategorized’ Category

Stopping WordPress from messing up quotation marks

Sunday, October 9th, 2011

If you want to share code with others using your wordpress blog, usually, these people will run into problems with your shared (quoted) code. WordPress processes the quotation marks into curly ones, which break your code when copy & pasting.

There are two solutions to this problem:

Now my blog is cured from this problem :-)

A working PDF Template Air example

Sunday, October 9th, 2011

It is built using Flash Builder 4 and the following steps:

Setup

  • create a new Air Project
  • add the .swc from Alive PDF v. 0.1.4.9 (0.1.5 is incompatible with AlivePDFTemplate at the moment)
  • add the cl folder from src of AlivePDF Template into your src folder

Import

add the following import statements, just after [CDATA[ in your <fx:Script> tag

import org.alivepdf.pdf.PDF;
import org.alivepdf.saving.Method;
import org.alivepdf.fonts.*;
import org.alivepdf.pages.Page;
import org.alivepdf.display.Display;
import org.alivepdf.layout.*;

import cl.huerta.pdf.PDFTemplate;
import cl.huerta.pdf.PDFi;
import cl.huerta.pdf.PDFParser;
import cl.huerta.pdf.decoders.ASCII85Decode;
import cl.huerta.pdf.PDFiPDFParser;
import cl.huerta.pdf.decoders.LZWDecode;
import cl.huerta.pdf.PDFContext;

Button

Add a button to control the process from the Design view (click on Design tab on top of your source). Click and drag the button from the available elements, then add a clickhandler under properties (on your right, click on the lightning bolt)

Code

Add the following code under the button click handler (based on the example given for AlivePDF Template).

//Must create a new PDFi instance (not PDF)
var myPDF : PDFi = new PDFi ( Orientation.PORTRAIT, Unit.MM, Size.LETTER );

// Import a file!!!! Just set the source file to an existing PDF
var pagecount:Number = myPDF.setSourceFile(File.desktopDirectory.nativePath + File.separator + "test.pdf" );
// Import a page. The first argument is the page number, the second the way it will be imported
var tplidx:Number = myPDF.importPage(1, '/MediaBox');

//This is important, you MUST add a page first!!!!
myPDF.addPage();
//Use the template in the current page
myPDF.useTemplate(tplidx, 10, 10, 90);

// This is not part of the original PDF. Just a test ^^
myPDF.setFont( FontFamily.ARIAL, Style.BOLD );
myPDF.setFontSize ( 18 );
myPDF.setXY( 10, 40 );
myPDF.addMultiCell ( 300, 1, "This is my PDF Headline" );

//Save the file
var f : FileStream = new FileStream();
var file : File = File.desktopDirectory.resolvePath("MyPDFi.pdf");
f.open( file, FileMode.WRITE);
var bytes : ByteArray = myPDF.save(Method.LOCAL);
f.writeBytes(bytes);
f.close();

Compile & Run

It will show an AIR window, with a button in it. On clicking the button the file "test.pdf" from your desktop (you should have placed one there!) will be added as a template to a new file MyPDFi.pdf.

Download

Download the project as exported (and zipped) by me http://blog.ideaday.de/max/wp-content/uploads/2011/10/ptair.zip

Witz II

Saturday, September 24th, 2011

Sie liegen auf der Couch.
"So ein Partnertausch ist wirklich nicht ganz ohne."
"Ja, aber ich wüsste schon gern, was unsere Frauen jetzt machen…"

Witz

Saturday, September 24th, 2011

Der Arzt ist nach der Untersuchung mit seinem Patienten sehr zufrieden und meint

"Und mit dem Sex klappt es doch sicher auch gut."
Antwortet der Patient:
" Na so dreimal in der Woche geht es schon…"
Arzt: Was? Bei Ihrer Konstition müsste es aber dreimal am Tag gehen."
Patient: " Ich tu ja mein bestes, aber als Katholischer Priester auf dem Land ist das schwer.

Crowley

Saturday, September 24th, 2011

We place no reliance
On Virgin or Pigeon;
Our method is Science,
Our aim is Religion.

A great book

Thursday, September 22nd, 2011

How to win with high self-esteem

Saturday, September 10th, 2011

Amazon

Monday, September 5th, 2011

Einkaufen bei Amazon

Klingt wie Science Fiction …

Thursday, August 11th, 2011

Doch es gibt sie wirklich, die "Südatlantische Anomalie", und in ihr sind Anti-Protonen. Siehe Spiegel.

Sita sings the blues music

Friday, June 17th, 2011

Link to the artist's page: http://toddmichaelsen.com/sita-sings-the-blues.cfm