add debug for find problems
This commit is contained in:
parent
a3008ac02f
commit
8e536f239d
|
@ -53,7 +53,7 @@ class GeneralController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/front/print/{id}', name: 'app_front_print')]
|
#[Route('/front/print/{id}', name: 'app_front_print')]
|
||||||
public function app_front_print(Provider $provider, EntityManagerInterface $entityManager, pdfMGR $pdfMGR, string $id): Response
|
public function app_front_print(Provider $provider, EntityManagerInterface $entityManager, PdfMGR $pdfMGR, string $id): Response
|
||||||
{
|
{
|
||||||
$print = $entityManager->getRepository(PrinterQueue::class)->findOneBy(['pid' => $id]);
|
$print = $entityManager->getRepository(PrinterQueue::class)->findOneBy(['pid' => $id]);
|
||||||
|
|
||||||
|
@ -65,12 +65,21 @@ class GeneralController extends AbstractController
|
||||||
return new JsonResponse(['error' => 'Empty print content'], Response::HTTP_BAD_REQUEST);
|
return new JsonResponse(['error' => 'Empty print content'], Response::HTTP_BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// تولید PDF و گرفتن محتوا به صورت رشته
|
||||||
if ($print->isPosprint()) {
|
if ($print->isPosprint()) {
|
||||||
$pdfMGR->streamTwig2PDFInvoiceType($print);
|
$pdfContent = $pdfMGR->generateTwig2PDFInvoiceType($print); // متد جدید برای گرفتن محتوا
|
||||||
} else {
|
} else {
|
||||||
$pdfMGR->streamTwig2PDF($print);
|
$pdfContent = $pdfMGR->generateTwig2PDF($print); // متد جدید برای گرفتن محتوا
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response('Print job completed', Response::HTTP_OK);
|
// برگرداندن PDF به عنوان پاسخ
|
||||||
|
return new Response(
|
||||||
|
$pdfContent,
|
||||||
|
Response::HTTP_OK,
|
||||||
|
[
|
||||||
|
'Content-Type' => 'application/pdf',
|
||||||
|
'Content-Disposition' => 'inline; filename="Hesabix PrintOut.pdf"',
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,8 @@ class pdfMGR
|
||||||
$this->twig = $twig;
|
$this->twig = $twig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function streamTwig2PDF(PrinterQueue $printQueue, $configs = [])
|
public function generateTwig2PDF(PrinterQueue $printQueue, $configs = []): string
|
||||||
{
|
{
|
||||||
// Load Twig File
|
|
||||||
$template = $this->twig->load('pdf/footer.html.twig');
|
$template = $this->twig->load('pdf/footer.html.twig');
|
||||||
$footer = $template->render([]);
|
$footer = $template->render([]);
|
||||||
|
|
||||||
|
@ -61,10 +60,12 @@ class pdfMGR
|
||||||
$mpdf->WriteHTML($htmlContent);
|
$mpdf->WriteHTML($htmlContent);
|
||||||
$mpdf->SetAutoPageBreak(true);
|
$mpdf->SetAutoPageBreak(true);
|
||||||
$mpdf->SetTitle('حسابیکس');
|
$mpdf->SetTitle('حسابیکس');
|
||||||
$mpdf->Output('Hesabix PrintOut.pdf', 'I');
|
|
||||||
|
// به جای Output مستقیم، محتوا رو برگردونید
|
||||||
|
return $mpdf->Output('', 'S'); // 'S' برای برگرداندن به صورت رشته
|
||||||
}
|
}
|
||||||
|
|
||||||
public function streamTwig2PDFInvoiceType(PrinterQueue $printQueue, $configs = [])
|
public function generateTwig2PDFInvoiceType(PrinterQueue $printQueue, $configs = []): string
|
||||||
{
|
{
|
||||||
$defaultConfig = (new ConfigVariables())->getDefaults();
|
$defaultConfig = (new ConfigVariables())->getDefaults();
|
||||||
$fontDirs = $defaultConfig['fontDir'];
|
$fontDirs = $defaultConfig['fontDir'];
|
||||||
|
@ -105,7 +106,8 @@ class pdfMGR
|
||||||
|
|
||||||
$htmlContent = $printQueue->getView() ?: '<p>محتوای PDF در دسترس نیست.</p>';
|
$htmlContent = $printQueue->getView() ?: '<p>محتوای PDF در دسترس نیست.</p>';
|
||||||
$mpdf->WriteHTML($htmlContent);
|
$mpdf->WriteHTML($htmlContent);
|
||||||
$mpdf->Output();
|
|
||||||
|
return $mpdf->Output('', 'S'); // 'S' برای برگرداندن به صورت رشته
|
||||||
}
|
}
|
||||||
|
|
||||||
public function savePDF(PrinterQueue $printQueue, string $path)
|
public function savePDF(PrinterQueue $printQueue, string $path)
|
||||||
|
|
Loading…
Reference in a new issue