question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How make it display the entire contents of the normal?

See original GitHub issue

Hi,

When the contents of the <p> paragraphs in the html code are too long, How can I make it display the entire contents of the normal? No artificial add tags,eg: <br>. I tried to use css to limit the maximum length, and automatic word wrap, but it still can not.

test case:
# -*- coding: utf-8 -*-

import xhtml2pdf.pisa as pisa

pisa.showLogging()

def dumpErrors(pdf, showLog=True):
    if pdf.warn:
        print "*** %d WARNINGS OCCURED" % pdf.warn
    if pdf.err:
        print "*** %d ERRORS OCCURED" % pdf.err

def testlong(src="example.html", dest="example.pdf"):
    pdf = pisa.CreatePDF(file(src, "r"), file(dest, "wb"))

    dumpErrors(pdf)
    if not pdf.err:
        pisa.startViewer(dest)

if __name__=="__main__":
    testlong()

the example html code:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>test</title>
        <style>
            body{
                font-family: 'Gilles';
            }
            .testdiv {
                width:100%;
                max-width:500px;
                word-break:break-all;
            }
        </style>
    </head>
    <body>
        <div class="testdiv">
            <p>
 "sdfsdfsdfffffffffffffffffffffffffffwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwggggggggggggggggggggggggpppppppppppaaaaaaazzzzzzzzzzxxxxxxxccccccvvvvvvvbbbbnnnnnnnnmmmmmkkkkkkkkllllll"
            </p>
        </div>
    </body>
</html>

the Pdf display is like this:

"sdfsdfsdfffffffffffffffffffffffffffwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwggggggggggggggggggggggggpppppppppppaaaaaaazzzzzzzzzzxxxxxxxccccc

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

17reactions
p-mazhnikcommented, Oct 9, 2019

@vuonghv try to use property

    -pdf-word-wrap: CJK;

It helped me. I could find this only in the source code, there is no documentation for this for some reason.
Notice that word may be broken at any character, as in word-break: break-all;

2reactions
SoundWaveX81commented, Sep 1, 2022

@p-mazhnik 3 years later, thanks!!! I have wasted like 3 hours of work until I found your reply. Thanks a lot!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Display Contents of a File in Linux
The simplest way to view text files in Linux is the cat command. It displays the complete contents in the command line without...
Read more >
View display settings in Windows
View display settings in Windows · Select Start > Settings > System > Display. · If you want to change the size of...
Read more >
How display: contents; Works
The pseudo-elements of an element with display: contents are considered to be part of its children, so are displayed as normal. <style> .outer...
Read more >
display - CSS: Cascading Style Sheets - MDN Web Docs
The display CSS property sets whether an element is treated as a block or inline element and the layout used for its children, ......
Read more >
Adjust the display and text size on iPhone
On iPhone, customize the display settings to make the screen easier to ... To change the text size for all apps, tap All...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found