Documentation
For more information about LaraTeX please check the Readme on github https://github.com/ismaelw/laratex.
Dry Run
Dry Run is your way to check if everything works already without much configuration. Make sure that you have modified the config file and then you are ready.
                                    
use Ismaelw\LaraTeX\LaraTeX;

...

return (new LaraTeX)->dryRun();
                                    
                                
Download Dry Run PDF
Download PDF with Data
You can also send data to your latex blade file and render the PDF file in that way.
                                    
use Ismaelw\LaraTeX\LaraTeX;

...

return (new LaraTeX('latex.tex'))->with([
    'Name' => 'John Doe',
    'Dob' => '01/01/1990',
    'SpecialCharacters' => '$ (a < b) $',
    'languages' => [
        'English',
        'Spanish',
        'Italian'
    ]
])->download('test.pdf');
                                    
                                
                                    

...

\begin{center}
    \item[Name :] {{ $Name }}
    \item[Date of Birth :] {{ $Dob }}
\end{center}

...

\begin{tabular}{|c|l|} 
        \hline
        \rowcolor[HTML]{E3E3E3}
        \textbf{ID} & \textbf{Language} \\
        \hline\renewcommand{\arraystretch}{1.5}
        
        @foreach($languages as $key => $language)
            {{ $key }} & {{ $language }} \\ \hline
        @endforeach        
\end{tabular}

...

\begin{center}
	{!! $SpecialCharacters !!}
\end{center}

...

                                    
                                
Download PDF with submitted data
Using the latex Blade directive
Since LaTeX has its own syntax it is not advised to use the standard blade syntax {{ $variable }} or {!! $variable !!}. Instead you can use @latex($variable) in your blade templates instead, which handles the suitable escaping of reserved LaTeX characters
                                    
use Ismaelw\LaraTeX\LaraTeX;

...

return (new LaraTeX('latex.tex2'))->with([
    'Name' => 'John Doe',
    'Dob' => '01/01/1990',
    'SpecialCharacters' => '$ (a < b) $',
    'languages' => [
        'English',
        'Spanish',
        'Italian'
    ]
])->download('test.pdf');
                                    
                                
                                    

...

\begin{center}
    \item[Name :] @latex($Name)
    \item[Date of Birth :] @latex($Dob)
\end{center}

...

\begin{tabular}{|c|l|} 
        \hline
        \rowcolor[HTML]{E3E3E3}
        \textbf{ID} & \textbf{Language} \\
        \hline\renewcommand{\arraystretch}{1.5}
        
        @foreach($languages as $key => $language)
            @latex($key) & @latex($language) \\ \hline
        @endforeach        
\end{tabular}

...

\begin{center}
	{!! $SpecialCharacters !!}
\end{center}

...

                                    
                                
Download PDF with submitted data
Convert HTML to LaTeX

Demo HTML String

A new builtin feature converts simple HTML strings to LaTeX strings. In this example below you can find a HTML string with the most common HTML tags.
                                    
use Ismaelw\LaraTeX\LaraTeX;

...

$HTMLString = '<h1>Heading 1</h1> <p>Text</p> <h2>Heading 2</h2> <p>Text</p> <h3>Heading 3</h3> <p>Text</p> <p>Normal text here with some <strong>strong</strong> and <strong>bold</strong> text.</p> <p>There is also text that could be <u>underlined</u>.</p> <p>Or of course we could have <em>em-wrapped</em> or <em>i-wrapped</em> text</p> <p>A special test could be a <u><em><strong>bold, underlined and italic</strong></em></u> text at the same time!</p> <p>For the mathematicians we also have calculations x<sup>2</sup> and chemical stuff H<sub>2</sub>O</p> <p>We also have lists that needs to be shown. For example an unordered and an ordered list.</p> <p>If there is alot of text we might also want to use a line break <br> to continue on the next line.</p> <ul> <li>UL Item 1 <ul> <li>UL Item 1.1</li> <li>UL Item 1.2</li> </ul> </li> <li>UL Item 2</li> <li>UL Item 3</li> </ul> <ol> <li>UL Item 1</li> <li>UL Item 2</li> <li>UL Item 3</li> </ol> <p>Last but not least. We have images.</p> <img src="/images/testimages/image1.png" /> <img src="/images/testimages/image2.png" >';

$Override = array(
array('tag' => 'img', 'extract' => 'src', 'replace' => '\begin{center}\includegraphics[scale=1]{$1}\end{center}'),
array('tag' => 'body', 'extract' => 'value', 'replace' => '$1 \newline '),
);

$LatexString = (new LaraTeX)->convertHtmlToLatex($HTMLString, $Override);
                                    
                                
Convert Demo to LaTeX

Convert your HTML string to LaTeX

If you want to try the converter with your own HTML code you can paste it in the textarea below and click on "Convert to LaTeX".

Convert to LaTeX
Laravel v8.56.0 (PHP v7.4.33)