# Using package datatool in standalone class

I wish to use package datatool in the standalone class (or with the standalone package, whichever works). I want datatool to print each row in the csv file on different page and standalone to crop each pdf according to the content on it (possibly, with fix width).

Following is my MWE. The example runs properly in article class, however, it gives error(s) in the standalone class. I guess that standalone does not like the clearpage command. However, as per my knowledge, this is the command (or \newpage) that prints each row on different pages in the output PDF.

\documentclass{article}%with this class things are fine.
%\documentclass[border=10pt]{standalone}%this class gives error.

\usepackage{datatool}
\usepackage{graphicx}

\begin{document}
\DTLforeach{sample}{%
\Nr=Number,\Quote=Quote}{%
\clearpage

(\Nr)\Quote
\begin{center}
\includegraphics[height=2cm]{test-graphics}
\end{center}%
}%
\end{document}


The csv file entries are like

Number, Quote
1, Quote 1
2, {Quote 2 which can have more text than other quotes. Thus, this quote would occupy more space than others would do.}
3, Quote 3


• I don't think datatool is the right tool if you do it this way. I would use a script or Lua to read the file and generate each separate standalone document. – Alan Munn Apr 16 at 17:55