BluDart API way bill response is in blob, so save it as PDF file inh a folder instead of storing in a database.
I already stored in the database so I’ll show you how to save as PDF.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | public function waybill_pdf_convert(){ $this->db->select('rmanumber, AWBPrintContent'); $this->db->from('bluedart_response'); $query = $this->db->get(); $rows = $query->result(); if (!empty($rows)) { foreach ($rows as $row) { $rmanumber = $row->rmanumber; // Name of the file $blobData = $row->AWBPrintContent; // PDF binary data $fileName = FCPATH . 'bluedart-waybill/' . $rmanumber . '.pdf'; // File path // Write raw binary data directly to the file if (file_put_contents($fileName, $blobData)) { echo "PDF file saved successfully: $fileName<br>"; } else { echo "Failed to save the PDF file: $fileName<br>"; } } } else { echo "No records found in the database."; } } |