Allright, found solutions to all the problems.
Code:pg = (PGraphicsPDF) createGraphics(wide, hi, PDF, "raster-###.pdf");
does the job, and since the application exits after the conditions are done I can call it in draw().
Check the first version here:
Code://*****(c)2010 by Philippe Bono*****
//*****licensed under GPL*****
import processing.pdf.*;
import interfascia.*;
//radio declarations
GUIController c;
IFRadioController rc;
IFRadioButton b1, b2, b3;
//textfield stuff
IFTextField tw, th;
IFLabel lw, lh;
//declare PG
PGraphicsPDF pg;
//Grid variables
int x1;
int y1;
//for precise calculation
float mmX;
float mmY;
//input
String xStr;
String yStr;
//pdf groesse
int wide;
int hi;
/*********************************************
*SETUP
**********************************************/
void setup() {
size(400, 400);
//Text Field creation
th = new IFTextField("Text Field", 25, 10, 40);
lh = new IFLabel("Breite in milimetern", 80, 10);
tw = new IFTextField("Text Field", 25, 40, 40);
lw = new IFLabel("hoehe in milimetern", 80, 40);
//Radio Button creation
c = new GUIController(this);
rc = new IFRadioController("Mode Selector");
b1 = new IFRadioButton("72 dpi", 20, 70, rc);
b2 = new IFRadioButton("150 dpi", 20, 90, rc);
b3 = new IFRadioButton("300 dpi", 20, 110, rc);
}
/*********************************************
*DRAW
**********************************************/
void draw(){
c.add(tw);
c.add(lw);
c.add(th);
c.add(lh);
xStr = tw.getValue();
yStr = th.getValue();
//println(yStr);
//println(xStr);
c.add(b1);
c.add(b2);
c.add(b3);
/*******das folgende ist getestet und funktioniert, die werte werden correct uebernommen******/
if (b1.isSelected() == true){
wide = 595;
hi = 840;
} else if (b2.isSelected() == true){
wide = 1240;
hi = 1745;
} else if (b3.isSelected() == true){
wide = 2480;
hi = 3508;
}
if (b1.isSelected() == true || b2.isSelected() == true || b3.isSelected() == true){
//3satze
mmX = (Integer.parseInt(xStr)*wide)/210; //297*210 ist din a4 in milimetern
//println(mmX);
x1 = (int) mmX;
mmY = (Integer.parseInt(yStr)*hi)/297;
y1 = (int) mmY;
//***********pgGraphics screen************************
pg = (PGraphicsPDF) createGraphics(wide, hi, PDF, "raster-###.pdf");
//println (hi);
//println(wide);
beginRecord(pg);
background (255);
//pg.stroke(111);
for (int i = 1; i < hi; i++) {
line(0, i*x1, wide, i*x1); //das ist die breite X
line(i*y1, 0, i*y1, hi); //das ist die hoehe y
if (i >= hi){ //soll den for loop brechen falls bedingung erfuellt
break;
}
//println(i);
}
endRecord();
exit();
}
}