How can give name for generate pdf using mpdf codeigniter - codeigniter

if anybody konws this,please help me.how to give name to pdf.
i generated pdf using mpdf codeigniter. on click of a button the pdf wil be viewed. but how can give name for that pdf? it shows 1 on the top of the pdf.how can i give name to that pdf?
My controller
public function viewpdf($key,$option) {
if($option=='1')
{
$searchdata['fetchproduct']=$this->b2bproduct_model->fetch_productdata1($key);
}
if($option=='2')
{
$searchdata['fetchproduct']=$this->b2bproduct_model->fetch_productdata2($key);
}
if($option=='3')
{
$searchdata['fetchproduct']=$this->b2bproduct_model->fetch_productdata3($key);
}
$html=$this->load->view('moderator/pdf_data', $searchdata,true);
//this the the PDF filename that user will get to download
$pdfFilePath = "shany.pdf";
//load mPDF library
$this->load->library('m_pdf');
//generate the PDF from the given html
$this->m_pdf->pdf->WriteHTML($html);
//download it.
$this->m_pdf->pdf->Output($pdfFilePath, "I");
}

Use this code.
$mpdf=new mPDF();
$mpdf->SetTitle('My Title');
$mpdf->WriteHTML('<p>Hallo World</p>');
$mpdf->Output('filename.pdf');
Set the title for the document. The title is displayed at the top of the Adobe Reader screen when viewing the PDF file

Use code as bellow
public function mypdf() {
$this->load->library('pdf');
$pdf = $this->pdf->load();
$html=$this->load->view('welcome_message',null,true);
$pdf->WriteHTML($html);
// write the HTML into the PDF
$output = 'your_given_name.pdf'; //You can give a name of your generated pdf file or you can create it auto on timestamp by using $output = time().'.pdf'.
$pdf->Output("$output", 'I');
}
If you send data to view page then replace the variable with null in line 4.
For more details please see the tutorial from here.
If you are interested on DOMPDF please see from here.

Related

svg images are not inserted in pdf while generating a pdf from html using itex7 html2pdf plugin

I am generating a pdf from multiple htmls. if any of the html consists img tag which refers to svg file like <img src="assets/6.svg" /> then in generated pdf doesnt have image included. If I keep jpg or png, then its included as part of generated pdf. Its happening only if I use below code but if I use HtmlConverter.convertToPdf() then svg files are showing fine in generated pdf.
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new File(pdfFileName)));
pdfDocument.setDefaultPageSize(PageSize.A4);
Document document = new Document(pdfDocument);
document.setMargins(40, 40, 40, 40);
for (String html : htmlFileList) {
List<IElement> elements = HtmlConverter.convertToElements(new FileInputStream(html), converterProperties);
System.out.println(elements.size());
for (IElement element : elements) {
System.out.println(element.getClass().getName());
document.add((IBlockElement)element);
}
}
document.close();
I am seeing error like below when generating a pdf from html using above code.
Unable to retrieve image with given base URI
(file:/C:/Projects/pdf_conversion/download/) and
image source path
(file:/C:/Projects/pdf_conversion/download/assets/cpc/img/icons/x_dont_gray.svg)
I am using above code because page content should be flown from page to page (dont want to create one pdf for one html). Any workaround is highly appreciated on this.

Is there any way to autocomplete a textbox in html using the data read from a phpspreadsheet? How should it be done on codeigniter?

I have been trying to find a way to read data from phpspreadsheet and populate it into a textbox in html using the autocomplete plugin in jquery. I have been trying to do it in codeigniter and I am relatively new to it. Can anyone tell me the steps to go through this process? I
I believe you can do this by having the spreadsheet data loaded on one page and then redirect them to a second page and include the data from the spreadsheet.
This all pseudo-code to show the idea that I'm trying to explain.
function index() {
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
$spreadsheet = IOFactory::load($inputFileName);
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, false, true);
$_SESSION['sheetdata'] = $sheetData;
redirect('secondpage');
}
function secondpage() {
$data['sheetdata'] = $_SESSION['sheetdata'];
// use this for the autocomplete
// templaste stuff here
}

PHPOffice spreadsheet to PDF export

I have some spreadsheets in MS excell. Trying to convert them to PDF by using PHPOffice and mPDF class. I have a problem to create and display footers on every created PDF page
This is working code for creating a PDF from spreadsheet.
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($pe);
Is there any solution or method i can call after this to generate footers before use save() method?
Thanks in advance
You can use the footer methods e.g. generate a footer with linenumbers
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx");
$spreadsheet = $reader->load('<path>'); //Path of reader sheet
$sheet = $spreadsheet->getActiveSheet();
$sheet->getHeaderFooter()->setFirstFooter('&C&"-,Bold"Page &P from &N'); //generate Fristfooter
There are more header/footer possibility look documentation or class documentation

Set title of pdf using mpdf file codeigniter

$this->load->library('m_pdf');
$pdf = $this->m_pdf->load();
$pdf->SetTitle('My Doc');
$pdf->WriteHTML($html);
$pdf->Output($pdfFilePath, "F");
Used SetTitle() function of mpdf but by default it is using name of file : "Untitled Document - _Test_Company_10120.pdf"
Also set the <title></title> tag but no use.
You used $pdf->SetTitle('My Doc');
Set the title for the document. The title is displayed at the top of the Adobe Reader screen when viewing the PDF file, and is include in the document metadata, which can be seen when inspecting the document properties in Adobe Reader.
So, Try this :
$pdfFilePath = "directory/your_pdf_name.pdf";
$pdf->Output($pdfFilePath, "F");

RadComboBox is not displaying image

I have a custom RadComboBox with an image bound to it. It is not displaying the image, it's displaying the path to the image file in text.
public IDictionary<string, object> Attributes
{
get
{
//Fix for XT-2253
_attributes["DisplayStatusType"] =string.Format(null, "<div class=\"bed_priority_field\"><img src=\"../img/assignment_{0}.png\" /></div>","priority");
_attributes["Tooltip"] = Tooltip;
return _attributes;
}
}
How do I get it to display the image instead of the text?
You should use Templates in this case.
Check this online demo on how to do it:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/templates/defaultcs.aspx

Resources