514514 </ span >
515515 </ a >
516516
517+ </ li >
518+
519+ < li class ="md-nav__item ">
520+ < a href ="#tips-and-tricks " class ="md-nav__link ">
521+ < span class ="md-ellipsis ">
522+ Tips and tricks
523+ </ span >
524+ </ a >
525+
517526</ li >
518527
519528 </ ul >
731740 </ span >
732741 </ a >
733742
743+ </ li >
744+
745+ < li class ="md-nav__item ">
746+ < a href ="#tips-and-tricks " class ="md-nav__link ">
747+ < span class ="md-ellipsis ">
748+ Tips and tricks
749+ </ span >
750+ </ a >
751+
734752</ li >
735753
736754 </ ul >
@@ -1030,8 +1048,8 @@ <h4 id="example_3">Example</h4>
10301048< h2 id ="linking-to-a-generated-pdf "> Linking to a generated PDF</ h2 >
10311049< p > All generated static PDF files are saved with the aliaspath of the generating
10321050resource. If you want to create a link to that PDF file, you could use the
1033- following code:</ p >
1034- < div class ="highlight "> < pre > < span > </ span > < code > < span class ="p "> <</ span > < span class ="nt "> a</ span > < span class ="na "> href</ span > < span class ="o "> =</ span > < span class ="s "> "[[*id:pdfresourcelink]]"</ span > < span class ="p "> ></ span > PDF< span class ="p "> </</ span > < span class ="nt "> a</ span > < span class ="p "> ></ span >
1051+ following code. The output filter returns < code > - </ code > if the file does not exist :</ p >
1052+ < div class ="highlight "> < pre > < span > </ span > < code > [[*id:pdfresourcelink:ne=`-`:then=` < span class ="p "> <</ span > < span class ="nt "> a</ span > < span class ="na "> href</ span > < span class ="o "> =</ span > < span class ="s "> "[[*id:pdfresourcelink]]"</ span > < span class ="p "> ></ span > PDF< span class ="p "> </</ span > < span class ="nt "> a</ span > < span class ="p "> ></ span > `:else=``]]
10351053</ code > </ pre > </ div >
10361054< h2 id ="debug-htmlcss-output "> Debug HTML/CSS output</ h2 >
10371055< p > The pre-rendered HTML or CSS output handled by mPDF can be debugged with the
@@ -1040,6 +1058,12 @@ <h2 id="debug-htmlcss-output">Debug HTML/CSS output</h2>
10401058URL parameter. The result will be the HTML or CSS code that is handled by mPDF.</ p >
10411059< p > That way you can identify wrong image paths etc. in this code. Don't forget to
10421060disable the < code > pdfresource.debug</ code > system setting afterwards.</ p >
1061+ < h2 id ="tips-and-tricks "> Tips and tricks</ h2 >
1062+ < p > If you want to change the filename of the generated PDF on the fly, you have to
1063+ create a new plugin that runs before PDFResource in OnWebPagePrerender. This
1064+ plugin has to execute < code > $modx->resource->set('alias', 'invoice_'
1065+ . date('Ymd', $invoice->get('date')) . '_' . $invoice->get('client_id'))</ code > to set the
1066+ alias on the fly (it works even without saving $modx->resource).</ p >
10431067
10441068
10451069
@@ -1071,7 +1095,7 @@ <h2 id="debug-htmlcss-output">Debug HTML/CSS output</h2>
10711095 < div class ="md-copyright ">
10721096
10731097 < div class ="md-copyright__highlight ">
1074- © 2015-2022 < a href ="https://treehillstudio.com "> Treehill Studio</ a >
1098+ © 2015-2025 < a href ="https://treehillstudio.com "> Treehill Studio</ a >
10751099 </ div >
10761100
10771101
0 commit comments