Fatal Error in convert PPT to PNG in PHP - php

I want to convert PPT to PNG with PHP. I wrote the following piece of code to solve the problem:
$powerpnt = new COM("PowerPoint.Application") or die('could not create the powerpoint instance');
$powerpnt->Visible = True;
$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"])));
$FileName = "MyPP";
$powerpnt->Presentations->Open("D:\\MySlide.ppt"); /* This is line #16 */
$powerpnt->ActivePresentation->SaveAs($strPath."/".$FileName,17);
$powerpnt->Quit;
$powerpnt = null;
But I got the following Fatal error:
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Office PowerPoint 2007<br/><b>Description:</b> PowerPoint could not open the file.' in C:\wamp\www\ppt2jpg\ppt2jpg.php:16 Stack trace: #0 C:\wamp\www\ppt2jpg\ppt2jpg.php(16): variant->Open('D:\MySlide.ppt') #1 {main} thrown in C:\wamp\www\ppt2jpg\ppt2jpg.php on line 16
How can I solve this problem?
Thanks in advance.

Related

Fatal Error:Uncaught SoapFault exception:[Client] no xml document on PHP, How to fix?

Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in D:\xampp\htdocs\soap\soap-client\client.php:76 Stack trace: #0 D:\xampp\htdocs\soap\soap-client\client.php(76): SoapClient->__call('ubah_mahasiswa', Array) #1 D:\xampp\htdocs\soap\soap-client\proses.php(10): client->ubah_mhs('14650011', 'Ratna', 'Sokaraja', '822214567') #2 {main} thrown in D:\xampp\htdocs\soap\soap-client\client.php on line 76
I got that message when trying to update the data, I've checked on line 76, but cannot find the false
public function ubah_mhs($nim_mhs,$nama_mhs,$alamat_mhs,$telepon_mhs)
{ // memanggil method/fungsi yang ada di server
$this->api->ubah_mahasiswa($nim_mhs,$nama_mhs,$alamat_mhs,$telepon_mhs);
// menghapus variabel dari memory
unset($nim_mhs, $nama_mhs, $alamat_mhs, $telepon_mhs);
}
I've checked in PHP Myadmin too but isn't an error.. What should I do?

iconv(): Detected an illegal character in input string in FPDF for Turkish characters

I got an error -> iconv(): Detected an illegal character in input string in
This is my code :
require_once 'fpdf/fpdf.php';
$pdf = new FPDF();
$pdf->AddPage();
$pdf->AddFont('arial_tr','','arial_tr.php');
$pdf->AddFont('arial_tr','B','arial_tr_bold.php');
$pdf->SetFont('arial_tr','',14);
$pdf->Cell(55,5,turkce('Fatura no'),0,0);
$pdf->Cell(58,5,turkce(': A011241'),0,0);
$pdf->Cell(25,5,turkce('Tarih'),0,0);
$pdf->Cell(52,5,turkce(': 2020-16-11 12:47 AM'),0,1);
$pdf->Cell(55,5,turkce('Toplam Tutar'),0,0);
$pdf->Cell(58,5,turkce(': 1231 ₺'),0,0);
$pdf->Cell(25,5,turkce('Müşteri Adı'),0,0);
$pdf->Cell(52,5,turkce(': Tuğrul Yıldırım'),0,1);
$pdf->Line(10,30,200,30);
$pdf->Ln(30);
$pdf->Cell(55,5,turkce('Ürün Adı'),0,0);
$pdf->Cell(58,5,turkce(': Coca Cola '),0,1);
$pdf->Cell(55,5,turkce('Vergi Oranı'),0,0);
$pdf->Cell(58,5,turkce(': %18 '),0,1);
function turkce($k)
{
return iconv('utf-8','iso-8859-9',$k);
}
$pdf->Output();
This is what I see :
Fatal error: Uncaught Exception: FPDF error: Some data has already been output, can't send PDF file in C:\xampp\htdocs\test4\islemler\fpdf\fpdf.php:271 Stack trace: #0 C:\xampp\htdocs\test4\islemler\fpdf\fpdf.php(1060): FPDF->Error('Some data has a...') #1 C:\xampp\htdocs\test4\islemler\fpdf\fpdf.php(999): FPDF->_checkoutput() #2 C:\xampp\htdocs\test4\islemler\fpdf.php(39): FPDF->Output() #3 {main} thrown in C:\xampp\htdocs\test4\islemler\fpdf\fpdf.php on line 271
Try
function turkce($k)
{
return iconv('utf-8','iso-8859-9\\TRANSLIT',$k);
}

I can't solve this Fatal error problem with pdfMerger

I'm trying to merge some pdf's, but I have a problem that I can't understand and I don't know what's happening, Can someone help me?
Attached code in PHP
This is the method for pdfMerger
public static function pdfMerger($archivos, $destino){
$pdf = new PDFMerger(); // or use $pdf = new \PDFMerger; for Laravel
if($archivos != null){
for($i=0; $i < count($archivos); $i++){
$pdf->addPDF($archivos[$i], 'all');
}
}
$pdf->merge('file', $destino);
}
And here is where I'm calling the method:
//This is a test
$control = new FilesController();
$dir = "/Jomar/induccion/documents/";
$files = glob($_SERVER['DOCUMENT_ROOT']."{$dir}politicas empresa/*.pdf");
$url = $_SERVER['DOCUMENT_ROOT']."{$dir}politicas empresa/prueba.pdf";
print_r($files);
$control->pdfMerger($files, $url);
This is the error I'm currently receiving:
Fatal error: Uncaught Exception: TCPDF_PARSER ERROR: decodeFilterFlateDecode: invalid code in C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\include\tcpdf_filters.php:474 Stack trace: #0 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\include\tcpdf_filters.php(359): TCPDF_FILTERS::Error('decodeFilterFla...') #1 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\include\tcpdf_filters.php(94): TCPDF_FILTERS::decodeFilterFlateDecode('\xEA\x91\xB9mj/\xAB\x8E;iN\xA3\x143\xAF...') #2 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\tcpdi_parser.php(1310): TCPDF_FILTERS::decodeFilter('FlateDecode', '\xEA\x91\xB9mj/\xAB\x8E;iN\xA3\x143\xAF...') #3 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\tcpdi_parser.php(1249): tcpdi_parser->_rebuildContentStream(Array) #4 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\tcpdi.php(192): tcpdi_parser->getContent() #5 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\PDFMerger.php(104): TCPDI->importPage(1) in C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\include\tcpdf_filters.php on line 474
(Sorry for my english)
The problem was of the permissions of the pdf, therefore, is necessary to check that in the pdf document doesn't have any type of restrictions. thanks for your help.

FPDF isn't working (font error)

I wanted to try out FPDF, with XAMPP it works perfectly, but as I upload it to my webserver, it says an error:
Warning: include(/font/helveticab.php): failed to open stream: No such file or directory in /customers/9/f/c/dynamistic.de/httpd.www/websites/testauftrag/fpdf.php on line 1147 Warning: include(): Failed opening '/font/helveticab.php' for inclusion (include_path='.:/usr/share/php') in /customers/9/f/c/dynamistic.de/httpd.www/websites/testauftrag/fpdf.php on line 1147 Fatal error: Uncaught Exception: FPDF error: Could not include font definition file in /customers/9/f/c/dynamistic.de/httpd.www/websites/testauftrag/fpdf.php:275 Stack trace: #0 /customers/9/f/c/dynamistic.de/httpd.www/websites/testauftrag/fpdf.php(1149): FPDF->Error('Could not inclu...') #1 /customers/9/f/c/dynamistic.de/httpd.www/websites/testauftrag/fpdf.php(463): FPDF->_loadfont('helveticab.php') #2 /customers/9/f/c/dynamistic.de/httpd.www/websites/testauftrag/fpdf.php(511): FPDF->AddFont('helvetica', 'B') #3 /customers/9/f/c/dynamistic.de/httpd.www/websites/testauftrag/rechnung.php(14): FPDF->SetFont('helvetica', 'B', 15) #4 /customers/9/f/c/dynamistic.de/httpd.www/websites/testauftrag/fpdf.php(338): PDF->Header() #5 /customers/9/f/c/dynamistic.de/httpd.www/websites/testauftrag/rechnung.php(65): FPDF->AddPage() #6 {main} thrown in /customers/9/f/c/dynamistic.de/httpd.www/websites/testauftrag/fpdf.php on line 275
This is the fpdf.php part which causes the error:
protected function _loadfont($font)
{
// Load a font definition file from the font directory
if(strpos($font,'/')!==false || strpos($font,"\\")!==false)
$this->Error('Incorrect font definition file name: '.$font);
include($this->fontpath.$font);
if(!isset($name))
$this->Error('Could not include font definition file');
if(isset($enc))
$enc = strtolower($enc);
if(!isset($subsetted))
$subsetted = false;
return get_defined_vars();
}

Open MyComputer using PHP COM class

i'm trying to open MyComputer using COM class ... whould you help me with the name of MyComputer in COM class ??
For example , if you wanna open NotePad you do this :
<?php
$shell = new COM("WScript.Shell");
$shell->Run("notepad.exe");
$shell = null; ?>
Run("notepad.exe"); works for notepad , but when i use Run("mycomputer.exe"); i face error :
Fatal error: Uncaught exception 'com_exception' with message 'Source: UnknownDescription: Unknown' in E:\Localhost\root\test.php:3 Stack trace: #0 E:\Localhost\root\test.php(3): com->Run('computer.exe') #1 {main} thrown in E:\Localhost\root\test.php on line 3
i appreciate any help from you my dear friends <3
you can try :
<?php
$shell = new COM("WScript.Shell");
$shell->Run("explorer.exe ,");
$shell = null; ?>
when we add "," it open My computer.

Categories