Just like image(jpg,png,gif) attachment, if you click them on the attachment, you can view it directly.
So I want certain extension also, like .txt to open directly on the browser when click not to download.
will inform the browser that the PDF should be saved as a file instead. Sure, ultimately it depends on your client and what apps you have installed on your client computer, but there is at least a way to hint the browser of how the file should be opened/downloaded. Not every browser behaves the same, and here is a (somewhat outdated) list with example links of how browsers react to sending inline txt content:
You do this via http headers. Either in your webserver configuration, if you have access, or via software. Unlike vBulletin, xF doesn't allow to change mime settings for individual attachment types, so that would require an add-on.