TCPDF ERROR joomla virtuemart does not create the invoice - joomla

I use joomla 3.9.6, virtuemart 3.4.2, and tcpdf 1.0.7
When i try to view the invoice(pdf) or when i change order status to confirmed i get the TCPDF ERROR: Unable to create output file: \vmorders\invoices\invoice_190522TIXG01.pdf
i already have created the folders vmorders\invoices and gave it the proper permissions. (the site runs locally with wamp)
Php Error log
[22-May-2019 16:11:21 UTC] PHP Warning: fopen(): remote host file access not supported, file://\vmorders\invoices\invoice_190522TIXG01.pdf in C:\wamp64\www\byzantinemusic\libraries\vendor\tecnickcom\tcpdf\include\tcpdf_static.php on line 1854

I think i have found the solution. Edit "libraries\vendor\tecnickcom\tcpdf\include\tcpdf_static.php". At line 1850 remove code
$filename = 'file://'.$filename;
and substitute with this
$absPath = getcwd();
$filename = str_replace("\\administrator","",$absPath) .$filename;

For Virtuemart 3.6.10:
Edit "libraries\vendor\tecnickcom\tcpdf\include\tcpdf_static.php".
At line 1817 remove code:
$filename = 'file://'.$filename;
and replace with:
$filename = $filename;
$absPath = getcwd();
$filename = str_replace("\\administrator","",$absPath)."/".$filename;

Related

passing image path from storage in Laravel failed

I have stored my images in storage/app/public/images.
and i have done the storage:link.
now i want to get a path for an image that exists in /images and i want to send it with an API.
i do the below to pass it to HTTP::attach():
$path = storage_path('images' . DIRECTORY_SEPARATOR . $new_file);
and then:
$response = Http::attach('new_file', file_get_contents($path))->post('http://localhost/imageresizer/service.php', $sizes);
when i dd($path), everything seems OK and i get the path i expect.
but there's the below error when i log::debug:
file_get_contents(C:\laragon\www\myblog\storage\images\SVoGGKjERVMYxy9qDciAhgOse9kzQsIuvBg64hjE.jpg): failed to open stream: No such file or directory
what's the problem with file_get_contents ?
If your file is in storage/app/public/images, you'll want to use:
$path = storage_path('app/public/images/' . $new_file);
NB the additional 'app/public/'.

Laravel, php artisan passport:install error

I was curious about setting up an API in Laravel using Passport so I followed their documentation here:
https://laravel.com/docs/5.6/passport
Once I run
php artisan passport:install
It gives me this error:
ErrorException : openssl_pkey_new(): private key length is too short; it needs to be at least 384 bits, not 0
at /Users/fantastisk/web/blog-laravel/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php:560
556| $config = array();
557| if (isset($this->configFile)) {
558| $config['config'] = $this->configFile;
559| }
> 560| $rsa = openssl_pkey_new(array('private_key_bits' => $bits) + $config);
561| openssl_pkey_export($rsa, $privatekey, null, $config);
562| $publickey = openssl_pkey_get_details($rsa);
563| $publickey = $publickey['key'];
564|
Exception trace:
1 openssl_pkey_new(["4096", "/Users/fantastisk/web/blog-laravel/vendor/phpseclib/phpseclib/phpseclib/Crypt/../openssl.cnf"])
/Users/fantastisk/web/blog-laravel/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php:560
2 phpseclib\Crypt\RSA::createKey("4096")
/Users/fantastisk/web/blog-laravel/vendor/laravel/passport/src/Console/KeysCommand.php:35
This is what i have in the openssl.cnf file
# minimalist openssl.cnf file for use with phpseclib
HOME = .
RANDFILE = $ENV::HOME/.rnd
distinguished_name = req_distinguished_name
[ v3_ca ]
I'm running on a mac with php 7.1 (i tried building it from source with openssl too), SSL Version => LibreSSL/2.0.20.
I tried following the documentation using homestead too, which gives me the exact same error.
To me it seems like there's a problem with the phpseclib library, but I haven't been able to find anything on google regarding this error.
As a final note, I tried running this command to check if openssl_pkey_new works:
openssl_pkey_new(array("digest_alg" => "sha512","private_key_bits" => 4096,"private_key_type" => OPENSSL_KEYTYPE_RSA,));
That worked with no error.
Any help or point in the right direction will be very much appreciated.
Try passing the length option as you run the install command:
php artisan passport:install --length=256
If that doesn't work then try forcing the key generation:
php artisan passport:key --force
You may need to run composer update prior.

Laravel adds mysql in file path

I am facing a weird issue with Laravel 5.5. I am working on my local xampp server and trying to execute LOAD DATA INFILE query in controller function. But I am getting error PDOException (HY000)
SQLSTATE[HY000]: General error: 29 File 'D:\xampp\mysql\data\uploads\RDMST.csv' not found (Errcode: 2 "No such file or directory")
Currently my csv file is located at public/uploads folder. I tried various path settings for filename like
$fileCsv = 'uploads/RDMST.csv';
$fileCsv = public_path().'/uploads/RDMST.csv';
But I am getting same error and please notice the error path shows mysql\data in path. I am not getting from where it is appending this two folders in path. When I echo public path , it displays this:
D:\xampp\htdocs\tax\public
So, can you please help how to use path for load file without appending this "mysql\data" in path?
Any help is greatly appreciated.
Here is my complete controller function:
public function getCsv()
{
//echo public_path(); die;
//$fileCsv = public_path().'/uploads/RDMST.csv';
$fileCsv = 'uploads/RDMST.csv';
echo $query = "LOAD DATA INFILE '".$fileCsv."'
REPLACE
INTO TABLE tblreception
(year,
reception_number,
file_date,
file_time,
instrument_type,
#created_at,
#updated_at)
SET created_at=NOW(),updated_at=null";
DB::connection()->getPdo()->exec($query);
//return view('reception');
}
Can we not use csv file path?
Thanks

tcpdf with laravel 5

i want to save the output pdf file to public folder my method is
public function qrSVG()
{
$qrCodes = ['4659284fff','465928447','465928447','613271980','484016586','aaaaabbbbbccccc'];
$id = ['201596400-1','201596400-2','201596400-3','831070646','493130428','aaaaabbbb'];
PDF::SetTitle('qrcodes\test');
$i=0;
foreach(array_chunk($qrCodes, 2) as $qrCodee)
{
PDF::AddPage();
$m = 55;
$n = 30;
foreach($qrCodee as $qr)
{
QrCode::size(400);
QrCode::margin(3);
QrCode::errorCorrection('H');
QrCode::encoding('UTF-8');
QrCode::backgroundColor(255,255,255);
QrCode::color(0,0,0);
QrCode::imageTitle($id[$i]);
$svg = QrCode::generate($qr);
PDF::ImageSVG('#'.$svg, $x=$m, $y=$n, $w='100', $h='100', $link='', $align='', $palign='', $border=1, $fitonpage=false);
$i++;
$n = 150;
}
}
ob_clean();
PDF::Output('qrcodes\test.pdf');}
this code generate and open the file put don't save it when i replace the last line in my code with PDF::Output('qrcodes\test.pdf', 'F');
when i put any option with PDF::Output there is an error with F and D options the error when use F is
ErrorException in tcpdf_static.php line 2440:
fopen(): remote host file access not supported, file://qrcodes\test.pdf
and when i replace the last line with
PDF::Output($_SERVER['DOCUMENT_ROOT'] . 'qrcodes\test.pdf', 'F');
the error is
ErrorException in tcpdf.php line 2793:
Undefined property: Elibyy\TCPDF\Pdf::$h
The main reason you're getting the error about remote host file access not supported is because you need to provide the full path in the file name that you provide to the Output() method. Yeah, it's a bit annoying and it catches me out all the time!
I can't comment on the second error you're getting because I cannot get your code to run (missing methods in QrCode class). What version are you using? Also, why are you trying to create an SVG for the QR code and then adding that to the PDF? Instead of taking that approach, I would highly recommend following the approach illustrated in this example:
https://github.com/tecnickcom/TCPDF/blob/master/examples/example_050.php
As you will see in the example, you should create an instance of the TCPDF class and then work with that instance, rather than calling the static methods.

Laravel / Snappy: can not generate PDF or create folder

This is my code:
$offer = Offer::find($id);
$url = URL::to('/offers/view/' . $id . '/pdf');
PDF::loadFile($url)
->callSettings()
->save('/tisa/src/public/pdf/offer/Tisa-ponudba_'. $offer->code .'.pdf');
I am getting following error:
RuntimeException in AbstractGenerator.php line 517:
The output file's directory '/tisa/src/public/pdf/offer' could not be created.
Any ideas what could be wrong? I can not determine if a file can not be created or is the folder path?

Resources