html - How to detect end of page for PDF in php (laravel)

268

I have the following php code that converts html blade and show it on PDF file:

public function generatePDF(Request $request)
{
    PDF::SetTitle('myPDF');
    PDF::AddPage();
    $html_content = $view->render();
    PDF::AddPage();
    PDF::writeHTML($html_content, true, false, true, false, '');
    PDF::Output('myPDF.pdf'); }

$view is a laravel blade takes many paragraphs(string) with different lengths form database then the previous code show them on PDF file in a specific pattern.

What i want is to guarantee that no paragraph will split between two pages, for example if there is a paragraph of 4 lines and only two lines remains from the first page, then the whole paragraph should start from the second page.

117

Answer

Solution:

i think you should need to use this package instead for better library when dealing with PDF.

https://github.com/dompdf/dompdf

This is quite most developers has been using on the PDF development to every projects and even simpler to integrate and use.

For hard core solution, you may use this library but you need to code in a native PHP coding. Here is the online doc of the Library. http://www.fpdf.org/

People are also looking for solutions to the problem: Most popular PHP proxy scripts

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.