Giter VIP home page Giter VIP logo

pdf-php's People

Contributors

alexispplin avatar aronnovakinovae avatar bledoeg avatar cedric-anne avatar gudorian avatar jasverix avatar jatubio avatar jhonnycgarcia avatar lsolesen avatar lucassouzavieira avatar manuzza avatar ole1986 avatar oradwell avatar peter279k avatar rikvdh avatar shawe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdf-php's Issues

Problem when mixing fonts in a paragraph

Version: 0.12.23

Paragraphs with different fonts (i.e. containing some text in bold or italic) are rendered incorrectly.

Example 1 (<bniel must be draw as "Daniel"):
captura de pantalla de 2016-10-20 16-15-34

Example 2 (This is what happens inserting a space between and Daniel):
captura de pantalla de 2016-10-20 16-16-58

Text truncated while wrapping

Hello,
I'm facing this problem where text being truncated while wrapping.
Same issue happened in your readme.pdf in
Page 14
Page 18
Page 23
Page 29
I think all these pages are having similar problem.
Thank you.

Document properties garbled by setEncryption

Document properties don't make it through intact when using 40-bit or 128-bit encryption. For example:

$pdf->addInfo('Title', 'Document title here');
$pdf->addInfo('Subject', 'Document subject here');
$pdf->setEncryption($upwd,$opwd,array('copy','print'),2);

produces a document title of "Dª÷%["yˆPÔx-r".
comment out the setEncryption line and it is correct.

Using version 0.12.36 of the library and viewing the generated PDF with Adobe Acrobat Reader DC (2017.009.20044)

I have not attempted this with the 0.13 branch.

Bug?

(Loving the class so far. Thanks to all the contributors.)

ezTable causes max execution time when column width is to small

Example:

error_reporting(E_ALL);
date_default_timezone_set('UTC');

include_once '../src/Cezpdf.php';
$pdf = new CezPDF("a4");

if(strpos(PHP_OS, 'WIN') !== false){
    $pdf->tempPath = 'C:/temp';
}

$array = array(
    array('p'=>'First','c'=>'Second')
);


// WORKING
//$pdf->ezTable($array, ['p' => 'Col 1', 'c' => 'Col 2'], null,['showHeadings' => 1,'evenColumns' => 0, 'cols' => ['c' => ['width' => 20] ] ]);
// NOT WORKING
$pdf->ezTable($array,array('p'=>'page','c'=>''), "Some Title", ['evenColumns' => 0, 'cols' => ['c' => ['width' => 15] ] ]);

if (isset($_GET['d']) && $_GET['d']){
    echo "<pre>";
    echo $pdf->ezOutput(TRUE);
    echo "</pre>";
} else {
  $pdf->ezStream();
}

Text justification in tables is broken...

This worked in the old (original) version. I have tested .27 and .32 and it fails in both.

When "left" justification is used on text in a table the left edge is neat and it looks correct.

When "right" justification is used the right edge is neat, but it overlaps the edge of the table.

When "full" justification is used on text in a table cell then both right and left edges have jagged text.

All justification modes OUTSIDE of tables work perfectly.

The right justification issue seems to be consistent (but I almost never right justify text in a table so never noticed it before).

From what I can work out there are two factors that cause the "full" justification issue:

  1. The width of the available space for the text.
  2. Whether the text has longer words in it that mean larger gaps between words when wrapping occurs.

Change the sample "Lorem Ipsum" text (which has some long words) to a paragraph with short words (like "The quick brown fox.."), and the problem goes away. The sample code has both paragraphs present for testing.

Widen the table column so it has more space to work with, and the problem goes away. In the sample code, use a larger value of $W.

Sample code is in the zip file, which created the attached PDF.

example.pdf

generate.php.zip

ezTable inside object (openObject()) stopped working in 0.12.27

Recently upgraded to 0.12.31 and noticed a minor bug. We used an ezTable inside an object (openObject()), and that appears to no longer be working. I tracked it down to 0.12.27, but have not looked at specifically which commit caused it as I realised that we didn't really need to use an object at all.

A simple example:

$pdf = new Cezpdf('A4', 'LANDSCAPE', 'none', array());

$array = array(
	array('name' => "<b>NameA</b>", 'value' => "<b>ValueA</b>"),
	array('name' => "<b>NameB</b>", 'value' => "<b>ValueB</b>"),
);
$pdfObject = $pdf->openObject();
$pdf->rectangle(178, 550, 190, 30);
$pdf->ezSetY(580);
$pdf->ezTable($array, '', '', array(
	'showLines'			 => 0,
	'showHeadings'		 => 0,
	'innerLineThickness' => 1,
	'outerLineThickness' => 1,
	'shaded'			 => 0,
	'fontSize'			 => 10,
	'titleFontSize'		 => 10,
	'rowGap'			 => 0,
	'xPos'				 => 180,
	'xOrientation'		 => 'right',
	'cols'				 => array(
		'name'	 => array('width' => 80, 'justification' => 'right'),
		'value'	 => array('width' => 100, 'justification' => 'left')
)));
$pdf->closeObject();
$pdf->addObject($pdfObject, 'add');

if (isset($_GET['d']) && $_GET['d']) {
	echo "<pre>";
	echo $pdf->ezOutput(TRUE);
	echo "</pre>";
} else {
	$pdf->ezStream();
}

Output for 0.12.26 and 0.12.27 are attached.
0.12.26.pdf
0.12.27.pdf

ezImage and Background Not Work

Hello, I have been coming to this project for a long time and am experiencing problems when I insert images into my pdf, I have the same problem when I try to insert background into my page, I downloaded as latest versions and the error persists. Sometimes an image works on a PHP page of my pdf and at other times it does not work. I have already tested the examples that come with the project and they even cause errors and do not display some images and backgrounds.

Callbacks don't nest

This does not work (two nested callbacks):

$pdf->addText($x + 55  ,$y + 0,8,"<c:color:".$pdf->c->hex2rgb('#ffffff','ccolor')."><c:alink:https://www.mypatentideas.com/>https://www.mypatentideas.com/</c:alink></c:color>");

[BTW, c is a color class I have created during __construct of my extension $this->c = new _colors(); ]

So here is my hack:

$pdf->addText($x + 55  ,$y + 0,8,"<c:alink:https://www.mypatentideas.com/|#ffffff|0.000001><b><i>https://www.mypatentideas.com/</i></b></c:alink>");

So it appears the <b> and <i> callbacks work fine.

In order, I set the color, and line thickness, both optional as piped values.

public function extractInfo($info)
		{
		$p = $info['p'];
		if(isset($p))
			{
			$t = explode("|",$p);
					$info["p"] = trim($t[0]);
					if(isset($t[1]))
						{
						# color
						$info["extra"]["color"] = trim($t[1]); 
						
						
						if(isset($t[2]))
							{
							# color
							$info["extra"]["lineFactor"] = trim($t[2]); 
							}
						}
			}
		#print_r($info);exit;			
		return $info;
		}


public function alink($info,$internal=0){
		// a callback function to support the formation of clickable links within the document
		$info = $this->extractInfo($info); 
        $lineFactor=0.05; // the thickness of the line as a proportion of the height. also the drop of the line.			
		if(isset($info["extra"]["lineFactor"]))
			{
			$lineFactor = $info["extra"]["lineFactor"];
			}
				
        switch($info['status']){
            case 'start':
            case 'sol':		
                // the beginning of the link
                // this should contain the URl for the link as the 'p' entry, and will also contain the value of 'nCallback'
                if (!isset($this->ez['links'])){
                    $this->ez['links']=array();
                }
                $i = $info['nCallback'];
                $this->ez['links'][$i] = array('x'=>$info['x'],'y'=>$info['y'],'angle'=>$info['angle'],'descender'=>$info['descender'],'height'=>$info['height'],'url'=>$info['p']);
                if ($internal==0){
                    $this->saveState();
					if(isset($info["extra"]["color"]))
						{
						$this->setBothHexColor($info["extra"]["color"]);
						}
						else
							{
							# blue
							$this->setColor(0,0,1);
							$this->setStrokeColor(0,0,1);
							}
                    
                    $thick = $info['height']*$lineFactor;
                    $this->setLineStyle($thick);
                }
                break;
            case 'end':
            case 'eol':
                // the end of the link
                // assume that it is the most recent opening which has closed
                $i = $info['nCallback'];
                $start = $this->ez['links'][$i];
                // add underlining
                if ($internal){
                    $this->addInternalLink($start['url'],$start['x'],$start['y']+$start['descender'],$info['x'],$start['y']+$start['descender']+$start['height']);
                } else {
                    $a = deg2rad((float)$start['angle']-90.0);
                    $drop = $start['height']*$lineFactor*1.5;
                    $dropx = cos($a)*$drop;
                    $dropy = -sin($a)*$drop;
                    $this->line($start['x']-$dropx,$start['y']-$dropy,$info['x']-$dropx,$info['y']-$dropy);
                    $this->addLink($start['url'],$start['x'],$start['y']+$start['descender'],$info['x'],$start['y']+$start['descender']+$start['height']);
                    $this->restoreState();
                }
                break;
        }
    }


	public function setBothHexColor($hex)
		{
		$this->setStrokeHexColor($hex);
		$this->setHexColor($hex);
		}
	public function setStrokeHexColor($hex)
		{
		# stroke color
		$color = str_replace('#','',$hex);
			if(strlen($color)==3){$color=$color{0}.$color{0}.$color{1}.$color{1}.$color{2}.$color{2};}			
		$r = number_format(hexdec(substr($color,0,2))/255,4);
		$g = number_format(hexdec(substr($color,2,2))/255,4);
		$b	= number_format(hexdec(substr($color,4,2))/255,4);
			$this->setStrokeColor($r,$g,$b);
		}
	public function setHexColor($hex)
		{
		# fill color
		$color = str_replace('#','',$hex);
			if(strlen($color)==3){$color=$color{0}.$color{0}.$color{1}.$color{1}.$color{2}.$color{2};}		
		$r = number_format(hexdec(substr($color,0,2))/255,4);
		$g = number_format(hexdec(substr($color,2,2))/255,4);
		$b	= number_format(hexdec(substr($color,4,2))/255,4);
		$this->setColor($r,$g,$b);
		}


Illegal string offset?

#0 /data/web/common/php/libs/pdf-php/src/include/TTF.php(1064): ErrorHandler(2, 'Illegal string offset '44.0000000000'', '/data/web/common/php/libs/pdf-php/src/include/TTF.php', 1064, Array)

Full Justification On a Column Overflow Affecting Dynamic Header Space Size

image

HI, I've never submitting a issue request before, so here goes.

I'm not sure if this is happening in version 13, but it still happens for me in 009e - 12.20.

Section G overflows into the next page (calls a function to write the rest of the line on the next page if text goes pass margins) and the next page is fine, but before it goes to the next page it uses the "full" justification space sizing of the last line "limited funding and staff reductions negatively impacts the program's" (blue arrow at the bottom) on the header line (red arrow at the top) "AGS211: LAND SURVEY 11 03 07 03".

I guess some where it is not resetting it to zero after writing the line?

Thanks,
Gannon

Naming confusion

  • The library is named R&OS PDF PHP library.
  • The main class is called Cpdf.
  • It is on ole1986/pdf-php

It seems a little odd. I would probably think the library is best known as Cpdf, but I am not sure.

We could do a couple of things to remedy this? We could create an organization on github, which hosts the library. That organization could be named cpdf and then the repository could still be pdf-php.

The repository could also be renamed to cpdf-php.

For composer right now it is called randos/pdf-php. This should also be renamed to whatever, we choose to be the name of the organization.

If we choose to use namespacing we should choose a good one :)

@ole1986 What is your take on this one?

Table Contents Hidden when there are line breaks

Short description:

Code that used to work in the original PDF libraries fail in the most recent ones (tested in .27 and .32).

IF the contents of a table cell contains a line break then ALL content in the rest of the table disappears, BUT only in Adobe Acrobat on Windows.

Using the sample code and generated PDF, this is what I get if I view the document on Preview on Mac:

preview_on_mac

But here is what happens if the same document is viewed on Windows:

acrobat_on_windows

In the sample code, all line breaks in the table output are added using a parameter as follows:

$UseAsLineBreak = "\n";

If you change the parameter so line breaks are NOT used like so:

$UseAsLineBreak = " ";

Then the PDF works again, everywhere.

The example code works on the old/original PDF classes that we have used for years, but fails on the recent versions.

pdf_generate_acrobat.php.zip
acrobat.pdf

Where has getFontDecender gone?

This was in the original...

/**
* return the height in units of the current font in the given size
*/
function getFontHeight($size){
  if (!$this->numFonts){
    $this->selectFont('./fonts/Helvetica');
  }
  // for the current font, and the given size, what is the height of the font in user units
  $h = $this->fonts[$this->currentFont]['FontBBox'][3]-$this->fonts[$this->currentFont]['FontBBox'][1];
  return $size*$h/1000;
}

/**
* return the font decender, this will normally return a negative number
* if you add this number to the baseline, you get the level of the bottom of the font
* it is in the pdf user units
*/
function getFontDecender($size){
  // note that this will most likely return a negative value
  if (!$this->numFonts){
    $this->selectFont('./fonts/Helvetica');
  }
  $h = $this->fonts[$this->currentFont]['FontBBox'][1];
  return $size*$h/1000;
}

I have also added functions to deal with predicting font size, if you know the font name and have the bounding box...

First Row Calculation Bug...

There is a bug in the new release. If you create a table with showHeadings = 0 and a top border then the height of the first row border is calculated incorrectly. This is revealed when the first row is shaded as the shading "sticks out" of the top of the table. The zoomed attached screenshot shows this (I have copied part of the second row and pasted over the first to show the difference). It shows that the shading on the two rows is identical, but the height of the line is not.

first row

The top border is too low by half the height of the rowGap.

The fix is to add this line:

$y1 += ($options['rowGap'] / 2);

in two places in Cezpdf.php. The line needs to go in immediately before:

$y0=$y1;

This line only appears twice in the file so it is easy to find.

In both locations the revised code block looks like this:

            if (!$options['showHeadings']){ // existing line
                $y1 += ($options['rowGap'] / 2); // added line
                $y0=$y1; // existing line
            } // existing line

Manuzza

New Issue (first occurence in 0.12.34)

Sorry, but the latest release has created a new issue. Very simply, this works:

$PDF->ezText("<b><u>Bold and Underlined</u></b>");

and this does not:

$PDF->ezText("<u><b>Bold and Underlined</b></u>");

The second one produces the following error:

Notice: Undefined offset: 0 in pdf_0.12.34/Cezpdf.php on line 2196

The "underline" line is drawn from the bottom left of the PDF (0,0) to the end of the line. It only fails if the <u> tag is outside the bold tag.

A "<u>" tag on it's own is fine.

Please see attached sample code and generated PDF.

Murray.
pdf_generate_underline.php.zip
underline.pdf

colspan and rowspan on ezTable

Hello again,

in the meantime we brought a few of our forms to v0.12 and everything works great. There's just a little thing that bothers us. We can't bring colspan or rowspan to work.
Probably because it ain't implemented yet ;)

We found a post in a different forum where someone else asked about it in 2012. Is there something new since then?

Thanks for your awesome work on this project.

Add code via pull requests

