pontedilana / php-weasyprint Goto Github PK
View Code? Open in Web Editor NEWPHP library allowing PDF generation or snapshot from an URL or an HTML page. Wrapper for Kozea/WeasyPrint
License: MIT License
PHP library allowing PDF generation or snapshot from an URL or an HTML page. Wrapper for Kozea/WeasyPrint
License: MIT License
Good day
I have a Codeigniter PHP web app that implements php-weasyprint. I sometimes (5% of the time) get the following error when a user generates a document:
The process "/usr/local/bin/weasyprint '/tmp/php_weasyprint6489782e31d4e8.37601559.html' '.../d9cb68c13f6489782e30fcf.pdf'" exceeded the timeout of 10 seconds.
I cannot seem to see why this happens. It is also interesting, because when the error appears, it is almost immediately after the quotation generation has been initiated, not 10 seconds later.
Is there any reason why this could be happening? I am not sure what code to share, but at least this is my document generator function:
`
class Document_Generator
{
function create_pdf(
$html,
$complete_relative_path
) {
$pdf = new Pdf('/usr/local/bin/weasyprint');
if (file_exists($complete_relative_path)) {
unlink($complete_relative_path);
}
return $pdf->generateFromHtml($html, $complete_relative_path);
}
}
`
Hello
Initially I was thinking this might be a WeasyPrint issue, but the command line version is working correctly.
Here are a couple of real URLs as examples you can play with.
First a real image that will work:
https://sobs.com.au/docs/pix/simple-example.png
Second, a secure image retrieval that doesn't produce any image (but it does work when using WeasyPrint from the command line):
https://sobs.com.au/ui/fap.php?fap=WyJub3RpY2VBdHRhY2htZW50Iiw3NjI5MjksIi4uXC91cGxvYWRzXC8xNVwvbm90aWNlc1wvMjAyM1wvMDVcLzc2MjkyOV8xNjg0MTQwOTE5XzEuanBnIl0
Cheers
Murray
Hello
I'm trying to implement some php unit testing around my PDF generation.
I can easily check the creation of the PDF document, but if I want to ensure it contains the text I'm looking for, formatted in a similar manner, I'm having trouble.
I found this article (https://stackoverflow.com/questions/32489513/software-testing-a-pdf-is-created-correctly) which suggested generating the PDF and comparing it to a previously generated PDF, which I tried, but it didn't work. Even though both contained exactly the same content the strings were never the same.
Do you have any suggestions how I might be able to ensure my PDF contains the correct content?
The exit status code '2' says something went wrong:
stderr: "usage: weasyprint [-h] [--version] [-i] [-e ENCODING] [-s STYLESHEET]
[-m MEDIA_TYPE] [-u BASE_URL] [-a ATTACHMENT] [-p]
[-O {images,fonts,all,none}] [-v] [-d] [-q]
input output
weasyprint: error: unrecognized arguments: --format C:\Users\AEM\AppData\Local\Temp\php_weasyprint61cbe3514c1101.17556704.pdf
"
stdout: ""
command: C:\Users\AEM\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\weasyprint.exe --format pdf "http://www.github.com" "C:\Users\AEM\AppData\Local\Temp\php_weasyprint61cbe3514c1101.17556704.pdf".
if i run in command line , i get same error
when i run this command is ok
weasyprint https://example.com weasyprint-website.pdf
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.