Questions about PHP generating PDF files with Html2pdf

Source: Internet
Author: User
You master: Ask you a question, I use PHP html2pdf generated dynamic PDF, found a problem, such as the HTML file to enter more than a line length of characters (such as: 200 characters), then the resulting PDF, can only display one line, will not wrap, Unless I manually in the HTML file through \ n or
A newline was made to show normal. Using the instance top bottom righ left to set the margin is not used. Thank you! Is there anyone who has such a problem?

The code is as follows:
$html 2pdf = new Html2pdf (' P ', ' A4 ', ' fr ', true, ' UTF-8 ', Array (30, 20, 25, 25));
$html 2pdf->pdf->setdisplaymode (' fullpage ');

Note: The margin set for array (30, 20, 25, 25) in this code only works on HTML wrapped.


Reply to discussion (solution)

The drawings are as follows:

The problem aaaaaaa more than the PDF page, and many AAA does not show

Html2pdf is the analysis of CSS to achieve the composition of the PDF
That is, if your CSS is wrong or he does not know, it will inevitably affect the effect of the PDF page

If your aaaa .... When viewing in a mainstream browser, there will be a folding line, then the html2pdf will be folded

This is the problem of html2pdf, you can not change it, only adapt to it.
If you can control the site page, you can also adapt.
But if you want to deal with other Web pages, then you can only search for another tool.

Thank you very much for the two-bit, I would like to ask is that I use a table or div to control the width (such as width=500px; or width=50%,aaaaaaaaaaaa (very long)) if the form of a Web page can be automatically wrapped, but with the html2pdf generated PDF is not, Is html2pdf still have some function I did not study thoroughly or do not have this function at all??? Thank you

Who has used this function, this problem is very common. I am now using PHP to determine the length of the characters to wrap, but there is a problem, Chinese characters and letters, numbers accounted for different size, for example, if all Chinese characters, I font size of 14px, then 32 Chinese characters just one line, I write
, but the key is that there are many cases of Chinese characters with alphanumeric, if still follow 32 characters to line, the whole length is different.

For AAAAAAAAAAAAAAAAAAAAAAAAA (very long)
When no arrangement is specified:
If there is no "(very long)" then the line will not be folded, only the "(Very long)" Place is broken

has exceeded the page length, very long and long, under normal circumstances, the form of Web page display can be wrapped, but the PDF file generated by html2pdf will not be wrapped, can only show the length of this page, on one line

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.