wkhtmltopdf style table of contents - php

I'm wondering how i can go about reducing the font size on the generated table of contents.
I've read and reread their documentation here: https://wkhtmltopdf.org/usage/wkhtmltopdf.txt
The bit i'm confused on is:
The generated XML document can be viewed by dumping it to a file using the
--dump-outline switch. For example:
wkhtmltopdf --dump-outline toc.xml http://qt-project.org/doc/qt-4.8/qstring.html qstring.pdf
I'm having difficulty understanding how to translate to my own project, and what do they mean by this part of the command:
http://qt-project.org/doc/qt-4.8/qstring.html qstring.pdf

If you want to change the default table of content (HTML and / or CSS styles), you can use the xsl-style-sheet parameter to specify a custom XLS stylesheet.
In your custom XLS you can add any HTML tag you need.
You can find an example of the default XLS file here. For your information, le XLS is generated from the tocstylesheet.cc file (see here).

Related

mPDF generating blank pdf when importing css

When using PHP 8.1 and mpdf 8.1.2, when generating a PDF, the body of the resulting pdf is empty. While when I just output the HTML used in writehtml, I do get the full content including the css interpreted correctly.
However, when I comment out the <style>{% include '#App/inlineStyles/pdf.css' %}</style> part, it does render the PDF correctly, however (obviously) without the required styling.
I also tried seperately including both using 2 different writeHTML calls (with different modes for css). This resulted in the css not being applied (but the content being written).
The pdf.css file doesn't contain anything weird/invalid. It's partially based on tailwind and generated from .scss files.
I tried new Mpdf(['debug'=>true]) and also tried to catch any mpdfexceptions, but there were none.
Can somebody help me out?
EDIT:
The reason for this happening is within CssManager.php that the entire css gets removed:
// Remove CSS (tags and content), if any
$regexp = '/<style.*?>(.*?)<\/style>/si'; // it can be <style> or <style type="txt/css">
$html = preg_replace($regexp, '', $html);
EDIT2:
How am I supposed to include a file? I think I know the problem; I require the tailwind css component in my .css file which I'm including. The length of my .css file is 38601 lines (1000kb). The problem is in Mpdf/CssManager.php, line 481 (the code above). The return of the preg_replace is null because the file is too long.
In the past (with PHP 7.3 & an older version of mpdf) I did manage to include the tailwind css also into the mpdf writehtml. But in this version it does not work any longer.
My main question is, what is the best way to include the tailwind component? As I'm guessing that the length is what is causing $html to be null and therefore resulting in a blank page
(I'm not sure whether it would still be required to include a file (?))

Downloaded .csv file contains Type HTML Document

i am having problem when downloading file using Php script, Problem is when csv generated it contains document type HTML.
"Which is: HTML document (5.9 KB)"
I tried everything like changes Content type etc but issue still persist.
Please suggest,
Thanks in advance.

FPDF Text with HTML tags

I'm using FPDF to create an A4 sized PDF, I can add text/images and this is working fine. I have a dynamically generated string which contains some HTML tags (BR etc) and was wondering how I can have that output onto the PDF as opposed to literally printing the tags out.
$centre = urldecode($row_CertDetails['centre_name']);
$pdf->Text(10, 110, $centre);
I've seen on some forums people mentioning WriteHTML, however my version of FPDF doesn't seem to include that.
Is it an add-on?
Yes, it is an Add-On:
Write HTML
Author: Clément Lavoillotte
License: FPDF
This is an enhancement of the WriteHTML() method from tutorial 6. Supported tags are: ...
Please see Write HTML FPDF Script #42 which I think is the latest version, but feel free to browse the FPDF scripts/Add-Ons.
I've solved it anyway.
Because I'm also using FPDI, what I did was extract the contents of the class in http://www.fpdf.org/en/script/script42.php and put it inside the FPDI.php file.

php file to pdf

I was converting a HTML file to PDF using dompdf. I managed to get the desired result but a problem arose, the HTML file needs to be converted to PHP because it will receive data from a form (from another file)!
The dompdf in this case doesn't work and it not shows the result of what was written in the form.
I think what you search is a template Engine to replace values in a HTML file.
There are some Engines like Smarty, TWIG.
You can parse your HTML file and with the HTML return you can create your PDF file.
Perhaps its a bit oversized for your case but you could build your own short engine and parse your HTML file and replace your specified Tags with the form values.
You can create your html file automaticaly in temp. After request to your php file, your file generates automaticaly a .html file (in temp), then create your pdf from this file.

How can LiveDocx in PHP be used to read .doc & .docx files and read text inside it and save to HTML?

Let's say we have a .doc & .docx files. I want to use LiveDocx in PHP to load the files, read it's content and strip the text from inside it. Then save it to an HTML string.
Can this be done?
I've searched the documentation, and it seams that LiveDocx only loads .doc & .docx template files only!
You can save using external libraries and simply grab the text from the XML within the files:
http://www.webcheatsheet.com/PHP/reading_the_clean_text_from_docx_odt.php
I think you can find what you need in this example.
I might be wrong, but I think they call them "template" files because they act like a template but are still normal .doc/.docx documents. I suggest you simply try to run that example.
I think you can use TextControl that improves phpLiveDocx TextControl link
Using this you can also import pdf doc and docx
When you do document conversion on LiveDocX, you need to do a mailmerge and then retrieve the document. Even though you aren't inserting any new content, you need to do a mailmerge that replaces a dummy placeholder with dummy content.
So, the process I'd suggest is:
1) Set your source document as local template
2) Merge a dummy field with dummy content
3) Retrieve your document as HTML
4) Use a script server side to remove the html and leave only the content (Something like, remove everything between the HEAD tags, then strip_tags on the rest)
5) You should be left with your content as a simple string - I'm not sure it'll be too meaningful, but might be useful for building something like search indices.

Categories