Your issue may be when you are writing the PDF file from the encoded you are adding new lines to the file and corrupting it. You have to use the “-nonewline” when writing to the file. Assuming you are base64 encoding the file here is a code snippet for decoding:
==================================
package require base64
set handle [open $pdfFile r]
fconfigure $handle -encoding binary -translation binary
set pdfData [read $handle]
close $handle
set outPDF [ base64::decode $pdfData ]
set handle [open $pdfFile.DECODED.PDF w]
fconfigure $handle -encoding binary -translation binary
puts -nonewline $handle $outPDF
close $handle