Page 1 of 1

Printing a Browser Widget

Posted: Tue Mar 26, 2019 1:10 am
by kdjanz
Mac on Mojave, LC Community 8.2.0 and 9.0.3

I have a browser widget alone on a card which displays a simple HTML text table. I clone this card 25 times while randomizing the text in the tables - all so far so good.

When I go to print the 25 randomized cards, they all appear blank when I look at them in Preview via the printing dialog. I can see the tables on the cards, but they don't seem to print. Suggestions?

I then thought that I could use the snapshot command to grab the browser and turn it into a PNG that I would then paste into a graphic that I created over the browser rectangle. I used the tutorial on creating a thumbnail and tried to set the imagedata of my image to the imagedata from the snapshot. My images all remained empty.

Any help on either approach would be appreciated.

Thanks

Kelly

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 2:08 pm
by dunbarx
Hi.

This is an interesting question to me, because I do not use widgets.

But I made a stack with two cards, each with a browser widget that was set to the LC home page. Each card's widget worked just fine. I put a field on card 1 as well.

But when I went to print the cards, I got nothing but the field.
LC 9.0.3 Mac 10.13.4

So, anyone?

Craig Newman

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 2:28 pm
by bogs
dunbarx wrote:
Tue Mar 26, 2019 2:08 pm
So, anyone?
... else that is, I have less than no clue here :mrgreen:

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 2:38 pm
by [-hh]
Print/PrintToPDF is not supported by the browser widget.
It is on the long list of LC promises for LC 9.

But, of course, you can make a snapshot from (the rect of) the widget and print that, even very long pages:

Use "BrowserSnapshot_v015": (sorry, currently not available)

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 2:52 pm
by bogs
[-hh] wrote:
Tue Mar 26, 2019 2:38 pm
But, of course, you can make a snapshot from (the rect of) the widget and print that, even very long pages:
Oddly enough, when I tried just that, I got an error :?

However, I was able to export a snapshot of the general area of the widget (but only by shooting the stack). Go figure.
Selection_001.png
It is a (widget) shoot...

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 3:35 pm
by [-hh]
That*s why I said "(the rect of) the widget".

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 3:46 pm
by kdjanz
Could someone give me a code fragment on how you are doing the snapshot?

I tried that but the rectangle seemed to have an issue between global and window coordinates. The other issue was that the snapshot seemed to be random static - tearing of the image so that columns & rows don’t line up.

Thanks

Kelly

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 3:58 pm
by [-hh]

Code: Select all

if there is no img "temp" then create img "temp"
put globalLoc(the topleft of widget "browser"), \
   globalLoc(the botright of widget "browser") into rct
export snapshot from rect rct to img "temp" as PNG

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 4:03 pm
by kdjanz
Thanks!

The global additions should help.

Could you add a couple more lines to put the snapshot into an image “theImage” that I already have on the card to cover the browser widget. With the ‘wallpaper’ image covering the browser, I’m hoping I can then print the card.

Thanks

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 4:12 pm
by [-hh]
You cannot put an image on top of a browser widget (which is a native display).

So lock screen, show the widget, do the snapshot as above (use "theImage" instead of "temp"), hide the widget, set topleft of image "theImage" to the topleft of widget "browser".
Depending on your CPU/GPU you have to "wait 10 ticks with messages" after step 2.

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 4:26 pm
by kdjanz
i'll try that this evening when I get back to LiveCode.

Thanks for the quick help.

Kelly

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 5:12 pm
by bogs
[-hh] wrote:
Tue Mar 26, 2019 3:35 pm
That*s why I said "(the rect of) the widget".
LOL ! You mean because I didn't have the parenthesis around "the rect of", that caused it to fail? I am sooooooo glad you stopped by, I don't think I'd have ever caught that one :oops:

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 5:40 pm
by kdjanz
That belongs in the Department of Subtle! How is a newbie ever going to... <Despair>

Re: Printing a Browser Widget

Posted: Tue Mar 26, 2019 6:56 pm
by [-hh]
When writing snapshot from (the rect of) widget I meant that
   "export snapshot from widget"
is not possible, so we have to use
   "export snapshot from rect <rectangle>".

With this form <rectangle> is *always* in *global* coordinates.

So we could have a function globalRect to write

Code: Select all

export snapshot from rect globalRect(the rect of widget "browser") to img "temp" as PNG
Here is the function.

Code: Select all

function globalRect pRect
  return the globalLoc of (item 1 to 2 of pRect), \
         the globalLoc of (item 3 to 4 of pRect)
end globalRect
p.s. globalRect(the rect of this card) = the rect of this stack.

Re: Printing a Browser Widget

Posted: Wed Mar 27, 2019 12:38 pm
by bogs
kdjanz wrote:
Tue Mar 26, 2019 5:40 pm
That belongs in the Department of Subtle! How is a newbie ever going to... <Despair>
kdjanz, my assumption was wrong (happens :wink: )

While there are edge cases where something like that will trip you up, by the time you hit them, you will no longer be a newbie, so take heart :D