It is not possible to do this natively in Dia.
Being open source software, the feature could be implemented.
There is nothing that technically prevents a PDF from having custom dimensions (but it can't have no dimensions, that goes without saying I think).
Just in case Dia coders are reading this, the way I see the feature implemented would look like this:
- You would still have to select a paper size in Page Setup.
- You would set all margins to zero
- You would then tick a check-box named something like "Crop paper size to fit content"
On export, Dia would first scale the image to best fit the paper size, then adjust the paper size in one dimension to eliminate remaining empty space, then perform the render to PDF.
Who wants to implement this? If I had the coding expertise I would, because frankly this would be an excellent feature which I'd use myself too.