There’s already a solution
Print to PDF, which is well understood and supported on every operating system.