Cannot invoke printing from POS app

Hi ALL,

We are trying to invoke printing from shopify POS extensions. We have an endpoint that is returning a PDF content and we would like to print it with the POS app, invoking system printing.

We use the following code to initiate app bridge:

const config = {
apiKey: Secrets.shopify.clientID,
host: new URLSearchParams(location.search).get("host"),
forceRedirect: true // btw, we tried with this value on false anyway, does not work
};
 
const app = createApp(config);
// const redirect = Redirect.create(app);

app.dispatch(Redirect.toRemote({
url: 'https://ourdomain.com/receipt.pdf' + location. Search,
newContext: true,
}));

app.dispatch(Print.Action.APP);

The expectation was that app will redirect to our pdf and invoke printing on it, then the print dialog will show up.
First, redirect does not happen at all, secondly, printing dialog is not invoked.

We also tried to redirect the app to an html page, instead of a pdf, then invoke printing with window.print() function but this is not invoking printing dialog, probably because the app loads the content into an iframe which blocks printing function.

How did you solved this issue. Has somebody managed to print pdf documents with app bridge and POS iOS app?

Any help is much appreciated. This issue is hunting us for some time.

1 Like

Hi Bogdan,

As far as I know, the Shopify App Bridge does not support the ability to directly print PDF documents from a URL but I’ll connect with the product team to see how this could be achieved.

Hi again Bogdan,

It may be possible to print your content, but you may need to convert the PDF to HTML first with a package like this, then you should be able to use the window.print method to actually print.

Hope this helps!

Hi Liam,

We tried this solution but it does not work. On desktop it works well, url returns an html and opens print dialog.

On POS app, window.print() is not doing anything…

Hi Liam, it used to work but stopped working within the last two weeks, please see a reproduction here: https://github.com/Shopify/shopify-app-template-remix/issues/461