@bindu-dashing/dam-solution-v2 5.9.232 → 5.9.233

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,31 +35,52 @@ const PdfEditorCanvas = forwardRef(({ fileUrl, s3Path, currentTool, color, fontS
35
35
  useEffect(() => {
36
36
  const loadPdf = () => __awaiter(void 0, void 0, void 0, function* () {
37
37
  try {
38
- // Try fetching via API base64 first (same as image editor)
38
+ // Try direct URL fetch first (most reliable for binary data)
39
+ if (fileUrl) {
40
+ try {
41
+ const response = yield fetch(fileUrl);
42
+ if (response.ok) {
43
+ const arrayBuffer = yield response.arrayBuffer();
44
+ const bytes = new Uint8Array(arrayBuffer);
45
+ // Verify PDF header (%PDF-)
46
+ if (bytes.length > 4 &&
47
+ bytes[0] === 0x25 &&
48
+ bytes[1] === 0x50 &&
49
+ bytes[2] === 0x44 &&
50
+ bytes[3] === 0x46) {
51
+ setPdfBytes(bytes);
52
+ const doc = yield pdfjsLib.getDocument({ data: bytes.slice() })
53
+ .promise;
54
+ setPdfDoc(doc);
55
+ onPagesLoaded(doc.numPages);
56
+ return;
57
+ }
58
+ }
59
+ }
60
+ catch (fetchErr) {
61
+ console.warn("Direct URL fetch failed, trying base64 API:", fetchErr);
62
+ }
63
+ }
64
+ // Fallback: fetch via API base64 endpoint
39
65
  if (s3Path) {
40
66
  const response = yield api.get(`${GET_BASE64_USING_PATH_URL}?key=${s3Path}`);
41
- const base64 = get(response, "base64", "");
42
- if (base64) {
43
- const binaryString = atob(base64);
67
+ const base64Data = get(response, "data.base64") ||
68
+ get(response, "base64", "");
69
+ if (base64Data) {
70
+ const binaryString = atob(base64Data);
44
71
  const bytes = new Uint8Array(binaryString.length);
45
72
  for (let i = 0; i < binaryString.length; i++) {
46
73
  bytes[i] = binaryString.charCodeAt(i);
47
74
  }
48
75
  setPdfBytes(bytes);
49
- const doc = yield pdfjsLib.getDocument({ data: bytes }).promise;
76
+ const doc = yield pdfjsLib.getDocument({ data: bytes.slice() })
77
+ .promise;
50
78
  setPdfDoc(doc);
51
79
  onPagesLoaded(doc.numPages);
52
80
  return;
53
81
  }
54
82
  }
55
- // Fallback: fetch from URL
56
- const response = yield fetch(fileUrl);
57
- const arrayBuffer = yield response.arrayBuffer();
58
- const bytes = new Uint8Array(arrayBuffer);
59
- setPdfBytes(bytes);
60
- const doc = yield pdfjsLib.getDocument({ data: bytes }).promise;
61
- setPdfDoc(doc);
62
- onPagesLoaded(doc.numPages);
83
+ console.error("Could not load PDF from any source");
63
84
  }
64
85
  catch (err) {
65
86
  console.error("Error loading PDF:", err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.9.232",
3
+ "version": "5.9.233",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",