php base64互转pdf 将base64解析成pdf

这是一个PHP实现的功能,可以将Base64编码转换为PDF文件,并且也能将PDF文件转换为Base64编码。通过file_get_contents读取内容,base64_decode和base64_encode进行转换,然后使用file_put_contents写入文件。
摘要由CSDN通过智能技术生成

/*
 * base64转pdf
 */
function base642pdf($formTxt,$toPdf)
{
    $file = file_get_contents($formTxt);//读
    $data = base64_decode($file);//转换
    file_put_contents($toPdf, $data);//写
}


/*
 * pdf转base64
 */
function pdf2base64($formPdf,$toTxt)
{
    $file = file_get_contents($formPdf);//读
    $data = base64_encode($file);//转换
    file_put_contents($toTxt, $data);//写
}

 

<?php $a="JVBERi0xLjQKJeLjz9MKOSAwIG9iago8PC9UeXBlL1hPYmplY3QvUmVzb3VyY2VzPDwvUHJvY1NldFsvUERGL1RleHQvSW1hZ2VCL0ltYWdlQy9JbWFnZUldL0ZvbnQ8PC9GMSAxMCAwIFIvRjIgMTEgMCBSPj4+Pi9TdWJ0eXBlL0Zvcm0vQkJveFswIDAgODQxLjg5IDU5NS4yOF0vTWF0cml4WzEgMCAwIDEgMCAwXS9MZW5ndGggMjgwMy9Gb3JtVHlwZSAxL0ZpbHRlci9GbGF0ZURlY29kZT4+c3RyZWFtCnicrZldb1tHDobv9SsG2Ju0gE/m+8N3qZ1kUySN1/bWyba90DqyrUaWXFtpkH+/JGeOhpSVQAEWQdG8Ec9zZoYckjPnr4lWoYTBZnULf9VqMcneDLnwvzaDxeRmcjFZToz6PLHqZzD/c2K0ejP57Q+tPkz+oue1ur+e/HQ+efrCKGMGm9T5FTyBP+A/6KF4FVwZjFPn8MbBJR+jOr+cPPlRPTs9+uerX5+r47dH6scfzv8EIPzw/LzyrIpDio9wSQWbh2QaziSdCffLaq3WK/XfmZqu19PLm9kHlHfTy4/T6xmH06gHrV2xOHZr/ZCCCsHi224nNvkhpFEvNtrGIXjUzX7UNxMcIP7pC2HtEBwfubVh0PCQ0zSl28mBGXRdhouTd49GR+MqYOJU8OALg+PKeQgGtBlSgfc6bfEHoc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FifEd/ormvYNLbEVexYENT3RcDZChckjcQph+n6uWn9Y5A+BopZEy6/w+Sb/EUNBS8tuFhi9r4HQxIt6Xsi8HHcIPs4ECzUdrGzhnqft3ZJR3oDJngP9OPq7vpcqbeTBeru9Xi4ePj7fgNOLSotg1SJ+9qSvp5CsR9NnWBXQzRZIZxvWCaJok9vT8megyYul7W2jrPGLO2BrKlOCNsak7bjtAyOrYbSbLNCAlCi+MI9rVwSMiaDiG3kycD4vtyWTeUIJ
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值