Consider the following minimal example graph that should fit on an A4 page
digraph G{
size="8.3,11.7!" ratio=fill;
foo->bar;
}
C
The problem lies in the details about the ratio:
Note that this is adjusted before the size attribute constraints are enforced. In addition, the calculations usually ignore the node sizes, so the final drawing size may only approximate what is desired.
It seems that graphviz
The result would be bigger than A4.
Therefore if we were to make nodes and margin as small as possible, then the output should come relatively close to A4.
Setting margin to 0 and the node's shape to point as well as their width and height to the minimum values with the following graph:
digraph G{
ratio="fill";
size="8.3,11.7!";
margin=0;
node[shape=point, height=0.02, width=0.01];
foo->bar;
}
neato -Tpdf with this graph results in a PDF with dimensions 211x297mm (using 8.267 inches as width will result in a clean 210x297mm).
Unfortunately, even knowing how graphviz works in respect to ratio=fill, I don't think there's an easy way to make sure the final result is always A4 when using nodes which actually have a width and height.