I have to overlay some texts on a PDF form. As converting the PDF form to EPS with pdftops produces unsatisfying result, I will not use PSTricks code below.
\documentclass[pstricks,border=12pt]{standalone}
\def\M{4}% columns
\def\N{4}% rows
\def\scale{1}% scale
\def\filename{example-image-a}% filename
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=\scale]{\filename}}
\addtopsstyle{gridstyle}
{
gridcolor=yellow,
subgridcolor=gray,
subgriddiv=10,
griddots=0,
subgriddots=5,
gridwidth=0.4pt,
subgridwidth=0.2pt,
}
\psset
{
xunit=0.5\dimexpr\wd\IBox/\M,
yunit=0.5\dimexpr\ht\IBox/\N,
}
\begin{document}
\begin{pspicture}[showgrid=top](-\M,-\N)(\M,\N)
\rput(0,0){\usebox\IBox}
\rput[bl](1,1){This is a text.}
\end{pspicture}
\end{document}
The output I want to achieve looks like the following.

Instead I will use TikZ. My problem is how to set the horizontal and vertical unit in TikZ. More precisely, how to do the following in TikZ?
\psset
{
xunit=0.5\dimexpr\wd\IBox/\M,
yunit=0.5\dimexpr\ht\IBox/\N,
}
MWE in TikZ
\documentclass[tikz,12pt,dvipsnames,border=12pt]{standalone}
\def\M{4}% columns
\def\N{4}% rows
\def\scale{1}% scale
\def\filename{example-image-a.pdf}% filename
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=\scale]{\filename}}
\begin{document}
\begin{tikzpicture}[inner sep=0,x=0.5\wd\IBox/\M\relax,y=0.5\ht\IBox/\N\relax]
\node (image) at (0,0) {\usebox\IBox};
\node at (1,1) {some text goes here};
\draw[help lines,red,step=1](-\M,-\N) grid (\M,\N);
\end{tikzpicture}
\end{document}

DONE! Problem solved!
