question

RobertoGuardamagna-6052 avatar image
0 Votes"
RobertoGuardamagna-6052 asked XuDongPeng-MSFT commented

How to hide PDF toolbar on a ASP:NET page "embed object"

Hi,

I can correctly load and display a PDF on an ASP.NET page getting the content from a database table.
When the PDF is displayed a toolbar appears (zoom, download, print etc) and I would like to hide it.
Searching on the net I found that there is the "#toolbar=0" parameter to include in the URL to load the PDF but since the content is loaded directly from a database table, I don't have a "real" URL.
The way I load the PDF is tyhe following:

  • at first I create a string with the command:

embed = "<object data=\"{0}{1}\" type=\"application/pdf\" width=\"80%\" height=\"1000px\">";
embed += "</object>";

  • the PDF is loaded through an ASHX file: ltEmbed.Text = string.Format(embed, ResolveUrl("~/FileCS.ashx?Id="), ID);

where the "ID" is a number that identifies the content to load and "ltEmbed" is a "asp:Literal".
I tried different solutions but no one worked so...is there someone who knows how to hide the PDF viewer toolbar?
Thank you, best regards.

Roberto

dotnet-aspnet-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RobertoGuardamagna-6052 ,

the PDF is loaded through an ASHX file: ltEmbed.Text = string.Format(embed, ResolveUrl("~/FileCS.ashx?Id="), ID);

What kind of data are you getting? Base64 format data? Or something else? After a simple test, ‘#toolbar=0’ can work with data in Base64 format.

0 Votes 0 ·

0 Answers