# Printing from Juce

**URL:** <https://forum.juce.com/t/printing-from-juce/412>\
**Category:** Windows\
**Created:** [September 26, 2005, 4:27pm UTC](https://forum.juce.com/t/printing-from-juce/412 "2005-09-26T16:27:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [September 26, 2005, 4:27pm UTC](https://forum.juce.com/t/printing-from-juce/412/1 "2005-09-26T16:27:19Z")

</div>

I need to print, as in a paper printer, from Juce. Specifically, is there a way I can draw into a juce graphic like you can a MFC Graphics Context, then output it to a printer, like in MFC? Through a quick look in the api I could barely find the word “print” two times… This will be windows only, at least for now, it may be ported to linux.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [September 26, 2005, 6:37pm UTC](https://forum.juce.com/t/printing-from-juce/412/2 "2005-09-26T18:37:00Z")

</div>

yeah, this is something I’ve yet to look at at all… will do as soon as I can get the chance. Hopefully it’s not something that’ll be too tricky to add, but I don’t think I’ve ever written any printing code before, so don’t know.

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [September 26, 2005, 6:50pm UTC](https://forum.juce.com/t/printing-from-juce/412/3 "2005-09-26T18:50:52Z")

</div>

Unknown how it is on other systems, I’ve only done it on windows. Just basically paint an image the size of the page, and send it to the printer, pretty easy in mfc…

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [September 27, 2005, 11:08pm UTC](https://forum.juce.com/t/printing-from-juce/412/4 "2005-09-27T23:08:57Z")

</div>

I do apologize for the double-post but it has been a few days.

Does anyone have experience on printing from Juce so I can save a good bit of time?

---

<div class="post-metadata">

**Author:** ![Amando](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Amando](https://forum.juce.com/u/Amando)\
**Post date:** [June 4, 2006, 12:58am UTC](https://forum.juce.com/t/printing-from-juce/412/5 "2006-06-04T00:58:32Z")

</div>

hello folks,

I am new to JUCE, but i have got the API solution here, works fine:

[code]#include \<windows.h\>

/\*

1. call the func, the first time, like:  
HDC printDC = toPaper(START\_PRINTER);

2. now make a loop for each page, like:  
int p;  
for (p=0; p\<numPages; p++)  
{  
StartPage(printDC);  
// DT\_WORDBREAK is a collecting constant, recommended for multiLine output  
DrawText(printDC, “once upon a time…”, 19, &rt, DT\_WORDBREAK);  
LineTo(printDC, 300, 300);  
EndPage(printDC);  
}

3. when you ar done, call the func a second time like:  
HDC printDC = toPaper(END\_PRINTER);

/////////// Dev-C++: to use the WIN\_API stuff at the console, you will need  
// the “libgdi32.a”.  
\*/

HDC toPaper(int toDo)  
{  
static PRINTDLG pd;

```
switch (toDo)
	{
	case START_PRINTER:
		memset(&pd, 0, sizeof(PRINTDLG));
		pd.lStructSize = sizeof(PRINTDLG);
		pd.hwndOwner = 0; // hWnd;
		pd.Flags = PD_RETURNDC;

		if (PrintDlg(&pd)) 
			{
			DOCINFO di;

			memset(&di, 0, sizeof(DOCINFO));
			di.cbSize	= sizeof(DOCINFO);
			di.lpszDocName	= "dosDrucker";

			StartDoc(pd.hDC, &di);
			return pd.hDC;
			}
		else {error("PrintDlg(&pd) hat Fehler ret.");}
		break;
	case END_PRINTER:
		EndDoc(pd.hDC); // Dokument wird geschlossen
		DeleteDC(pd.hDC);
		
		if (pd.hDevMode != NULL) GlobalFree(pd.hDevMode);
		if (pd.hDevNames != NULL) GlobalFree(pd.hDevNames);
		return 0;
	default:
		break;
	}

return 0;
}

```

[/code]

the original can be found here:  
[http://willemer.de/informatik/windows/windruck.htm](http://willemer.de/informatik/windows/windruck.htm)  
i have only wrapped it to the func.

greetz  
Amando

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [June 4, 2006, 1:00am UTC](https://forum.juce.com/t/printing-from-juce/412/6 "2006-06-04T01:00:34Z")

</div>

mmmh :roll: boost is not in here, you better delete the post :roll:

---

<div class="post-metadata">

**Author:** ![Amando](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Amando](https://forum.juce.com/u/Amando)\
**Post date:** [June 4, 2006, 3:39pm UTC](https://forum.juce.com/t/printing-from-juce/412/7 "2006-06-04T15:39:27Z")

</div>

???  
What do you mean with “boost”? I’m not a native english speaker.  
Do you mind the API stuff, or what?  
Is that the “thanks” for people who want to do you a favor?

Amando

---

<div class="post-metadata">

**Author:** ![haydxn](https://avatars.discourse-cdn.com/v4/letter/h/5fc32e/32.png) [@haydxn](https://forum.juce.com/u/haydxn)\
**Post date:** [June 4, 2006, 4:47pm UTC](https://forum.juce.com/t/printing-from-juce/412/8 "2006-06-04T16:47:21Z")

</div>

I think he’s being funny 😉 some boost obsessives at the moment 🙂

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 5, 2006, 10:33am UTC](https://forum.juce.com/t/printing-from-juce/412/9 "2006-06-05T10:33:06Z")

</div>

Back on the topic of printing… I actually added a class LowLevelGraphicsPostScriptRenderer a few versions back, which is a graphics context that churns out postscript.

It’s not quite finished, but the idea was that you’d draw to a postscript context, then dump the output to a printer - I’ve not had chance to figure out all the platform-specific printer bits yet, but if anyone’s messing around with trying to print in juce, that’s a good place to start.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 9:53am UTC](https://forum.juce.com/t/printing-from-juce/412/10 "2017-05-12T09:53:30Z")

</div>

Closed on May 12, 2017, 9:53am UTC


