private function writePdfAttachement($api, $attachement)
{
try {
$pageCount = $api->SetSourceFile($attachement);
} catch (\MpdfException $e) {
$pageCount = 0;
}
for ($i = 1; $i <= $pageCount; $i++) {
$api->AddPage();
$templateId = $api->ImportPage($i);
$api->UseTemplate($templateId);
}
}