# PDF export doesn't work with Hyper framework

**URL:** <https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747>\
**Category:** Libraries\
**Created:** [December 18, 2018, 11:25pm UTC](https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747 "2018-12-18T23:25:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![buraquex](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@buraquex](https://discourse.processing.org/u/buraquex)\
**Post date:** [December 18, 2018, 11:25pm UTC](https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747/1 "2018-12-18T23:25:37Z")

</div>

Hello,

I recently used Joshua Davis’ fantastic hype framework for a poster design. It worked great, until I decided to export to a pdf as a vector. All I get is an empty pdf with no graphics. Pls help me if there any one out there who also uses this great framework and can get pdf with vectors.

Thank you so much!

---

<div class="post-metadata">

**Author:** ![buraquex](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@buraquex](https://discourse.processing.org/u/buraquex)\
**Post date:** [December 19, 2018, 5:15am UTC](https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747/2 "2018-12-19T05:15:40Z")

</div>

Oh, I just watched Joshua’s videos on Skillshare and he actually shows how to get vectors out, very clearly. Thank you Joshua 🙂

So problem solved, case closed 🙂

---

<div class="post-metadata">

**Author:** ![dan850](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@dan850](https://discourse.processing.org/u/dan850)\
**Post date:** [December 19, 2018, 9:15am UTC](https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747/3 "2018-12-19T09:15:05Z")

</div>

@buraquex that’s great news! Do you mind posting the link to Joshua’s videos for future readers please?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [December 21, 2018, 3:51pm UTC](https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747/4 "2018-12-21T15:51:06Z")

</div>

> [@dan850](#):
>
> the link to Joshua’s videos

I _think_ that is:

[https://www.skillshare.com/classes/Programming-Graphics-I-Introduction-to-Generative-Art/782118657](https://www.skillshare.com/classes/Programming-Graphics-I-Introduction-to-Generative-Art/782118657)

---

<div class="post-metadata">

**Author:** ![buraquex](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@buraquex](https://discourse.processing.org/u/buraquex)\
**Post date:** [December 22, 2018, 5:09am UTC](https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747/5 "2018-12-22T05:09:26Z")

</div>

oh yes, this is the one. Close to the last chapters, he shows how to output image and vector files.

---

<div class="post-metadata">

**Author:** ![Hub33s](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@Hub33s](https://discourse.processing.org/u/Hub33s)\
**Post date:** [January 1, 2019, 1:08pm UTC](https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747/6 "2019-01-01T13:08:27Z")

</div>

@buraquex it sounds like I am having the same problem you were, only I can’t get proper vector output by following Joshua’s process, it renders but only as a pixel based image. I would be super grateful if for any insight as to what I am missing: [Export to PDF will not render vectors](https://discourse.processing.org/t/export-to-pdf-will-not-render-vectors/7064)

---

<div class="post-metadata">

**Author:** ![buraquex](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@buraquex](https://discourse.processing.org/u/buraquex)\
**Post date:** [January 5, 2019, 7:46pm UTC](https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747/7 "2019-01-05T19:46:49Z")

</div>

Hi @Hub33s, here is how you do it:

1. First add this line to the beginning of your code: **import processing.pdf.\*;**

2. Also don’t forget to add the hype framework: **import hype.\*;**

3. Don’t forget to add this code in setup() function: **H.init(this).background(#FFFFFF);**

4. In your draw() function add this code:

```auto
void draw() {
  PGraphics tmp = null;

  if (record) {
    tmp = beginRecord(PDF, "render-######.pdf");
  }

  if (tmp == null) {
    H.drawStage();
  } else {
    PGraphics g = tmp;
    boolean uses3D = false;
    float alpha = 1;
    H.stage().paintAll(g, uses3D, alpha);
  }

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

```

1. And finally add this code outside of any other functions:

```auto
void keyPressed() {
  if (key == 's') {
    record = true;
    draw();
  }
}

```

Each time you press ‘s’ key, a new version of the pdf will be saved to where the project is.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Hub33s](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@Hub33s](https://discourse.processing.org/u/Hub33s)\
**Post date:** [January 6, 2019, 10:55pm UTC](https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747/8 "2019-01-06T22:55:40Z")

</div>

Thank you, much appreciated.

---

<div class="post-metadata">

**Author:** ![hupco](https://avatars.discourse-cdn.com/v4/letter/h/b19c9b/32.png) [@hupco](https://discourse.processing.org/u/hupco)\
**Post date:** [November 3, 2022, 8:48pm UTC](https://discourse.processing.org/t/pdf-export-doesnt-work-with-hyper-framework/6747/9 "2022-11-03T20:48:13Z")

</div>

Hi. I can’t print 3D in PDF HBox. I suggest I can print 3D projection in Hype.  
It prints 2D as expected with HRect and `H.stage().paintAll(g, false, 1);`

Second param in `paintAll` is `boolean usesZ`.

Here is simplified not working example with HBox and `H.stage().paintAll(g, true, 1);`

```auto
import hype.*;
import processing.pdf.*;

boolean record = false;

void setup() {
  size(600, 600, P3D);
  H.init(this).background(#ff00ff).autoClear(true);
  
  HBox d = new HBox();
  d
    // .depth(20)
    .loc( width/2, height/2, 10 )
    .width(20)
    .height(20)
  ;

  H.add(d);
}

void draw() {
  PGraphics tmp = null;

  if (record) {
    tmp = beginRecord(PDF, "render-HBox.pdf");
  }

  if (tmp == null) {
    H.drawStage();
  } else {
    PGraphics g = tmp;
    H.stage().paintAll(g, true, 1);
  }

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

void keyPressed() {
  if (key == 's') {
    record = true;
    // draw();
  }
}

```
