It is kind of complicated actually. There is some stuff that is straight forward. Published before 1923 is public domain. Anything else has other criteria. Here is a guide. That is all for the US, so it may be different elsewhere.
Here are a couple sources of Public Domain documents in ready to use electronic format:
Most of the contents of above are public domain. Some are not. Each is clearly marked.
If you have a physical book with a copyright date that puts it in the public domain, then you could have it typed in, or use OCR (optical character recognition) to digitize it.
There are actually other sources beyond Public Domain, depending on what you want to do. A relatively new movement is the Creative Commons, where things are still copyrighted, but limited use is grated under certain terms. The use may even include publishing for money. This is similar to open source, which is mostly confined to software. Many sites, like Flickr allow people to license their works with Creative Commons for easy sharing.
Most of the contents of the Wikimedia foundation’s websites (including WikiSource above) is available under the GNU Free Documentation License. It grants you a lot of freedoms with how you use it, but has a number of restrictions. Mainly if you modify or add to it then you must make your modifications or additions also available under the same license. It does however allow you to create a print version with certain requirements of front mater inclusion.
There are a lot of straight forward areas, but then some others that are rather gray where you may want to get an attorney.