How do I print the screen centralised and for any orientatio

0 favourites
  • 7 posts
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • As I know, I cannot control the printer and its configuration options, but I need to print the screen and the result needs to be centralised and fit for any orientation. Is it possible? I am using the "execute javascript" action and I am getting a snapshot for that.

    Thanks in advance.

  • I know this is not a common situation (print something in the game) but I really need some advices here. I believe that someone knows if is possible to format the layout to get a good print or not.

    Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use a text box object and the anchor behaviour. Should give what you want

  • Or do you mean like a screenshot ? If thats the case no clue sorry

  • The JavaScript command "print()" will print the page. I guess you can also print an invisible page too using an iframe:

    https://developer.mozilla.org/en-US/doc ... e/Printing

    So from what I can tell you can snapshot the canvas and create a new page with JavaScript that has the snapshot red image and print it. To center the image on the page you'd use css as I understand it.

    At least that's the right direction to start tinkering.

  • The JavaScript command "print()" will print the page. I guess you can also print an invisible page too using an iframe:

    https://developer.mozilla.org/en-US/doc ... e/Printing

    So from what I can tell you can snapshot the canvas and create a new page with JavaScript that has the snapshot red image and print it. To center the image on the page you'd use css as I understand it.

    At least that's the right direction to start tinkering.

    Thanks for the suggestions R0J0hound

    I tried to follow the Magistross suggestion in this post: how-do-i-send-content-to-the-user-s-printer-from-the-layout_t110978?start=20

    "var iframe = document.getElementById(""iframe"");
    if(!iframe) iframe = document.createElement(""iframe"");
    iframe.frameBorder=0;
    iframe.width=""0px"";
    iframe.height=""0px"";
    iframe.id=""iframe"";
    iframe.setAttribute(""src"", ""about:blank"");
    document.body.appendChild(iframe);
    var image = new Image(); image.src = """ & CanvasSnapshot & """; $(""#iframe"")[0].contentWindow.document.open(); $(""#iframe"")[0].contentWindow.document.appendChild(image); $(""#iframe"")[0].contentWindow.document.close();
    window.frames[""iframe""].focus();
    window.frames[""iframe""].print();"[/code:23vls9ju]
    
    But nothing happened. Maybe because this is an old post.
    
    I cannot understand why the image appears with a large left margin when I try to print it and why it does not fit on the page if I am using an image with 800x600 resolution.
  • This was more painful to figure out than it should have been. You can change the css of the canvas to cover the page.

    "var style = document.getElementById('c2canvas').style;
    style.position='fixed';
    style.left=0;
    style.top=0;
    style.height='1in';
    style.width='1in';
    print();"[/code:33kajbrm]
    
    So you'd just change the canvas size and scroll before running that javascript code.  You'll want to restore the css values to what they were before after that.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)