We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Help with PDF export
Page Index Toggle Pages: 1
Help with PDF export (Read 1318 times)
Help with PDF export
Nov 4th, 2009, 6:46am
 
Hey

sorry guys but I got a problem.
I loaded a font in my processing-project. when i display the project for a test it shows me the right font. But after a while i look at the PDF export file and in there where a standard font.. not mine which i choose.

I hope my english is not two bad. Thanks for helping and have a good day

If u need any Screens or the PDF i try to uplaod it.

Code:

import processing.pdf.*;

Kurve  kurv;

float   i = 3; // 300 dpi 4.16 multiplikator
float   varx = 842.0; // Breite A4 auf 72 dpi in PXL
float   vary = 1191.0; // Breite A4 auf 72 dpi in PXL
int     xSize;
int     ySize;
String[]  ldr;
int     ndx = 0;
int    bland = 0;
int    blandziel = 0;
int    maxbland = 16;
int    zahler = 4;
int    abstandvar;
int  koor[][] = new int[16][8];
int    nwhnrall;
int    vrbl = 0;
int    vrbl2 = 0;
float    varheight;
float    varall;
float    varhold;
float    varhold2;
float    varhold3;
float    varhold1;
float    varhold12;
float    varhold13;
PFont  GravurLight;

void setup() {
 noLoop();
 varx = varx * i;
 vary = vary * i;
 varx += 0.5;
 vary += 0.5;
 xSize = (int)varx;
 ySize = (int)vary;
 size(xSize,ySize);
 abstandvar = height/maxbland;
 smooth();
 beginRecord(PDF, "export1.pdf");
 GravurLight = createFont("GravurCondensed-Light", 12, true);
 background(255);
}

void draw() {
 noFill();
 ldr = loadStrings("daten.txt");
   while (ndx < ldr.length) {
     String [] pcs = split(ldr[ndx], "-");
     if (pcs.length == 20) {
       while (zahler < pcs.length) {
         int e = int (pcs[zahler]);
         koor[blandziel][6] = koor[blandziel][6] + e;
         koor[bland][7] = koor[bland][7] + e;
         blandziel++;
         zahler++;
       }
     }
     nwhnrall = nwhnrall + koor[bland][7];
     bland++;
     ndx++;
     zahler=4;
     blandziel=0;
   }
   bland = 0;
   ndx = 0;
   
   varall = nwhnrall;
   varheight = height;
   varheight = varheight - 16.0 * 6;
   
   for (int cnt1=0; cnt1 < 16; cnt1++) {
     koor[cnt1][0] = vrbl + 8;
     varhold = koor[cnt1][0];
     varhold3 = koor[cnt1][7];
     varhold2 = varhold + varheight / varall * varhold3 -2.0;
     koor[cnt1][1] = (int) varhold2;
     koor[cnt1][2] = 0;  
     vrbl = koor[cnt1][1];
     
     koor[cnt1][3] = vrbl2 + 8;
     varhold1 = koor[cnt1][3];
     varhold13 = koor[cnt1][6];
     varhold12 = varhold1 + varheight / varall * varhold13 -2.0;
     koor[cnt1][4] = (int) varhold2;
     koor[cnt1][5] = 0;
     vrbl2 =  koor[cnt1][4];  
   }
   while (ndx < ldr.length) {
     String [] pcs = split(ldr[ndx], "-");
     if (pcs.length == 20) {
       int a = int (pcs[0]);
       int b = int (pcs[1]);
       int c = int (pcs[2]);
       String d = pcs[3];
       while (zahler < pcs.length) {
         int e = int (pcs[zahler]);
         kurv = new Kurve(blandziel,bland,color(a,b,c,85),e/500,d);
         kurv.display();
         blandziel++;
         zahler++;
       }
     }
     bland++;
     ndx++;
     zahler=4;
     blandziel=0;
   }
 println("LÄUFT GUT");
 endRecord();
}

class Kurve {
 int     z;
 float   vz;
 int  start;
 int  ziel;
 int    varstart;
 int    varziel;
 color farbe;
 float vpunkt11;
 float vpunkt12;
 float vpunkt21;
 float vpunkt22;
 int  punkt11;
 int  punkt12;
 int  punkt21;
 int  punkt22;
 String name;
 float logschwank (int x) {
   return (log(x) / log(height));
 }
 float schwank;
 
