今天,我遇到了一个问题,即在符号上使用KnpSnappyBundle生成PDF。
我正在使用AJAX运行路由,代码工作正常,但它不会生成PDF,
我想在这里完成的是在新的选项卡或窗口中生成PDF,并向客户端返回成功的消息。
这是我的代码:
/**
* @Route("/api/release_bills/{month}/{year}/{region}", name="api_print_bills", methods={"GET","POST"})
* @param BillRepository $billRepository
* @param ConsumptionRepository $consumptionRepository
* @param Request $request
* @param Snappy $snappy
* @param $month
* @param $year
* @param $region
* @return Response
* @throws Exception
*/
public function releaseBills(BillRepository $billRepository,ConsumptionRepository $consumptionRepository, Request $request, Snappy $snappy, $month,$year,$region ): Response
{
$error = array();
$success = array();
if( $month>0 && $month<13 || preg_match("/^\d{4}$/",$year)||$region!=''){
if($year>=2018 && $year <=2050){
$entityManager = $this->getDoctrine()->getManager();
$bills = $consumptionRepository->findAllWaterMetersForBilling($month,$year,$region);
$isBillsExisted = $billRepository->findAllBillsByDate($month,$year,$region);
if(empty($bills)){
array_push($error,['error'=>'there is not bills to be release for this criteria : [ city: '.$region.', year :'.$year.', and Month : '.$month.'!]']);
return new JsonResponse($error);
}
$arr = array();
$newBills = array();
$billsEnd=end($bills);
foreach ($bills as $key=>$b){
$wmNumber = $b->getWaterMeter()->getWmNumber();
$fullName = $b->getWaterMeter()->getClient()->getFullName();
$cin = $b->getWaterMeter()->getClient()->getCin();
$address= $b->getWaterMeter()->getAddress();
$wmAddress = $b->getWaterMeter()->getAddress()->getStreetAddress();
$city = $b->getWaterMeter()->getAddress()->getCity();
动漫人物
慕沐林林
九州编程
炎炎设计
随时随地看视频慕课网APP