Utility function to open new tab that is not an url

Hello, I would like to open a new tab in my browser with this string:
In this case, I can open local data in the browser in order to print nicely.
I tried utils.openUrl, but it must take a string start with http://
so this won't work with openurl. Thanks!

You could use URL parameters - but to be more specific, can you provide an example of what you are attempting to do in a screenshot and code?

Yes, I'd be interested in screenshots as well in case URL params could work! :nerd_face:

you see, if I can use utils.openUrl with this string in a new tab of the browser, I can actually open a pdf file in the browser and print it!

right now I found a work around is to upload this pdf file to amazon s3 and then open the file URL link for printing, but yes, that is really annoying!

Hey @tsuweng!

We have an internal request that we're tracking for supporting printing with our PDF component so that you can preview/print straight from Retool. I can let you know here if and when that's included :slightly_smiling_face:

It looks like this is a symptom of a larger issue with browsers not supporting data URIs being opened in the top-level frame of a new window (see this StackExchange post for some sources regarding Chrome, Firefox, and Edge). You might also see in your browser console that Retool tries navigating there but the browser returns something like this:

actually, the error i got is that utils.OpenUrl must start with http....
is there a way that openUrl can take a pdf base64 data and open a new window with it? Thanks!

query1.data.file.data is what you see in pdf1 component.

Unfortunately, it doesn't look like it's possible due to the underlying limitation that browsers impose on what you can programmatically open in a new window. You'll notice that if you copy that data URI string and run something like window.open("paste URI string here") it doesn't work. If you yourself put it in directly, then it works, but since Retool would need to do it programmatically, it doesn't.

There might be a workaround for this using a 3rd party service and/or URL parameters as Scott mentioned, but I'm having some trouble finding one.

Again, though, we'll definitely let you know here when we include more support for downloading PDFs directly from Retool! Sorry to not have a better answer for you.