Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined array key "" #1031

Open
nemanja-ivanis opened this issue Feb 3, 2024 · 2 comments
Open

Undefined array key "" #1031

nemanja-ivanis opened this issue Feb 3, 2024 · 2 comments

Comments

@nemanja-ivanis
Copy link

When i try to output my pdf i get "Undefined array key ''" on line 4752 in dompdf\dompdf\lib\Cpdf.php. That particular line of code is:

$font = $this->fonts[$this->currentFont];

Both $this->fonts and $this->currentFont are empty. Why is this happening and how can i fix it? Why are those arrays and variables empty? It seems like a problem with the package.

I am using laravel 10.10 and barryvdh/laravel-dompdf 2.0.1.

@parallels999
Copy link

**This is just a Dompdf wrapper!**
I understand that this package is just a Laravel wrapper for https://github.com/dompdf/dompdf
Any issues with PDF rendering, CSS that is not applied correctly, aligning/fonts/characters etc that are not directly related to this package, should be reported there. When having doubts, please try to reproduce the issue with just dompdf. If it's also present there, do not open an issue here please.

This is just a Dompdf wrapper!
I understand that this package is just a Laravel wrapper for https://github.com/dompdf/dompdf
Any issues with PDF rendering, CSS that is not applied correctly, aligning/fonts/characters/images/html etc that are not directly related to this package, should be reported there. When having doubts, please try to reproduce the issue with just dompdf. If it's also present there, do not open an issue here please.

@worktchaloemphon
Copy link

I got this error too.

and here is my code.

`
$domPdf = $pdf->getDomPDF();
$canvas = $domPdf->get_canvas();
$font = $domPdf->getFontMetrics()->get_font("thsarabun", "normal"); // get null because there are not cached in storage/fonts

// comment here to cache fonts file
$canvas->page_text(
$x = $canvas->get_width() - 80,
$y = $canvas->get_height() - 40,
$text = "Page Number {PAGE_NUM} of {PAGE_COUNT}",
$font = $font,
$size = 15,
$color = array(0, 0, 0)
);

return $pdf->stream('example.pdf');

`

I have already put my fonts file .ttf to storage/fonts but Laravel doesn't cache it into .ufm file.
so I comment line $canvas->page_text() and run only return $pdf-stream(). It start to generate cache fonts file inside storage/fonts

So I uncomment $canvas->page_text() and It work. It ref pic is my final files inside storage/fonts

Screenshot 2567-05-13 at 23 21 44

( sorry for my English.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants