Alter PDF output via hook

Hi all.

I need some help to alter/edit the pdf output.

For example, in “pdf.lib.php”, there is a hook named “pdf_build_address” and I’d like to use it to edit the Sourcecompany name on the generated pdf. Do my code should be like:

public function pdf_build_address($parameters, &$object, &$action, $hookmanager)
	{
		global $conf, $user, $langs;
		$error = 0; // Error counter
		if ($parameters['currentcontext'] == 'sourcecompany') {
			$sourcecompany->name = "NEW NAME";
		}
	}

but this is not working. Tried also this:

	public function pdf_build_address($parameters, &$object, &$action, $hookmanager)
	{
		global $conf, $user, $langs;
		$error = 0; // Error counter
		if ($parameters['currentcontext'] == 'ordercard') {
			if ($parameters['currentcontext'] == 'sourcecompany') {
				$sourcecompany->name = "NEW NAME";
			}
		}
	}

Problem is that in pdf generation I cannot use var_dump() to see what’s going on.

What I need is to translate the company name, address, etc. when pdf is generated on foreign languages (i.e. en_US) as the default one is Cyrillic-based language.

1 Like