Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do i convert between centimeters and the $width used in addImage() and addCell() ? #73

Closed
badpenguin opened this issue Feb 27, 2014 · 3 comments

Comments

@badpenguin
Copy link

How do i convert between centimeters
and the $width used in addImage() and addCell() ?

@Progi1984 Progi1984 added this to the 0.7.1 milestone Feb 27, 2014
@ivanlanin
Copy link
Contributor

Image widths are defined in pixels. Use PHPWord_Shared_Font::centimeterSizeToPixels() to set your image width in centimeters.

// Image with 2 cm width
$imageStyle = array('width' => PHPWord_Shared_Font::centimeterSizeToPixels(2));
$section->addImage('MyImage.jpg', $imageStyle);

Cell widths are defined in twips. Use PHPWord_Shared_Font::centimeterSizeToTwips() to set your cell width in centimeters.

$table = $section->addTable();
$table->addRow();
$table->addCell(PHPWord_Shared_Font::centimeterSizeToTwips(1.5)); // Cell with 1.5 cm width

@ivanlanin
Copy link
Contributor

@Progi1984 I think we can close this question.

@anshad
Copy link

anshad commented Mar 22, 2019

@badpenguin @ivanlanin Any help on how to use this class in Laravel?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants