Converting a spooled file into PDF is not an RPG function.
If you want to do it natively on your system, you need 5722IP1 IBM Infoprint Server.
The principe is to define a writer that will convert you spool into a PDF file and store it in the IFS.
See Chapter 4. Using the Infoprint Server for iSeries PDF transform in the Prining VI Redbook:
It’s quit easy to start. It can be a bit tricky if you want something “customized”.
Hope this will help
To use RPG yourself to generate PDF output, you might use either the General Print APIs and/or Exit Programs to intercept printer output or various Spooled File APIs to process spooled files already on *OUTQs.
The printer data would be processed by the RPG code that you will write. You will write the code to implement the PDF Specifications as described in the Document Management – Portable Document Format – Part 1: PDF 1.7, First Edition document.
If you choose to avoid the Print and.or Spooled File APIs, you can always write new programs that generate the PDF documents directly by using the specifications at that Adobe web site above.