tc-lib-pdf icon indicating copy to clipboard operation
tc-lib-pdf copied to clipboard

Text without space isn't wrapped with getTextCell function

Open thomas-keck opened this issue 1 year ago • 2 comments

Describe the bug Text without spaces isn't wrapped in cell.

To Reproduce Steps to reproduce the behavior:

  1. Insert text without spaces with getTextCell
$pdf->getTextCell(
    'GENTEST-CREATE-NEW-2-BIS-CA',
    $docPosition['x'] + $label->getLeft(),
    $docPosition['y'],
    $label->getInnerWidth(),
    $skuHeight, // float $height = 0,
    0, // float $offset = 0,
    0, // float $linespace = 0,
    'T', // string $valign = 'C',
    'L', // string $halign = 'C',
    null, // ?array $cell = null,
    [], // array $styles = [],
    0, // float $strokewidth = 0,
    0, // float $wordspacing = 0,
    0, // float $leading = 0,
    0, // float $rise = 0,
    true, // bool $jlast = true,
    true, // bool $fill = true,
    false, // bool $stroke = false,
    false, // bool $clip = false,
    true, // bool $drawcell = true,
);
  1. PDF is stored in file :
$fs = new Filesystem();
$tempName = $fs->tempnam(\sys_get_temp_dir(), 'barcode_session_product_');
$fs->appendToFile($tempName, $pdf->getOutPDFString());
  1. Display PDF with Symfony's BinaryFileResponse :
$displayFile = u($session->getName())
    ->ensureStart('barcode_session_product_')->snake()->ensureEnd('.pdf')
    ->toString();

return $this->file($tempName, $displayFile, ResponseHeaderBag::DISPOSITION_INLINE);

Expected behavior Text has to be wrapped in cell to fit the width.

Environment:

  • OS: macOS 13.6.7
  • PHP version: 8.3.3
  • Symfony version: 7.0.7

Additional context I want to edit labels (24 per page model) with SKU and barcode.

SCR-20240705-kfek

thomas-keck avatar Jul 05 '24 09:07 thomas-keck

Since version 8.0.62 you can use the enableZeroWidthBreakPoints function as in the example: https://github.com/tecnickcom/tc-lib-pdf/blob/main/examples/index.php#L1299

This version also support text hyphenation (see the example).

nicolaasuni avatar Jul 31 '24 17:07 nicolaasuni

Hello @nicolaasuni

Thanks for your reply, your patch seems OK.

I revert my code to TCPDF since my issue.

When do you think this project will be stable to use it in production ?

thomas-keck avatar Aug 01 '24 13:08 thomas-keck

The current library is already usable. Some advanced features are yet to be ported. I have updated the README.md with some info...

nicolaasuni avatar Aug 13 '24 16:08 nicolaasuni