Skip to content

TCPDF - Stroke thickness will not applied #1164

Closed
@Collie-IT

Description

@Collie-IT

This is:

What is the expected behavior?

If I use a borderstyle like
\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR
In the PDF the line should be the size of the borderstyle in case aboth small.

What is the current behavior?

The lines get the same thickness because in protected function getCSSBorderStyle($cssborder) of
<path>/vendor/tecnickcom/tcpdf/tcpdf.php the Parameter count will be interpreted like

	$bprop = preg_split('/[\s]+/', trim($cssborder));
		$border = array(); // value to be returned
		switch (count($bprop)) {
			case 3: {
				$width = $bprop[0];
				$style = $bprop[1];
				$color = $bprop[2];
				break;
			}
			case 2: {
				$width = 'medium';
				$style = $bprop[0];
				$color = $bprop[1];
				break;
			}
			case 1: {
				$width = 'medium';
				$style = $bprop[0];
				$color = 'black';
				break;
			}
			default: {
				$width = 'medium';
				$style = 'solid';
				$color = 'black';
				break;
			}
		}

PHP spreedsheet sends 4 parameters ("X X X !important") and all goes to the default: case.

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

// add code that show the issue here...
$sheet = $spreadsheet->getActiveSheet();
$sheet->getStyle("A1")->getBorders()->getTop()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR);
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Tcpdf');
$writer->save($tpath);

Which versions of PhpSpreadsheet and PHP are affected?

Tested with 1.8.2, 19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions