1
votes

In dompdf I want to generate a single pdf-file, containing multiple documents, which may or may not have the same classes and elements in their HTML-base, but different css.

Simply concatenating all html-templates together and then rendering it won't be an option, because the documents have different headers and footers and the styles would overwrite each other.

Is there any better (faster, less resource consuming) way to this than generating every document at once, then store it to the file system and at the end combine them using tcpdf and fpdi?

2

2 Answers

1
votes

With dompdf not yet (though it's being considered for inclusion in a future release). That being said, depending on the number of documents you're loading you may see better performance rendering them separately, particularly if you spawn a separate process to render each document.

0
votes

You can use Node.cloneNode to get the copies of multiple documents and later concatenate them together before sending to DomPdf.

Please note that this method copies the applied CSS styles too unless they are computed.

So, I believe you have a solution as long as you apply your css through css classes.