For the following, I would like to get an exact measurement of 10mm for both the right and left margins of the graph paper instead of 20 mm.
% https://tex.stackexchange.com/a/356984/2288
\documentclass{article}
\usepackage{pgfplots}
\usepackage{siunitx}
\usepackage[
a4paper , right = 10mm , left = 10mm , includeheadfoot,
]{geometry}
\begin{document}
\pagestyle{empty}
\centering
% http://tex.stackexchange.com/a/15002/100384
\newcommand*{\getlength}[2]{%
% Convert to `cm` and round to two fractional digits:
\pgfmathsetmacro#1{round(0.0351459804*#2)}%
}
\vspace*{\fill}
\rotatebox{0}{
\begin{tikzpicture}
% a factor for measures, since pfplots produces slightly bigger images than defined
% in width/height. This can be used to adjust that problem manually
\pgfmathsetmacro{\factor}{0.9}% 0.9
% we will need some length in `cm`, without units, and rounded
\getlength{\yMax}{\factor*\textheight}
\getlength{\xMax}{\factor*\textwidth}
\begin{axis}[
set layers,
width=\factor\textwidth, height=\factor\textheight,
x = 1cm, y = 1cm,
xtick={0,1,...,\xMax},
ytick={0,1,...,\yMax},
minor xtick={0,0.1,0.2,...,\xMax},
minor ytick={0,0.1,0.2,...,\yMax},
tick style = {line width = 0.6pt, black!40!white},
minor tick style = {draw = none},
major tick style = {draw = none},
ticklabel style = {draw = none},
xticklabels=\empty, %xlabel = \empty,
yticklabels=\empty, %ylabel = \empty,
axis line style = {-latex},
grid = both,
minor grid style={line width=0.2pt, black!20!white},
major grid style={line width=0.6pt, black!60!white},
ymin=0, ymax=\yMax,
xmin=0, xmax=\xMax,
]
\begin{pgfonlayer}{axis grid}
\draw[line width=0.40pt, step=0.5cm, black!40!white] (axis cs: 0, 0) grid (axis cs: \xMax, \yMax);
\end{pgfonlayer}
\end{axis}
\end{tikzpicture}
}
\vspace*{\fill}
\end{document}
Update
When editing @JohnKormylo's answer to have
\usepackage[
a4paper , right = 10mm , left = 10mm ,
top = 5 mm, headheight = 0 mm, headsep = 0 mm,
foot = 0 mm, bottom = 5 mm, showframe
]{geometry}
the output has two issues:
1- the drawing is on the second page, while the first page is empty
2- the bottom margin is less than the specified value of 5 mm.

geometrysince I need to make sure the output isa4paper? (2) what does\pgfresetboundingbox \path (border.south west) (border.north east);do? (3) also, what does\begin{tikzpicture}[remember picture, overlay] \node at (current page.center) {\usebox\gridbox}; \end{tikzpicture}do? I hope your patience hasn't run out:). – Diaa Feb 26 '20 at 21:53\pgfresetboundingbox, what was the original bounding box? – Diaa Feb 27 '20 at 18:31