 Kurve (int _start, int _ziel, color _farbe, int _z, String _name) {
   start = _start;
   ziel = _ziel;
   farbe = _farbe;
   z = _z;
   name = _name;
   
   schwank = logschwank(abstandvar) * width;
 }
 

 
 void display() {
   if (start == ziel) {
     fill(0);
     textFont(GravurLight);
     text(name, 5, koor[start][0]+3, 17*i, (koor[start][0]+(koor[start][1]-koor[start][0])));
     text(name, width-17*i, koor[start][3]+3, width-5, (koor[start][3]+(koor[start][4]-koor[start][3])));
     noFill();
     stroke(0,0,0,128);
     line(5,koor[start][0]-2,20*i,koor[start][0]-2);
     line(5,koor[start][1]+2,20*i,koor[start][1]+2);
     line(width-5,koor[start][3]-2,width-20*i,koor[start][3]-2);
     line(width-5,koor[start][4]+2,width-20*i,koor[start][4]+2);
   }
   
   while (z > 0) {
     stroke(farbe);
     varstart = koor[start][0] + koor[start][2];
     varziel = koor[ziel][3] + koor[ziel][5];
     koor[start][2] =  koor[start][2] + 2;
     koor[ziel][5] = koor[ziel][5] + 2;
     if (koor[start][0] + koor[start][2] > koor[start][1]) {
       koor[start][2] = 0;
     }
     if (koor[ziel][3] + koor[ziel][5] > koor[ziel][4]) {
       koor[ziel][5] = 0;
     }
     vpunkt11 = random(120*i,schwank);
     punkt11 = (int)vpunkt11;
     vpunkt12 = random(varstart-abstandvar/16,varstart+abstandvar/16);
     punkt12 = (int)vpunkt12;  
     vpunkt21 = random(schwank);
     punkt21 = (int)vpunkt21;
     vpunkt22 = random(varziel-abstandvar/16,varziel+abstandvar/16);
     punkt22 = (int)vpunkt22;  
     bezier(20*i, varstart, punkt11, punkt12, punkt21, punkt22, width-20*i, varziel);  
     z--;
   }
 }
}
   

Re: Help with PDF export
Reply #1 - Nov 4th, 2009, 7:21am
 
Hey

just a small update... used this function

Code:
      textMode(SCREEN); 



now the text is converted into vectorgraphics buuuut how ever it uses the standart font.
Re: Help with PDF export
Reply #2 - Nov 4th, 2009, 8:10am
 
Re: Help with PDF export
Reply #3 - Nov 4th, 2009, 9:57am
 
hey i read it but where do i find the hint for my situation?

best wishes
Re: Help with PDF export
Reply #4 - Nov 4th, 2009, 1:28pm
 
I was thinking of the paragraph "Another option for type, is to use createFont() with a TrueType font (some OpenType fonts also work). Any font that shows up in PFont.list() should work, or if not, adding a .ttf file to the data directory and calling createFont("fontname.ttf") will also work."
You are on Mac?
Re: Help with PDF export
Reply #5 - Nov 4th, 2009, 2:29pm
 
Yes iam working on a Mac. I will try tomorrow if this could help

thanks Smiley good night
Re: Help with PDF export
Reply #6 - Nov 8th, 2009, 8:59am
 
hi

i just made this little script for a test... but in my exportfile, there is only a white block.

Code:
import processing.pdf.*;
PFont font;

void setup () {
size (400,400);
beginRecord(PDF, "export1.pdf");
smooth();
background(0);
font = loadFont("Rockwell-Italic-48.vlw");
textFont(font, 32);
noLoop();
}


void draw () {
text("word", 15, 50);
println("LÄUFT GUT");
endRecord();
}

Re: Help with PDF export
Reply #7 - Nov 10th, 2009, 6:48am
 
Hi,

its horrible that nobody knows what i made wrong Sad
I tried another way to create an PDF file. Now it display the right font.... buuut i can not chance the size of the prog by changing a multiplier.

Code:
import processing.pdf.*;

float i = 1; //multiplier
float varx = 800.0; //width
float vary = 1000.0; //height
int xSize;
int ySize;

void setup() {
varx = varx *i;
vary = vary *i;
varx += 0.5;
vary += 0.5;
xSize = int(varx);
ySize = int(vary);
size(xSize,ySize, PDF, "test.pdf");
background(255);
stroke(0);
}

void draw() {
line(20*i,20*i,width-20*i,height-20*i);
exit();
}


I made a little testprog. if u raise the multiplier "i" the PDF shows only a detail in the PDF file. If i import the PDF in Illustrator the rest is in there but its not displayed by acrobat reader or the preview function of mac.

If anybody have a hint please post it! would be helpful!

Sascha
Page Index Toggle Pages: 1