TCanvas resolution&quality changes if diving to pads

You can see in the PDF document properties that the width is 7.88 inches, or 20 cm, for both files. See also

What you could do is change the paper size to obtain the width that you need; as long as the width is what you want, the height you specify here doesn’t seem to matter, as it will be adjusted to the aspect ratio of your canvas, as you can see from your PDFs, which both have a width of 20 cm but different heights in spite of the default of 26.
So, if you want the dimensions to change in a consistent way when you change the pixel sizes, you will have to do some simple calculation to pass the corresponding cm to SetPaperSize.