\documentclass{article}
\usepackage[a4paper]{geometry}
\begin{document}
\makeatletter
\ExplSyntaxOn
\cs_new:Npn \ifaivpaper@TF
{
\bool_lazy_and:nnTF
{ \dim_compare_p:nNn { 297mm } = { \paperheight } } % 不能是 29.7cm
{ \dim_compare_p:nNn { 210mm } = { \paperwidth } }
}
\ExplSyntaxOff
\ifaivpaper@TF{a4paper}{not a4paper}
\makeatother
\end{document}