I need to convert a XML to PDF in my Laravel Project (5.5).
In PostgreSQL, I have a field called XML_document (text).
How can I convert the content of that field into a PDF file?
I used DomPDF, I read the text field from database and make the XML show in the PDF file but in shows as plain text. Here's my controller:
<?php
namespace WebServiceApp\Http\Controllers;
use Illuminate\Http\Request;
use WebServiceApp\Customer;
use PDF;
class CustomerController extends Controller
{
public function export_pdf()
{
// Fetch all customers from database
$data = Customer::get();
// Send data to the view using loadView function of PDF facade
$pdf = PDF::loadView('test', compact('data'));
$pdf->save(storage_path().'_filename.pdf');
return $pdf->stream('customers.pdf');
//return $pdf->download('customers.pdf');
}
}
And here's my view:
@foreach($data as $customer)
{{ $customer->xml_documento }}
@endforeach
I need to make that XML to a legible PDF document because it's a bill. :(