PHP to print to a server side printer - php

I am trying to use PHP to print to a server side printer. I have found similar example code that mostly all use the same API’s functions in order to do this task. When I ran it on my server to test the code it was saying “PHP Fatal error: Call to undefined function printer_open()”. So I found at least three different versions of the php_printer.DLL’s for this printer function and tried them all separately . I did some more research and looking into the apache server error log found this warning
PHP Warning: PHP Startup: Unable to load dynamic library 'ext\php_printer.dll' - The specified module could not be found.\r\n in Unknown on line 0
From this found some Bing search results that said that the reason it is not loading when apache starts up is because it is depend on other libraries. If this is true I have not as yet been able to find which library DLL’s these are and where to get them. This is what I need help with first to basically know if it is not depended then why is the PHP warning being thrown or what library’s do I need.
Thanks for any help
zac
I am running a wampserver2.2
Apache 2.4.2
PHP 5.4.3
OS : windows 7 64 bit
Added to the php.ini file
extension=php_printer.dll
and no errors in the php log
also I did restarted the server each time I change the php.ini file or when I put a new DLL in the *ext* directory
I even put the path to the wamp DLL’s “...\ext\” in the environment variables for windows, as a shot in the dark .
Example code
<?php
/* get the sample text */
$lipsum = "test print";//file_get_contents('lipsum.txt');
phpinfo();
/* open a connection to the printer */
$printer = printer_open("Microsoft XPS Document Writer");
/* write the text to the print job */
printer_write($printer, $lipsum);
/* close the connection */
printer_close($printer);
?>
3/19/2015 edited
I found this site along with a slightly different error message from the php error log.
basically the below link said the error happened because the PHP_printer.dll is complied with a different visual studio c++ version and therefore need to be recompiled. it gives the steps for the most part I still am tring to get it to work
https://community.apachefriends.org/f/viewtopic.php?t=53348&p=204590
Php error:
[18-Mar-2015 22:55:56 UTC] PHP Warning: PHP Startup: printer: Unable
to initialize module Module compiled with module API=20121212 PHP
compiled with module API=20100525 These options need to match in
Unknown on line 0

In case you couldn't found a solution yet....
First of all check in phpinfo() that in the version of wmap server you are using thread safety is enabled or not. Just ctrl+F in the phpinfo() for "thread safety".
Probably thread safety is enabled in the version you are using. Then you have to download the ts(thread safe) version of the php_printer.dll which you can find here....
http://windows.php.net/downloads/pecl/snaps/printer/0.1.0-dev/
download specific file according to your system requirement (OS and others) and copy it in the extension directory of the wamp. Then just enable the extension in the php.ini file like
extension=php_printer.dll
just add this line in the ini file if already not there and there will be no ; at the beginning.
Hope it helps ...

Related

PHP Warning: PHP Startup: Unable to load dynamic library '- The specified procedure could not be found. in Unknown on line 0

I would like to change php version to 7.1 and i have an error:
PHP Warning: PHP Startup: Unable to load dynamic library
'C:\Program Files\PHP\v7.1\ext\php_sqlsrv_7_nts_x86.dll' - The specified procedure could not be found.
in Unknown on line 0
First think. This is not duplicate question because i checked many similar questions.
I'm using IIS, PHP 7.1, and SQL server (thats why i need sqlsrv drivers).
I checked php.ini file aready and i change extension-dir path to full path but nothing happens. (Logically if path is a problem why it works with other extensions? ).
It works with PHP 7.0.7 (all enabled extensions is exactly same)
Update: still won't work but i tried to paste path from error message to file explorer and file already there.
Turns out that PHP 7.0 and PHP 7.1 are not compatible and the mssql PDO drivers are for 7.0.
Github issue here
Also ensure you including the right 64/86 and ts/nts version.
As from Toby Allen's accepted answer above 7.0 and 7.1 are incompatible,
However Microsoft has released Preview versions of the drivers for 7.1.
This worked for me, hope it helps anyone searching.
Drivers can be found here under downloads
I had this issue yesterday. The key to the error is the last bit.
The specified procedure could not be found.
In my case I went through a painful amount of debugging. The first thing that I noticed was that when I ran a hello world php file, I didn't get this error. That indicated to me it wasn't actually a problem loading the file, it was a problem calling a function in the file.
I went in and repeatedly put die() statements in and moved it until it hit the error. It took awhile but I eventually discovered I was calling sqlsrv_connect with options that were (apparently) now invalid.
So I can't say the exact cause of your issue without seeing the code that actually causes the error, but I hope this at least points you in the right direction.

php_fdf.dll won't work in xampp

I have the most up to date version on Xampp (5.6.20). I have downloaded php_fdf.dll and fdftk.dll and placed them in
C:\xampp\php,
C:\xampp\ext\php,
C:\xampp\apache\bin,
C:\Windows\System32, and
C:\Windows\SysWOW64.
I have them each in all of these places because of advice from various other forum posts. In my php.ini file, I have extension=fdftk.dll, and
extension=php_fdf.dll with my extension directive as follows:
extension_dir="c:\xampp\php\ext".
I have even gone into my Paths on my computer's Environmental Variables and added
C:\xampp\php\ext as a path.
Still every time that I try to utilize a function, say $fdf = fdf_create();, I get
Fatal error: Call to undefined function fdf_create() in
C:\xampp\htdocs\processing.php on line 3
as well as this in the apache error log:
PHP Warning: PHP Startup: Invalid library (maybe not a PHP library)
'fdftk.dll' in Unknown on line 0
PHP Warning: PHP Startup: Unable to
load dynamic library 'c:\xampp\php\ext\php_fdf.dll' - The
specified module could not be found.\r\n in Unknown on line 0
I'm somewhat new to programming, so it's entirely possible that there is something simple that I'm just not aware of, but I've looked through countless forum posts, youtube videos and Xampp, PHP and Apache documentation.
Please help! All I really need is to take HTML form data in my PHP script, then put it into a PDF. It seems like loading the HTML data as FDF with the same field names would be the easiest way to do this (as I had trouble getting PDF forms to communicate properly).
You say you placed the files in C:\xampp\ext\php but extension_dir is c:\xampp\php\ext. ie. ext and php are transposed. Is that a typo or did you really put the files in a different directory than specified by extension_dir?
Also, fdftk.dll is probably not an extension. It's probably used by php_fdf.dll but is not itself an extension. I'd comment that line out.

php_printer.dll or some other way to print to network printer

What i'm trying to achieve is invoke a printer to print a file or something when it is generated. The printer is going to be on the same network.
I did some research and found php_printer.dll as a solution.
I'm currently running PHP Version 5.4.25 on my server. I tried to find the required file but the links are all not working. I found a php_printer.dll from an unofficial site and when i tried to install it i got
PHP Warning: PHP Startup: printer: Unable to initialize module\nModule compiled with module API=20060613\nPHP compiled with module API=20100525\nThese options need to match\n in Unknown on line 0
So either if someone has the file or a solution for this problem (i'm guessing the file is outdated that's why it's conflicting with some other extension).
I'm also open to other alternatives as to print directly to the printer without the user having to do something.
Found the correct file and installed it just fine.
Hope it might help someone else
LINK

connect to mysql database with php issue

I'm going to expand my local project (that used mysql database and php ) to web.
i upload all file and changed all addresses to my server.
but my app wont work and i get the error like this in server Error log:
[10-Feb-2014 04:06:38 America/New_York] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/magickwand.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/magickwand.so: cannot open shared object file: No such file or directory in Unknown on line 0
my app is load some list of goods. then it can be shown detail and edit.
there is no image.
what is this problem and how I can solve it?
You don't have ImageMagick installed at your server.
In order to use the MagickWand For PHP module's functions, you need to install ImageMagick version 6.3.5, or greater, and the MagickWand for PHP extension source code / DLL. For more detail please see here http://www.magickwand.org/

PHP log full of suhosin errors

Hello I have simple php script well it is more a html file with few php lines.
Yet it produces tons of errors in log that look like this on every line:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/suhosin.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0
I can not locate in nowhere in code where suhosin might been called...
This error is present on 2 different servers.
EDIT:
In phpinfo there is no suhosin present...
Thanks.
We will likely need more information in order to provide an accurate resolution, such as What version of PHP is installed on your system? however I will give you a general resolution.
Generally this issue is caused by PHP Upgrade, most recent PHP versions does not support suhosin as this only applied to older versions of php that needed additional security.
If you are on a shared hosting server you need to contact to your hosting provider and notify them about this issue, they are likely able to resolve it quickly.
If you are on a Dedicated server, VPS server or a localhost environment you can solve this issue by following the steps below:
Find your php.ini location [You can use phpinfo() to locate php.ini file]
Open the php.ini file and search suhosin.so
When you find suhosin comment this line extension = "suhosin.so" by adding semicolon at the beginning of the line, For example: ;extension = "suhosin.so"
Save this file
Restart Apache service httpd restart
Note: If ClouldLinux installed on your server, you need to force update CageFS by issuing the following command at the command line cagefsctl --force-update

Categories