Skip to content

Commit e16a534

Browse files
committed
Sample app update to test blob on external window
1 parent 0f1954c commit e16a534

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

SampleApp/src/app/features/features.component.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,9 @@ <h3>On-Demand Actions</h3>
723723

724724
<mat-divider></mat-divider>
725725

726-
<h3>PDF Source Type Testing (Issue #283)</h3>
726+
<h3>PDF Source Type Testing</h3>
727727
<p class="section-description">
728728
Test loading PDFs from different source types: string URL, Blob, or Uint8Array.
729-
This verifies that Issue #283 (Blob loading TypeError) is fixed.
730729
</p>
731730
<div class="action-buttons">
732731
<button
@@ -753,6 +752,13 @@ <h3>PDF Source Type Testing (Issue #283)</h3>
753752
>
754753
<mat-icon>data_array</mat-icon> Load from Uint8Array
755754
</button>
755+
<button
756+
mat-raised-button
757+
color="warn"
758+
(click)="loadBlobPdfInExternalWindow()"
759+
>
760+
<mat-icon>open_in_new</mat-icon> Load Blob in External Window
761+
</button>
756762
</div>
757763
<div class="info-box">
758764
<mat-icon>info</mat-icon>
@@ -1444,3 +1450,12 @@ <h2 class="interactive-title">Document Loading Error</h2>
14441450
</div>
14451451
</ng-template>
14461452
</div>
1453+
1454+
<div class="external-viewer-host">
1455+
<ng2-pdfjs-viewer
1456+
#externalBlobViewer
1457+
[externalWindow]="true"
1458+
[urlValidation]="true"
1459+
[diagnosticLogs]="diagnosticLogs"
1460+
></ng2-pdfjs-viewer>
1461+
</div>

SampleApp/src/app/features/features.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { VercelAnalyticsService } from "../services/vercel-analytics.service";
1313
})
1414
export class FeaturesComponent implements OnInit {
1515
@ViewChild("pdfViewer", { static: false }) public pdfViewer;
16+
@ViewChild("externalBlobViewer", { static: false }) public externalBlobViewer;
1617

1718
// Template references for different spinner styles
1819
@ViewChild("defaultSpinnerTemplate", { static: true })
@@ -551,6 +552,23 @@ export class FeaturesComponent implements OnInit {
551552
this.currentSourceType = 'string';
552553
console.log("✅ String pdfSrc set successfully");
553554
}
555+
556+
public async loadBlobPdfInExternalWindow() {
557+
try {
558+
console.log("🧪 Testing Blob pdfSrc loading in external window with urlValidation=false...");
559+
const response = await fetch('/assets/pdfjs/web/compressed.tracemonkey-pldi-09.pdf');
560+
const blob = await response.blob();
561+
562+
// Set blob for the separate external viewer and refresh
563+
this.externalBlobViewer.pdfSrc = blob;
564+
this.externalBlobViewer.refresh();
565+
566+
console.log("✅ Blob pdfSrc set successfully for external window:", blob);
567+
console.log("🔍 Check the console of the new window/tab for urlValidation diagnostic logs");
568+
} catch (error) {
569+
console.error("❌ Blob loading failed:", error);
570+
}
571+
}
554572

555573
// Convenience setter demonstrations
556574
public useTraditionalApproach = true;

0 commit comments

Comments
 (0)