PDF Libraries

MWXMWX
edited December 2014 in Questions about Code

Hi,

I am trying to save a PDF so that I can't use it as a vector graphic.

However, whenever I save the frame it doesn't save the black background - I get either a white or completely transparent background.

I am running a max map patch through my sketches so you may not be able to run the code that i'm using but just wondering if anyone else has this problem and if so how can I fix it? I've tried using a number of different examples from the PDF libraries but seem to get the same problem. I need to use PDF Files from 3D Geometry (With Screen Display).

import processing.pdf.*;

import maxlink.*;
MaxLink link = new MaxLink(this,"color_sketch");

// these must be public
public float b,s,c,p,v,B,n,r;
public int bb,ss,cc,pp,vv,BB,nn;

boolean record;

void setup() {
  size(600,800,P3D);
  background(0);
  smooth();


  link.declareInlet("b");
  link.declareInlet("s");
  link.declareInlet("c");
  link.declareInlet("p");
  link.declareInlet("v");
  link.declareInlet("B");
  link.declareInlet("n");

  link.declareInlet("bb");
  link.declareInlet("ss");
  link.declareInlet("cc");
  link.declareInlet("pp");
  link.declareInlet("vv");
  link.declareInlet("BB");
  link.declareInlet("nn");

  }



void draw() {

if (record) {
    beginRaw(PDF, "output.pdf");
  }



pushMatrix();

  fill(0, 8);
  rect(0, 0, width, height);   

stroke(255);
strokeWeight(1);
line(cc*20,ss*20,bb*20,mouseY);


stroke(255);
strokeWeight(1);
line(mouseX,bb*40,bb*60,BB);


  popMatrix();

  if (record) {
    endRaw();
  record = false;
}
}


// Hit 'r' to record a single frame
void keyPressed() {
  if (key == 'r') {
    record = true;
}
}

Any help would be greatly appreciated.

\MWX//

Tagged:

Answers

  • Answer ✓

    See the sticky of the forum: Processing forum rules and advices
    Bad formatting and no category selection.
    Fixed that for you.

  • Answer ✓

    BTW, you don't get the black background because you use an almost transparent black as fill color of your rectangle... Not sure if it can work in PDF. Perhaps it would be better if you draw a totally black background the first time.

    Not sure why you use a 3D renderer and PDF export, when your sketch is 2D.

  • Hello PhiLho,

    Thanks for fixing my post.

    The background of the sketch is black and the transparent rectangle creates a sort of fade on all of the lines drawn, so that transparent rectangle is part of the overall "aesthetic" of the image.

    I need to get a PDF from the image so I can print it in high res but none of the options seem to be working.

    Was using a 3D renderer for this sketch as I had been sending it to another programme using syphon.

  • More often than not i'm just getting a white screen :(

  • As said (in an unclear way, though), you have to call background(0);just after the beginRaw() too. The first one in setup() isn't "seen" by the PDF library.

Sign In or Register to comment.