0 Favourites

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

  • 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:

    [quote:2pq395fl]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 <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

  • Maybe try the Browser objects 'execute javacript' action and set it to "window.print();" in combination with the System Action - Take Snapshot.

  • Thank you! I'll give this a go and let you know how I get on.

  • 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.

  • Alright, cheers. Doesn't have to be perfect, just so long as it works thank you, trying this out now.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • The action executed correctly, but the printer printed out 2 blank pages unfortunately

    I tested this on preview though; hadn't uploaded it the live server. Could this be why?

  • Just exported and re-uploaded it to the server just to confirm it wasn't an offline issue, but still received 2 blank pages.

  • 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();".

  • Thank you for your patience with me.

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

    Sorry if this all seems obvious, I'm still new to C2.

  • 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.

  • Hm. In that case, would I need a more bespoke solution in Javascript? Will C2 support this?

    I found this on StackOverflow, I wondered if I might be able to implement something like this:

    http://stackoverflow.com/questions/4716 ... -on-a-page

  • I just quickly tried the attached which as you say, is probably just the page and not the snapshot:/ Although if I omit the Take Snapshot action, I also get a blank page! But adding the Take Snapshot printed the Outlined text and image.

  • Hm, downloaded the file and tried it but it didn't work for me?

  • I can't explain it?! Works every time for me.

    What browser are you using? I always use Firefox (currently Firefox 31.0).

  • Ack! how frustrating!

    I am using Firefox 30.0, so... can't imagine that would be it, could you?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,130
karshinkoff's avatar
karshinkoff
Unread hot topic
0 Favourites
Send Emails with Construct !
92 13,309
Samuel Masiero's avatar
Samuel Masiero
Unread hot topic
132 29,584
chadorireborn's avatar
chadorireborn