Why the pdf appears without the certificate content?

Published 1 week ago by adamjhn

This code is used to get the content stored in the column "content" of the certificates table in a pdf file.

The issue is that the pdf is blank instead of have the content of the certificate.

Do you know why?



 $certificateContent = RegistrationType::with('certificate')->where('id', $request->send_to)->first();
        $pdf = app()->make('dompdf.wrapper');

        $pdf->loadHTML($certificateContent->content);
        

        return $pdf->download('invoice.pdf');

Best Answer (As Selected By adamjhn)
Cronix

Doesn't look like you're accessing the relationship, which is where 'content' is defined... There is no 'content' property/attribute on the RegistrationType... it's in the 'certificate' relationship

$pdf->loadHTML($certificateContent->certificate->content);
Cronix
Cronix
1 week ago (573,640 XP)

Why did you start a new thread? I thought this was "solved"?

adamjhn
adamjhn
1 week ago (10,530 XP)

Because the other was related to get the certificate content in a pdf but the pdf appears blank which seems another issue, since the code to load the html in the pdf dont show any error.

Cronix
Cronix
1 week ago (573,640 XP)

And a dd($certificateContent) shows what? (expand the attributes)

adamjhn
adamjhn
1 week ago (10,530 XP)

Shows:

RegistrationType {#311 ▼
...
  #attributes: array:11 [▼
    "id" => 1
    "name" => "general"
    "description" => "description"
    "price" => 0
    "conference_id" => 1
    "certificate_id" => 1
    "created_at" => "2018-07-11 15:51:21"
    "updated_at" => "2018-07-11 16:25:52"
  ]
...
  #relations: array:1 [▼
    "certificate" => Certificate {#327 ▼
      ....
      #attributes: array:4 [▼
        "id" => 1
        "content" => "<p>test</p>"
        "created_at" => "2018-07-11 16:25:43"
        "updated_at" => "2018-07-11 16:25:43"
      ]
...
    }
  ]
...
}

Cronix
Cronix
1 week ago (573,640 XP)

Doesn't look like you're accessing the relationship, which is where 'content' is defined... There is no 'content' property/attribute on the RegistrationType... it's in the 'certificate' relationship

$pdf->loadHTML($certificateContent->certificate->content);

Please sign in or create an account to participate in this conversation.