QPDF is a good option:
QPDF is a command-line tool and C++ library that performs content-preserving
transformations on PDF files. It supports linearization, encryption, ...
You can use Spire.PDF for Python to convert PDF to text. The spacing and positioning of the text will be retained during the text extraction.
from spire.pdf import *
from spire.pdf.common import *
PdfLib CORE is a library for modern .NET Core applications to edit and read PDF files.
Snippet from the readme.md:
var dpiX, dpiY = 300D;
var i = 0;
using var pdfDocument = new PdfDocument(File.Open(&...