How do I send content to the user's printer from the Layout?

Get help using Construct 2

Post » Wed Jul 23, 2014 9:12 am

Hi there,

I'm making a colouring book game for a client, and want to be able to send the current Layout to the printer (with verification, of course) once the player has finished colouring the image. I've looked in the manual but couldn't find what I needed. Can you lend me a hand?

I want the following to happen upon pressing the print button:

1. Remove certain layers from the screen (fine with this)
2. Add the client's branded logo to a certain position on the screen (also fine)
3. Grab the contents as an image / or record the positions of objects / output to pdf (this is where I get stuck)
Then
4. Ask the player for printer verification / if on mobile device, merely save the file
Then
5. Print!


Work in progress is hosted here (will have to remove the link once my question has been answered because of NDA, but will re-post when it is live)

http://angelserver.in/html5/dinotrain/

Unfortunately I can't upload the .capx, also because of NDA and client owned IP etc etc. But I can screenshot the event sheet if needed.

Thank you!

Vicki :mrgreen:
B
7
S
1
Posts: 61
Reputation: 588

Post » Wed Jul 23, 2014 9:43 am

Maybe try the Browser objects 'execute javacript' action and set it to "window.print();" in combination with the System Action - Take Snapshot.
Last edited by zenox98 on Wed Jul 23, 2014 9:54 am, edited 1 time in total.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,555
Reputation: 60,454

Post » Wed Jul 23, 2014 9:54 am

Thank you! I'll give this a go and let you know how I get on.
B
7
S
1
Posts: 61
Reputation: 588

Post » Wed Jul 23, 2014 9:56 am

You have to take a snapshot first using the system action, then add a condition

System on canvas snapshot - Browser Execute Javascript "window.print();".

Just tried and it worked, but not perfect.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,555
Reputation: 60,454

Post » Wed Jul 23, 2014 9:59 am

Alright, cheers. Doesn't have to be perfect, just so long as it works :) thank you, trying this out now.
B
7
S
1
Posts: 61
Reputation: 588

Post » Wed Jul 23, 2014 10:04 am

The action executed correctly, but the printer printed out 2 blank pages unfortunately :(

Image

I tested this on preview though; hadn't uploaded it the live server. Could this be why?
B
7
S
1
Posts: 61
Reputation: 588

Post » Wed Jul 23, 2014 10:30 am

Just exported and re-uploaded it to the server just to confirm it wasn't an offline issue, but still received 2 blank pages.
B
7
S
1
Posts: 61
Reputation: 588

Post » Wed Jul 23, 2014 10:31 am

You forgot the

"System on canvas snapshot" condition. If you check manual. you'll see that this waits to make sure the snapshot has been taken. Then put the Browser action after it. That's what the following does:

System on canvas snapshot - Browser Execute Javascript "window.print();".
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,555
Reputation: 60,454

Post » Wed Jul 23, 2014 10:53 am

Thank you for your patience with me.

Is this what you mean? I am still receiving blank pages.

Image

Sorry if this all seems obvious, I'm still new to C2.
B
7
S
1
Posts: 61
Reputation: 588

Post » Wed Jul 23, 2014 11:26 am

zenox98 wrote:You forgot the

"System on canvas snapshot" condition. If you check manual. you'll see that this waits to make sure the snapshot has been taken. Then put the Browser action after it. That's what the following does:

System on canvas snapshot - Browser Execute Javascript "window.print();".


I could be wrong, but the window.print actually won't print the snapshot but the page itself in it's current state, unless there is a way to tell it to print the canvasSnapshit expression itself.

Also I am not a specialist at all, but I am not sure you can print the content of a canvas easily, but I could be totally wrong on that.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests