Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF: pixelDensity(2) throws off scaling when creating PDFs using beginRecord() and createGraphics(PDF) #6216

Open
rapatski opened this issue Aug 26, 2021 · 1 comment

Comments

@rapatski
Copy link

Description

With pixelDensity(2) enabled, PDF exports using offscreen buffers like beginRecord() and createGraphics(PDF) need to be scaled by 0.5 (1 / float(pixelDensity)) to have the expected result.

Steps to Reproduce

import processing.pdf.*;

void settings()
{
  pixelDensity(2);
  size(500, 500);
}

void setup()
{
  beginRecord(PDF, "test.pdf");

  //scale(1 / float(pixelDensity)); // uncomment to get expected pdf output
  background(0, 255, 0);
  rect(0, 0, width, height, 100, 100, 100, 100);

  endRecord();
}

void draw() {}

void exportUsingPGraphics()
{
  PGraphics pdf = createGraphics(width, height, PDF, "test_usingpgraphics.pdf");
  pdf.beginDraw();
  pdf.background(0, 0, 255);
  //pdf.scale(1 / float(pixelDensity)); // uncomment to get expected pdf output
  pdf.fill(255, 0, 0);
  pdf.rect(0, 0, width, height, 100, 100, 100, 100);
  pdf.dispose();
  pdf.endDraw();
}

void keyReleased()
{
  exportUsingPGraphics();
}

Your Environment

  • Processing version: 3.5.4
  • Operating System and OS version: macOS Mojave 11.4 (20F71)
@rapatski rapatski changed the title pixelDensity(2) throws off scaling when creating PDFs using beginRecord() and createGraphics(PDF) PDF: pixelDensity(2) throws off scaling when creating PDFs using beginRecord() and createGraphics(PDF) Aug 29, 2021
@karan-prajapati-976
Copy link

I want to work on this issue please assign me this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants