Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/474.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用php或javascript打印pdf文件?_Php_Javascript_Image_Pdf_Printing - Fatal编程技术网

如何用php或javascript打印pdf文件?

如何用php或javascript打印pdf文件?,php,javascript,image,pdf,printing,Php,Javascript,Image,Pdf,Printing,我想在使用php或javascript单击“打印”按钮时自动打印pdf文件 谢谢您不需要添加按钮。如果通过嵌入PDF或提供链接在新窗口中打开来加载PDF以在网页上显示,除非文档已禁用打印,否则访问者只需右键单击并使用Adobe Reader打印命令即可 您可以发送这样的消息。您不需要添加按钮。如果通过嵌入PDF或提供链接在新窗口中打开来加载PDF以在网页上显示,除非文档已禁用打印,否则访问者只需右键单击并使用Adobe Reader打印命令即可 你可以发一条这样的信息。注意! 谷歌云打印在202

我想在使用php或javascript单击“打印”按钮时自动打印pdf文件


谢谢

您不需要添加按钮。如果通过嵌入PDF或提供链接在新窗口中打开来加载PDF以在网页上显示,除非文档已禁用打印,否则访问者只需右键单击并使用Adobe Reader打印命令即可


您可以发送这样的消息。

您不需要添加按钮。如果通过嵌入PDF或提供链接在新窗口中打开来加载PDF以在网页上显示,除非文档已禁用打印,否则访问者只需右键单击并使用Adobe Reader打印命令即可

你可以发一条这样的信息。

注意! 谷歌云打印在2020年12月后被弃用。

我知道这不是解决您问题的最佳解决方案,但如果您的打印机具有本地google cloudprint支持,或者您通过google chrome浏览器将打印机添加到cloudprint,则您可以通过google打印文档

要在GoogleCloudPrint上从PHP打印文档,您需要从Github获得以下类

有关如何获取凭据的信息位于类的中

有了这个代码片段,打印工作就像一个符咒

require_once 'php/cprint/Config.php';
require_once 'php/cprint/GoogleCloudPrint.php';

$gcp = new GoogleCloudPrint();
$refreshTokenConfig['refresh_token'] = 'your_refresh_token';
$token = $gcp->getAccessTokenByRefreshToken($urlconfig['refreshtoken_url'],http_build_query($refreshTokenConfig));
$gcp->setAuthToken($token);
$printers = $gcp->getPrinters();
//print_r($printers); // Show available printers with IDs

if(count($printers) == 0){
    exit("Could not get printers");
}else{
    $printerID = "your_printer_id";
    $resarray = $gcp->sendPrintToPrinter($printerID, "Document title", "path/to/document.pdf", "application/pdf");
    if($resarray['status'] == true){
        echo "Document has been sent to printer and should print shortly.";
    }else{
        echo "An error occured while printing the doc. Error code:".$resarray['errorcode']." Message:".$resarray['errormessage'];
    }
}
我希望这对某人有所帮助,因为我拼命地从我的Web服务器上寻找打印的方法。

注意! 谷歌云打印在2020年12月后被弃用。

我知道这不是解决您问题的最佳解决方案,但如果您的打印机具有本地google cloudprint支持,或者您通过google chrome浏览器将打印机添加到cloudprint,则您可以通过google打印文档

要在GoogleCloudPrint上从PHP打印文档,您需要从Github获得以下类

有关如何获取凭据的信息位于类的中

有了这个代码片段,打印工作就像一个符咒

require_once 'php/cprint/Config.php';
require_once 'php/cprint/GoogleCloudPrint.php';

$gcp = new GoogleCloudPrint();
$refreshTokenConfig['refresh_token'] = 'your_refresh_token';
$token = $gcp->getAccessTokenByRefreshToken($urlconfig['refreshtoken_url'],http_build_query($refreshTokenConfig));
$gcp->setAuthToken($token);
$printers = $gcp->getPrinters();
//print_r($printers); // Show available printers with IDs

if(count($printers) == 0){
    exit("Could not get printers");
}else{
    $printerID = "your_printer_id";
    $resarray = $gcp->sendPrintToPrinter($printerID, "Document title", "path/to/document.pdf", "application/pdf");
    if($resarray['status'] == true){
        echo "Document has been sent to printer and should print shortly.";
    }else{
        echo "An error occured while printing the doc. Error code:".$resarray['errorcode']." Message:".$resarray['errormessage'];
    }
}

我希望这对其他人有所帮助,因为我拼命地在我的Web服务器上搜索打印方法。

TCPDF是用于在php中创建pdf的库。HTML中嵌入pdf:TCPDF是用于在php中创建pdf的库。HTML中嵌入pdf:我也有同样的问题。您找到解决方案了吗?同样,我希望远程员工能够使用我们的在线仪表板在办公室打印。谷歌云打印工作得很好,我现在该怎么办?我也有同样的问题。您找到解决方案了吗?同样,我希望远程员工能够使用我们的在线仪表板在办公室打印。谷歌云打印已经足够好了,我现在该怎么办?