Comments (5)
Finally found the issue: the .../vendor/dompdf/dompdf/lib/fonts/ directory has not had sufficient rights to create the .ufm font and .ufm.json file. chmod -R 777 fonts/ made it work.
unfortunately no error reported that...
from dompdf.
Which version of Dompdf are you using? Do you have a sample of the HTML + CSS you're using with that font?
As for the amount of memory, that's only 16MB. Dompdf is not optimized for operation in low-memory environments, so hopefully that is not the maximum amount of memory available to PHP.
from dompdf.
I am using Dompdf 2.0.4.
My Code looks like this:
$dompdf = new Dompdf([
'isRemoteEnabled' => true,
'isHtml5ParserEnabled' => true,
'chroot' => ABSPATH, // this is my constant for the projects absolute path (works for all images, etc)
'defaultFont' => 'Courier',
]);
$html = ' <!DOCTYPE html>
<html lang="de">
<head>
<style>
@font-face {
font-family: "segoe-ui";
font-weight: 300;
font-style: normal;
font-variant: normal;
src: url("../public/assets/fonts/segoe-ui/SegoeUI.ttf") format("truetype");
}
body {
font-family: "segoe-ui", sans-serif;
font-weight:300;
}
</style>
<title>PDF</title>
</head>
<body>
This is a string as the only content in the pdf
</body>
</html>';
$dompdf->loadHtml( $html );
$dompdf->setPaper('A4');
$dompdf->render();
$canvas = $dompdf->getCanvas();
$canvas->page_script(function ($pageNumber, $pageCount, $canvas, $fontMetrics) use ($dompdf) {
$text = 'Seite ' . $pageNumber . ' / ' . $pageCount;
$font = $fontMetrics->getFont('DejaVuSans');
$size = 9;
$canvas->text(62, 78, $text, $font, $size);
});
$filename = 'test.pdf';
$dompdf->stream( $filename, [
'compress' => true,
'Attachment' => false,
]);
I increased the Memory Limit to 128M. Using the code above i still get:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 65015808 bytes)
Setting up code above with default font "Courier" everything renders as it should.
Additional information:
I am running my Dev-Environment in WSL ( Apache, PHP, MySQL). I gave 32GB of available Memory to WSL via .wslconfig. When opening up my Task Manager and unlimiting the PHP memory_limit i can see my PCs usage increasing from (default) 20GB to up to 30GB before the script breaks.
from dompdf.
I certainly would not expect that particular sample to cause a memory limit exception. Maybe something about your copy of the font is problematic? Have you tried installing another font?
from dompdf.
Dompdf might be swallowing that error to prevent it from halting rendering. Enabling additional debug messaging would have exposed the problem.
I am surprised lack of permissions was causing a memory limit exception. I'd have to look into it to see what Dompdf is doing in that scenario.
FYI there is a request to add a post-installation task to check permissions. I'm also thinking of a way of generating info on demand to validate the installation.
from dompdf.
Related Issues (20)
- Gujarati Language Some Fonts are not displaying as Expected HOT 1
- overflow hidden with an image height bigger than the paper height puts an empty page in front off HOT 1
- Incompatible function signature for imagepolygon() and imagefilledpolygon() in GD.php HOT 3
- Hide page number in all pages HOT 3
- Unable to render shadow-root. HOT 1
- While updating Composer Dompdf\Options::validateArtifactPath() HOT 2
- Naira Symbol - Currency Not Working HOT 3
- setEncryption not working with variable HOT 7
- <pre> tags make extra space on first line HOT 3
- CSS and the page break HOT 4
- Unordered lists nested within ordered lists force the remaining ordered list items to use bullets HOT 3
- Bug on $dompdf->render() HOT 1
- EOL marker shall be immediately followed by a %
- Be Factur-x ready HOT 2
- Page break not working in long text HOT 3
- text() font in page_script() is ignored in specific situation with SVG img file HOT 3
- Implement onRenderProgress callback
- Problem while loading RTL table HOT 1
- utf-8 character not rendering HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dompdf.