We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, everyone,
I have a problem with exporting GIS map graphics as PDF, which has many polygons as PDF. Thanks to PShape, I can draw the polygons with holes on screen, but the problems are the polygons with holes are badly exported into PDF file with unnecessary lines.
Could this be the default setting in processing PDF library? If anyone knows how to make better PDF outputs, I truly appreciate!!
Regards,
import processing.pdf.*;
import controlP5.*;
int width = 800;
int height = 800;
Button b1;
ControlP5 controlP5;
boolean pdfSave=false;
PGraphics pdf;
PShape s;
void setup(){
size(width,height,P2D);
smooth();
controlP5=new ControlP5(this);
b1 = controlP5.addButton("PDF SAVE",350,width-100,height-20,70,16);
b1.setId(1);
s = createShape();
s.beginShape();
s.fill(255);
s.stroke(0);
s.strokeWeight(2);
// Exterior contour of shape(shell)
s.beginContour();
s.vertex(-100,-100);
s.vertex(100,-100);
s.vertex(100,100);
s.vertex(-100,100);
s.vertex(-100,-100);
s.endContour();
s.strokeWeight(1);
// Interior contour of shape (holes)
s.beginContour();
s.vertex(-10,-10);
s.vertex(10,-10);
s.vertex(10,10);
s.vertex(-10,10);
s.vertex(-10,-10);
s.endContour();
// Interior contour of shape (holes)
s.beginContour();
s.vertex(-80,-80);
s.vertex(-50,-80);
s.vertex(-50,-50);
s.vertex(-80,-50);
s.vertex(-80,-80);
s.endContour();
s.endShape();
pdf = (PGraphicsPDF) createGraphics(width, height, PDF, "pscreen.pdf");
}
void draw(){
if(pdfSave){
beginRecord(pdf);
}
background(255);
translate(width/2, height/2);
shape(s);
translate(-width/2, -height/2);
if(pdfSave) {
endRecord();
pdfSave=false;
println("PDF SAVED");
}
loop();
}
void controlEvent(ControlEvent theEvent) {
if(theEvent.controller().id()==1){
pdfSave=true;
}
}