A good way to approach development in git could be that all new code should be added via feature branches (like the current experimental and before merging into master commits should be squashed together in reasonable chunks to show what actually happened.

This way we could make code reviews before adding the commits to master to improve the code.

Autoupdate on packagist.org

The package is available to installation through ´composer´ on packagist.org. It can auto-update on each commit and on each tag. We need to make sure that it is setup correctly. See the explanation from packagist.org below:

GitHub Service Hook

Enabling the Packagist service hook ensures that your package will always be updated instantly when you push to GitHub. To do so you can go to your GitHub repository, click the "Settings" button, then "Webhooks & Services". Add a "Packagist" service, and configure it with your API token, plus your Packagist username. Check the "Active" box and submit the form. You can then hit the "Test Service" button to trigger it and check if Packagist removes the warning about the package not being auto-updated. (From: https://packagist.org/about#how-to-update-packages)

changed to new server running php 5.6 and experiencing problems

We recently migrated to a new server and pdf-php seems to be failing when creating a new pdf document. Any idea why?

    set_include_path('../include/pdf-php/src/' . PATH_SEPARATOR . get_include_path());
    include 'Cezpdf.php';

    $pdf = new Cezpdf('a4','portrait');  // this line causes the problem

Everything still works on the old server and other packages like TCPDF do work on the new server. I'd really like to avoid reformatting all my pdf templates.

Is pdf-php compatible with php 5.6? It seems like there is some internal conflict. No error other than the HTTP ERROR 500

the issue was solved by enabling mbstring, which somehow was left off the configuration.

addPDFFromFile

Hi, I contributed to the angle rotation on get hub for PNG files. It appears you have extended this to include JPG, but I don't know about GIFs?

This note is to ask about the ability to import a PDF object into a R&OS object. I can do this in Latex no problem... Similar to embedding images (PNG, GIF, JPG), I want to embed a PDF ... and probably with "clip options" - below is the syntax for latex...

\includegraphics[trim = 0 0 0 0,clip,width=6.5in]{pdfs/sample_growth.pdf}

fopen font issue

Our web server started throwing these errors when generating a pdf with php-pdf. It worked fine with no errors until yesterday. The path "fopen(/tmp/cachedTimes-Roman.php)" looks wrong to me, it isn't the path to the font file in php-pdf tree, perhaps it is a tmp/ copy of the font? The pdf still generates fine. Error still happens when I comment out the font selection statement. Unsure why this issue started or how to fix it. Also concerned that it just started seemingly on its own.

Warning: fopen(/tmp/cachedTimes-Roman.php) [function.fopen]: failed to open stream: Permission denied in /home/site/public_html/include/pdf-php/src/Cpdf.php on line 2039

Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/site/public_html/include/pdf-php/src/Cpdf.php on line 2040

Warning: fclose() expects parameter 1 to be resource, boolean given in /home/site/public_html/include/pdf-php/src/Cpdf.php on line 2041

PHP errors/ warnings when using TTF fonts.

Hi,
I'm getting notice 'String offset cast occurred'

but also something like that:

Severity: Warning
Message: Illegal string offset '44.0000000000'
Filename: include/TTF.php

I did cast all $off variables to int in TTF.php and it seem to fix the issue but I'm not sure if that's the right way.

php -v
PHP 5.4.45-0+deb7u5 (cli) (built: Aug 30 2016 20:15:34)

Merge experimental into master

What do you think the state of experimental is at the moment. Is it ready to be merged into master, so that can be the new branch to work off?

Before merging we should probably tag a maintenance release of the most current code in master.

@ole1986 What do you think?

addTextWrap() in 0.12

Where is this method?
I have update and now i have the following error
Fatal error: Call to undefined method Cezpdf::addTextWrap()

GPL vs MIT

Hi Ole,

I have been using this package since 1999-ish ... My favorite was 009 e

When Wayne released the package, he included this in the header ...

* IMPORTANT NOTE
* there is no warranty, implied or otherwise with this software.
* 
* LICENCE
* This code has been placed in the Public Domain for all to enjoy.
*
* @author		Wayne Munro <[email protected]>
* @version 	009
* @package	Cpdf

Today, as I was hacking away on the class, I noticed for the first time the "CopyLeft" GPL v3 in the header.

 * @category Documents
 * @package	 Cpdf
 * @version  $Id: Cpdf.php 274 2014-03-21 12:25:04Z ole1986 $
 * @author   Wayne Munro (inactive) <[email protected]>
 * @author   Lars Olesen <[email protected]>
 * @author   Sune Jensen <[email protected]>
 * @author   Ole Koeckemann <[email protected]>
 * @copyright 2007 - 2014 The authors
 * @license  GNU General Public License v3
 * @link http://pdf-php.sf.net

A GPL v3 is a far cry from the wish of the original developer.

https://en.wikipedia.org/wiki/GNU_General_Public_License#Open-source_criticism
https://en.wikipedia.org/wiki/GNU_General_Public_License#GPLv3_separates_community_further

I would propose either MIT or WTFPL.

https://en.wikipedia.org/wiki/MIT_License
https://en.wikipedia.org/wiki/WTFPL

I strongly believe that the MIT license aligns best with Wayne's original disclaimer.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

GPL v3 is a nonstarter for me. Please reconsider.

monte

{x:

Massive performance decrease in 0.12.35+ addText/getDirectives when ezTable column is too narrow

Had a very weird issue where PDFs that we had been creating without any problems for years would suddenly timeout after 2-3 minutes. They used to take about 10-15 seconds to generate. After a lot of investigation I eventually tracked it down to a combination of R&OS PDF 0.12.35 and a table column that is slightly to narrow.

Difficult to explain in more detail, so a reduced test file is attached along with xdebug dumps of both 0.12.34 and 0.12.35 (issue also exists in 0.12.38). Changing the width of the column from 50 to 55 (line 27 in the test.txt - rename to .php) avoids the issue.

Screenshots from Cachegrind (with width = 50):
0.12.34
0 12 34_addtext
0 12 34_getdirectives

0.12.35
0 12 35_addtext
0 12 35_getdirectives

test.txt
xdebug.zip

$test option of addText did not work as expected

Hi Team,
I'm a very old user of ezPdf, I'm trying to update from 0.9.

I use the $test option on addTextWrap() to get the real height needed to display a text. With the new lib, the text is really printed in the PDF ! What's the best new practice to get the height of a text bloc without drawing in the PDF ?

Best regards

polish characters not working

Hello,

we're a software company from Germany and we really appreciate your work on this project.
Unfortunately we can't get polish or russian characters to work. In the experimental branch 0.13 this issue seems to be fixed because everything works fine. Sadly we're not able to upgrade to 0.13 yet because many features we're using in our current version (0.9) are not implemented in 0.13 yet.

Our question is: if you could bring the character and font support from 0.13 to 0.12 so we can upgrade our software to 0.12, that would be great.

cezpdf_char_unterschiede

Follow PSR2 coding standards

I think the library should follow PSR2 coding standards. I've added tests to reflect the current coding standards based of PSR2 standards - and added automatic tests in TravisCI to see whether we adhere to them.

The coding standards are defined in phpcs.xml and right now there is a little work to do. I will happily do it. However, I think we should merge in experimental into master first, if you think it is pretty much ready.

Font setup is not well explained.

First of all, I am amazed by the work you all did. I am trying to understand how to set the font ( custom TTF font, Roboto from google).
It seems the font was loaded, yet no visual queue, nor a filesize change is visible. I must be doing something wrong.

$this->isUnicode = true;
$this->setFontFamily("Roboto-Regular", array(
	"b"=>"Roboto-Bold",
	"i"=>"Roboto-Italic",
	"bi"=>"Roboto-BoldItalic",
	"ib"=>"Roboto-BoldItalic",
	"bb"=>"Roboto-Black"
));
$this->selectFont("Roboto-Regular");

Please, can you show me an example of how to use the custom TTF fonts?

Get the experimental branch worked into the git repository

I am working on getting R&OS PDF class to github. Progress can be seen here: https://github.com/lsolesen/pdf-php-svn --> Right now that is the old svn repository with tags and branches.

Problem right now, is that there is no common commits. Would you do the honors of branching and adding the experimental on top of the current master of the above github-repository? Then the development could be pretty much streamlined. Then you will get commit credit for the changes?

I can also try to merge it in, but then it will be as one single commit on the branch, so there will be no history on the experimental branch. @ole1986 What is your preference?

When we are satisfied with the progress in the above repository, I will move everything to this repository.

Spot colour

Is it possible to set the line colour to a spot colour and define a specific name for it? This will be handy for me to automatically generate a cutting line for my print driver for the artwork to automate the printing process from my website. And a rectangle with rounded corners, is that possible?

Implementation of Table Column Colours: Bug and Fix

Hi,

As of the previous update the table column coloring is not working properly. The issue is that the array path used to detect the column bgcolor is wrong.

In Cezpdf.inc change these lines:

// color of the column is second choice
elseif(isset($options["cols"]) && isset($options["cols"][$colName]) && isset($options["cols"][$colName]["bgcolor"]) && is_array($options["cols"][$colName]["bgcolor"]))
  $rowColShading[] = array("x"=> $rowX, "y"=>$rowY, "width"=>$rowW, "color"=>$options["cols"][$colName]["bgcolor"]);

to

// color of the column is second choice
elseif(isset($options["bgcolor"]) && isset($options["bgcolor"][$colName]) && is_array($options["bgcolor"][$colName]) && (sizeof($options["bgcolor"][$colName]) == 3))
  $rowColShading[] = array("x"=> $rowX, "y"=>$rowY, "width"=>$rowW, "color"=>$options["bgcolor"][$colName]);

This addresses the issue.

Improve examples in version 0.12

Can you please get over the examples folder of the current release

  • pdftomail.php (should be removed)
  • image.php (should be improced - at least a different color)
  • imageInTable.php (should be moved to tables.php)
  • imageObjectHash.php (must be more clear on what is happening here - technically its working)
  • tables.php (good so far, but add the inline image examples from imageInTable.php here)
  • test.php (move it to fonts.php and need more investigation on encodings i guess)
  • unicode.php
  • unicode-file.php (move it to unicode.php)

Thank you

Protected Function

Not really a bug per se - more of a question...

Is there any reason why the following function is defined as protected?

protected function addImage(&$img, $x, $y, $w = 0, $h = 0, $quality = 75, $angle = 0)

It is not used from anywhere else in the class and being protected, it cannot be access from outside the class. Shouldn't this be defined as public in order for it to be usable?

Murray

Support for CMYK color

For many years we've used this great library to, among other uses, create barcodes that are printed on our products. These need to be in the CMYK colorspace to avoid offset printing problems (only want the barcode to show up in the black print), and therefore we added two functions, setColorCMYK() and setStrokeColorCMYK() to Cpdf.php back in version 009. Most likely the code was found elsewhere at the time, but I no longer remember.

We recently upgraded to the lastest version, and had to re-add the functions (which still worked). It would obviously be beneficial for us to get CMYK support added officially, so hoping that's something that can be considered? I'll be happy to help out.

Here are the two functions we've been using, not sure if the function names fit with the current conventions:

    /**
     * sets the CMYK colour for stroke operations
     */
    public function setColorCMYK($c,$m,$y,$k,$force=0){
        if ($c>=0 && ($force || $c!=$this->currentColour['c'] || $m!=$this->currentColour['m'] || $y!=$this->currentColour['y'] || $k!=$this->currentColour['k'])){
            $this->objects[$this->currentContents]['c'].="\n".($c/100).' '.($m/100).' '.($y/100).' '.($k/100).' k';
            $this->currentColour=array('c'=>$c,'m'=>$m,'y'=>$y,'k'=>$k);
        }
    }
    /**
     * sets the CMYK colour for stroke operations
     */
    public function setStrokeColorCMYK($c,$m,$y,$k,$force=0){
        if ($c>=0 && ($force || $c!=$this->currentStrokeColour['c'] || $m!=$this->currentStrokeColour['m'] || $y!=$this->currentStrokeColour['y'] || $k!=$this->currentStrokeColour['k'])){
            $this->objects[$this->currentContents]['c'].="\n".($c/100).' '.($m/100).' '.($y/100).' '.($k/100).' K';
            $this->currentStrokeColour=array('c'=>$c,'m'=>$m,'y'=>$y,'k'=>$k);
        }
    }

Experimental status

Hi ole1986,

I am trying to figure out how "ready" experimental is. I can certainly contribute some if it is functional.

Is it functional? What is the target PDF standard? 1.7?

  1. Does it have annotation support? How do I do this? I am looking to have notes as "popup comments" on a graph ... e.g., a small circle with a link to a note. A la bloatware: https://tcpdf.org/examples/example_036/
  2. For my case, I need to do filledPolygon as an extension of the base polygon function, similar to gd-php function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.