# Export large scale print file + web file

**URL:** <https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380>\
**Category:** Beginners\
**Created:** [May 31, 2021, 8:35am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380 "2021-05-31T08:35:15Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![res56](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@res56](https://discourse.processing.org/u/res56)\
**Post date:** [May 31, 2021, 8:35am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/1 "2021-05-31T08:35:15Z")

</div>

Hey processing community,

is it possible to export 2 files at the same time for web and print?

Thanks a lot in advance,

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [May 31, 2021, 8:38am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/2 "2021-05-31T08:38:19Z")

</div>

Hi @res56 ,

Can you give more details on “web” and “print”?

If you mean `svg` / `pdf` or `png` / `jpg`, yes it’s possible :

- [`save()`](https://processing.org/reference/save_.html)
- [SVG export](https://processing.org/reference/libraries/svg/index.html)
- [PDF export](https://processing.org/reference/libraries/pdf/index.html)

---

<div class="post-metadata">

**Author:** ![res56](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@res56](https://discourse.processing.org/u/res56)\
**Post date:** [May 31, 2021, 8:39am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/3 "2021-05-31T08:39:35Z")

</div>

For print pdf would be perfect. For web png/jpg.

At the moment I only get an image with saveFrame(“balls-#####.png”);

The challenge is the resolution size. For web should be smaller than print aand the images should be the same \> have to be generated within one instance.

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [May 31, 2021, 8:43am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/4 "2021-05-31T08:43:34Z")

</div>

Ok I just tested it and if you use the PDF export, using `save()` doesn’t work :

```processing
import processing.pdf.*;

void setup() {
  size(400, 400, PDF, "filename.pdf");
}

void draw() {
  // Draw something good here
  line(0, 0, width/2, height);
  
  save("test.png");

  // Exit the program 
  println("Finished.");
  exit();
}

```

```auto
--> RuntimeException: No save() for PGraphicsPDF

```

You might want to run your code twice, one with the PDF export and another one with `save(...)` 😉

---

<div class="post-metadata">

**Author:** ![res56](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@res56](https://discourse.processing.org/u/res56)\
**Post date:** [May 31, 2021, 8:49am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/5 "2021-05-31T08:49:56Z")

</div>

```auto
void mousePressed() { 
  saveFrame("balls-#####.png");
   surface.setResizable(true);
   surface.setSize(7200, 9600);
   pdf = (PGraphicsPDF)beginRecord(PDF, "test.pdf");
   endRecord();
   exit();
} 

```

But the pdf can’t be opened :-/  
I created a generative scipt. In case I run the code twice the result is slightly different.

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [May 31, 2021, 8:51am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/6 "2021-05-31T08:51:01Z")

</div>

> [@res56](#):
>
> I created a generative scipt. In case I run the code twice the result is slightly different.

Then the solution is to export a PDF and then open it in an image editor like Gimp and export it as png 😉

---

<div class="post-metadata">

**Author:** ![res56](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@res56](https://discourse.processing.org/u/res56)\
**Post date:** [May 31, 2021, 9:00am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/7 "2021-05-31T09:00:55Z")

</div>

😂

okay sounds simpel I will give it a try 🙂

---

<div class="post-metadata">

**Author:** ![res56](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@res56](https://discourse.processing.org/u/res56)\
**Post date:** [May 31, 2021, 9:06am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/8 "2021-05-31T09:06:00Z")

</div>

> [@res56](#):
>
> ```auto
> void mousePressed() { 
> saveFrame("balls-#####.png");
> surface.setResizable(true);
> surface.setSize(7200, 9600);
> pdf = (PGraphicsPDF)beginRecord(PDF, "test.pdf");
> endRecord();
> exit();
> } 
> 
> ```

This code works, only the pdf is empty (but I can open it)

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [May 31, 2021, 9:08am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/9 "2021-05-31T09:08:49Z")

</div>

> [@res56](#):
>
> This code works, only the pdf is empty (but I can open it)

This is because there is no drawing operation between the `beginRecord()` and `endRecord()` functions.

This code works thought (without using `PDF` in the `size()` method) :

```auto
import processing.pdf.*;

void setup() {
  size(400, 400);
  noLoop();
  beginRecord(PDF, "filename.pdf"); 
}

void draw() {
  // Draw something good here
  line(0, 0, width/2, height);
  
  save("test.png");

  endRecord();
}

```

---

<div class="post-metadata">

**Author:** ![res56](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@res56](https://discourse.processing.org/u/res56)\
**Post date:** [May 31, 2021, 9:08am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/10 "2021-05-31T09:08:51Z")

</div>

Ah I know, because only the code between begin/end Record is stored

---

<div class="post-metadata">

**Author:** ![res56](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@res56](https://discourse.processing.org/u/res56)\
**Post date:** [May 31, 2021, 9:26am UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/11 "2021-05-31T09:26:07Z")

</div>

In fact your code works. But the program crashes if I set the canvas size to 2400x3200 for high res resolution :-/

Thanks anyway!

---

<div class="post-metadata">

**Author:** ![VOIDupgraded](https://avatars.discourse-cdn.com/v4/letter/v/91b2a8/32.png) [@VOIDupgraded](https://discourse.processing.org/u/VOIDupgraded)\
**Post date:** [June 1, 2021, 4:05pm UTC](https://discourse.processing.org/t/export-large-scale-print-file-web-file/30380/12 "2021-06-01T16:05:01Z")

</div>

If your program is crashing due to file size you might want to try increasing the available memory.  
`File > Preferences`  
 ![Capture](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f8cb20ec4f54e28327c5daacf0495cdeef3fb06e.png)
