Problem: First line with extra indents/blanks when pdf file generated by TCPDF lib using print module
Environments: print 6.x-1.18, TCPDF 6_0_038, drupal 6.22
Use case:
I have a node with html like these below:
<div class="print-content">
<div id="node-61" class="node clear-block">
<div class="content">
<div class="item-info">
<div class="code">Code: 05416.4048.0004</div>
<div class="barcode">Barcode: </div>
<div class="description">Description: dan xiang fa</div>
<div class="supplier">Supplier: Item supplier</div>
<div class="supp-code">Supplier Code: </div>
<div class="buy-price">Buy Price: 0.00</div>
<div class="rrp-price">RRP Price: 0.00</div>
<div class="our-price">Sell Price: 2019.60</div>
<div class="active">Active</div>
</div>
</div>
</div>
</div>
After theming by function theme_print_pdf_tcpdf_content from print_pdf, the output html changed as:
<span class="print-content">
<span id="node-61" class="node clear-block">
<span class="content">
<span class="item-info">
<span class="code">Code: 05416.4048.0004</span><br />
<span class="barcode">Barcode: </span><br />
<span class="description">Description: dan xiang fa</span><br />
<span class="supplier">Supplier: Item Supplier</span><br />
<span class="supp-code">Supplier Code: </span><br />
<span class="buy-price">Buy Price: 0.00</span><br />
<span class="rrp-price">RRP Price: 0.00</span><br />
<span class="our-price">Sell Price: 2019.60</span><br />
<span class="active">Active</span>
</span><br />
</span><br />
</span><br />
</span><br />
Then the output pdf file will has extra indents: see attached figure.
I found the clue from file print_pdf.pages.inc in function theme_print_pdf_tcpdf_content from print_pdf at line 580:
$matches[1] = str_replace(array('<div', 'div>'), array('<span', 'span><br />'), $matches[1]);
Where the div tags will be replaced by span, but why span tag will cause the problem?
BTW, I had tested both the div and the span separately with TCPDF directly, the html with div has no problem, but the span has the problem.
Comment | File | Size | Author |
---|---|---|---|
#3 | tcpdf-div.png | 10.37 KB | Weijian |
#1 | tcpdf-issue.png | 9.45 KB | Weijian |
Comments
Comment #1
Weijian CreditAttribution: Weijian commentedComment #2
jcnventura CreditAttribution: jcnventura commentedHow does it look without that line, can you send a screenshot?
It used to add a lot of space around the divs, which looked frankly ugly. But that was about 4 years ago, and way too many versions of TCPDF...
Comment #3
Weijian CreditAttribution: Weijian commentedThanks jcnventura very much for your quick response. See the enclosed tcpdf-div.png.
Comment #3.0
Weijian CreditAttribution: Weijian commentedattach figure
Comment #4
jcnventura CreditAttribution: jcnventura commentedClosing the issue, as it is for the Drupal 6 version of the module.