Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>10.0.14</Version>
<Version>10.0.15</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
{
_url = Url;
_lastStreamHash = string.Empty;
_lastStreamLength = 0;
await InvokeVoidAsync("setUrl", Id, _url);
}
if (_currentPage != CurrentPage)
Expand Down
39 changes: 9 additions & 30 deletions src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function setUrl(id, url) {

const { options } = pdf;
options.url = url;
options.data = null;
await loadPdf(pdf);
}

Expand All @@ -47,31 +48,12 @@ export async function setData(id, data) {
return;
}

const objectUrl = createObjectURLFromByte(data);
pdf.objectUrl = objectUrl;

const { options } = pdf;
options.url = objectUrl;
options.data = null;
options.url = null;
options.data = data;;
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra semicolon at the end of this line. Remove one of the semicolons.

Suggested change
options.data = data;;
options.data = data;

Copilot uses AI. Check for mistakes.
await loadPdf(pdf);
}

const createObjectURLFromBase64 = base64Data => {
const binaryString = atob(base64Data);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}

const blob = new Blob([bytes], { type: 'application/pdf' });
return URL.createObjectURL(blob);
}

const createObjectURLFromByte = bytes => {
const blob = new Blob([bytes], { type: 'application/pdf' });
return URL.createObjectURL(blob);
}

export function setScaleValue(id, value) {
const { pdfViewer } = Data.get(id);
if (pdfViewer) {
Expand Down Expand Up @@ -139,10 +121,7 @@ const loadPdf = async pdf => {

if (bar) {
const val = loaded / total * 100;
if (val > 100) {
val = 100;
}
bar.style.setProperty('--bb-view-progress-val', `${val}%`);
bar.style.setProperty('--bb-view-progress-val', `${Math.min(val, 100)}%`);

if (progressHandler === null) {
progressHandler = setTimeout(() => {
Expand Down Expand Up @@ -185,10 +164,7 @@ const loadPdf = async pdf => {
}

const disposePdf = pdf => {
const { el, observer, loadingTask, objectUrl } = pdf;
if (objectUrl) {
URL.revokeObjectURL(objectUrl);
}
const { el, observer, loadingTask } = pdf;

if (observer) {
observer.disconnect();
Expand All @@ -203,7 +179,10 @@ const disposePdf = pdf => {
const viewContainer = el.querySelector(".bb-view-container");
if (viewContainer) {
[...viewContainer.children].forEach(i => {
if (!i.classList.contains("pdfViewer")) {
if (i.classList.contains("pdfViewer")) {
i.innerHTML = "";
}
else {
i.remove();
}
})
Expand Down
Loading