Skip to content
Open
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
Expand Up @@ -107,7 +107,7 @@ router.post('/print-to-pdf', (req, res) => __awaiter(void 0, void 0, void 0, fun
});
});
});
yield printWindow.loadURL(`data:text/html;charset=UTF-8,${html}`);
yield printWindow.loadURL(`data:text/html;base64;charset=UTF-8,${html}`);
}));
router.get('/theme', (req, res) => {
res.json({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ router.post('/print-to-pdf', async (req, res) => {
});
});

await printWindow.loadURL(`data:text/html;charset=UTF-8,${html}`);
await printWindow.loadURL(`data:text/html;base64;charset=UTF-8,${html}`);
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

The data URL format syntax is incorrect. According to RFC 2397, the correct format for a base64-encoded data URL should be data:text/html;charset=UTF-8;base64,${html} (with base64 as the last parameter before the comma). The current order will cause the browser to not properly decode the base64 content.

Suggested change
await printWindow.loadURL(`data:text/html;base64;charset=UTF-8,${html}`);
await printWindow.loadURL(`data:text/html;charset=UTF-8;base64,${html}`);

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't believe the parameter order matters

});

router.get('/theme', (req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion src/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function print(string $html, ?Printer $printer = null, ?array $settings =
public function printToPDF(string $html, ?array $settings = []): string
{
return $this->client->post('system/print-to-pdf', [
'html' => $html,
'html' => base64_encode($html),
'settings' => $settings,
])->json('result');
}
Expand Down
Loading