2

I am using FPDF to create a PDF on a Laravel backend that serves Angular. I have created it in the normal FPDF way and I am unsure how to send the file response back to Angular.
I read here about generall how to go about it by configuring my $http request as below:

return $http({url: '/api/print/class-list', method: "POST", data: {data: data}, headers: {'Accept':'application/pdf'}, responseType: 'arrayBuffer'})
            .then(function(response)
            {
                console.log(response.data);
                var file = new Blob([response.data], {type: 'application/pdf'});
                var fileURL = URL.createObjectURL(file);
                var content = $sce.trustAsResourceUrl(fileURL);
                return content;
            }

I have injected $sce in the service and i am outputting the content in an embed tag. The tag just shows an empty PDF. I am wondering what the problem could be. Also, on the Laravel side, once I am done creating the PDF by writing $pdf->Output("page","D"), is there a way i should write return something so that it can be returned to Angular?


Also, when i console response, it kindof returns blob or some pdf stuff, and a number of errors after that like: "Warning: Unsupported feature "unknown"

Community
  • 1
  • 1
gthuo
  • 2,376
  • 5
  • 23
  • 30
  • 1
    Well, i solved my problem through another approach. Still using FPDF to generate my PDF then i create a filename for the file and pass this filename(well, the full path) as first parameter of `Output()` function. The second parameter i put as "F" to make it save file to computer. After calling the function, i then return the filename to the controller and in my `object` (or `embed`) tag, i append this filename to a static relative path like ``. It worked for me, and i just thought it could help. – gthuo Mar 08 '15 at 10:40

0 Answers0