Hi-Res PDF Image Does Not Reflect Canvas Drawing

Hello Forum,

I am working with one of the examples from the [Generative Design book](// http://www.generative-gestaltung.de) and I am trying to make a super hi-res image of the drawings I do. But, the PDF lines are never as delicate as they are in the design window. Does anyone know how to fix this? Thanks in advance for your suggestions. :slight_smile:

import processing.pdf.*;
import java.util.Calendar;

boolean recordPDF = false;

ArrayList history = new ArrayList();
float dist = 80;



 
void setup() {
  size(1000,700);
  background(255);
  stroke(0, 150);
  strokeWeight(.01);
  noFill();
}
void draw() {
}


void mouseDragged() {
 
  PVector d = new PVector(mouseX, mouseY, 0);
  history.add(0, d); 
  for (int p=0; p<history.size (); p++) {
    PVector v = (PVector) history.get(p);
    float join = p/history.size() + d.dist(v)/dist;
    if (join < random(0.9) && mouseButton == LEFT) {  
      line(d.x, d.y, v.x, v.y);
    }  
  }
}
 
void keyPressed() {
  if (key == 'x') {
    background(255);
    history.clear();
  }
  // ------ pdf export ------
  // press 'r' to start pdf recordPDF and 'e' to stop it
  // ONLY by pressing 'e' the pdf is saved to disk!
  if (key =='r' || key =='R') {
    if (recordPDF == false) {
      beginRecord(PDF, timestamp()+"_.pdf");
      println("recording started");
      recordPDF = true;
    }
  } 
  else if (key == 'e' || key =='E') {
    if (recordPDF) {
      println("recording stopped");
      endRecord();
      recordPDF = false;
      background(255); 
    }
  } 
}

// timestamp
String timestamp() {
  Calendar now = Calendar.getInstance();
  return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
}
1 Like

Have u tried zooming in? I don’t know the mechanics behind the pdf library but it seems that all the lines are drawn as vectors (meaning they should scale nicely to whatever resolution you’re using)

Hi Tony,

Thanks for writing back. The links are clean but super thick.

Here’s the canvas:

Here’s the PDF

It seems like there are extra layers to me…

1 Like

Interesting problem.

Do you need it to be a pdf? If you’re fine with just a screengrab, maybe save the raw canvas with save()?

If you’re set on a pdf, you might try messing around with the stroke() and strokewidth() in setup?

1 Like

Hello Tony and Forum,

So, I basically went through every version of PDF making here:
https://processing.org/reference/libraries/pdf/index.html

And, " Single Frame (No Screen Display)" produced the best results.

2 Likes