Open PDF embedded in a page, on Android browser

1 reply · opened Oct 18, 2021

CCarlosOct 18, 2021

I'm actually using the following code to embed a PDF into a page:

code1:

  alt : [test.pdf](/pdfs/test.pdf)

It works fine in desktop browsers, but on Android chrome browser, it will actually download the PDF instead of embedding it on the currently page. So, digging into the internet, I found that there is a trick to get it embedded into a page even on an Android browser, ie:

code2:

The solution looks ok.

My question is: what would be the best way to automatically use code1 if the browser is running in desktop machines, and code2 if it is on a mobile device.

Thanks!

SSemicolon WebSTAFFOct 18, 2021

Hello,

We recommend using both the Codes and then Display Utility Classes: https://getbootstrap.com/docs/5.1/utilities/display/ to display one of the Codes on Desktop and hide on Mobile and then the other one to Display on Mobile and Hide on Desktop.

To display only on Desktop:
[ch_pre]class="d-none d-md-block"[/ch_pre]

To display only on Mobile:
[ch_pre]class="d-block d-md-none"[/ch_pre]

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard