Data Uri Hash Parameters (hide Pdf Toolbar For Data Uri) December 01, 2023 Post a Comment I have a PDF base64 encode data URI. eg: return Solution 1: Like kolin said there is no way to directly send in query strings with a data URI. However, you can switch the data URI into a blob URL and pass the parameters in there.Just take your base64 data and convert it into a pdf blob like so:functionb64toBlob(b64Data, contentType) { var byteCharacters = atob(b64Data) var byteArrays = [] for (let offset = 0; offset < byteCharacters.length; offset += 512) { var slice = byteCharacters.slice(offset, offset + 512), byteNumbers = newArray(slice.length) for (let i = 0; i < slice.length; i++) { byteNumbers[i] = slice.charCodeAt(i) } var byteArray = newUint8Array(byteNumbers) byteArrays.push(byteArray) } var blob = newBlob(byteArrays, { type: contentType }) return blob} CopyThen use the createObjectURL method to create a URL you can put query strings on like so:URL.createObjectURL(b64toBlob(data.buffer.data, 'application/pdf')) + '#toolbar=0&navpanes=0&scrollbar=0'CopySet your object's data attribute to the resulting string and you'll have it. Solution 2: I'm in the same position myself here, and, unfortunately looking athttps://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIsthe statement (within "common problems"):No support for query strings, etc. The data portion of a data URI is opaque, so an attempt to use a query string (page-specific parameters, with the syntax ?parameter-data) with a data URI will just include the query string in the data the URI represents.seems to indicate that this is not possible.Baca JugaHtml5 Href Download Attribute Not Working With .pdf FileCreating Pdf From Html Background Color In The PdfHtml Image Tag With Base64 String (data Uri)If you are trying to prevent the printing of the PDF, and have access to the code that generates it (such as iText) you can programatically disable the print button using code similar to (encrypting the doc)stamper.setEncryption(null,null, PdfWriter.HideWindowUI, PdfWriter.STRENGTH40BITS); stamper.setViewerPreferences(PdfWriter.HideToolbar); Copyhowever this will not prevent the document being able to be saved. (see : http://developers.itextpdf.com/question/how-disable-save-button-and-hide-menu-bar-adobe-reader)It would be nice to be able to pass through has parameters to an embed(or object) element, but ho hum.Solution 3: Yesterday I was also facing similar problem and found a working solution. When you are using base64 in URI and trying to set default behavior none(#toolbar=0&navpanes=0&scrollbar=0&), src is not able to detect the boundary starting with '#'. You can get wanted result with this instead data:application/pdf;#toolbar=0&navpanes=0&scrollbar=0&;base64,your_base64_string. As per your code you can return like this: return <objectdata="data:application/pdf;#toolbar=0&navpanes=0&scrollbar=0&;base64,JVBERi0xLjMKJf////8KOCAwIG9...VmCjI0MTU4OAolJUVPRgo=" type="application/pdf"></object> CopyI hope this may help you and others. Solution 4: you just need to put '#toolbar=0&' in data Url after 'data:application/pdf;' tag to hide toolbar from pdf viewer as written below-data:application/pdf;#toolbar=0;base64 Share You may like these postsUsing Flex/css With WkhtmltopdfHow To Embed Fonts Into A Pdf With Tcpdf?Link To A Pdf In Html, The File Has No Extension, But I Know It Is Pdf How To Make It Open AppropriatelyConvert Html ( Having Javascript ) To Pdf Using Javascript Post a Comment for "Data Uri Hash Parameters (hide Pdf Toolbar For Data Uri)"