i you want to create pdf with txt file with Encoding: Custom to do direct for my past experience i am using this method to do this kind of work
var pdfReader = new PdfReader(filePath);
var pdfDocument = new PdfDocument(pdfReader);
var strategy = new LocationTextExtractionStrategy();
StringBuilder extractedText = new StringBuilder();
for (int i = 1; i <= pdfDocument.GetNumberOfPages(); i++)
{
var page = pdfDocument.GetPage(i);
string pageText = PdfTextExtractor.GetTextFromPage(page, strategy);
extractedText.Append(pageText);
}
pdfReader.Close();
return extractedText.ToString();
with this method if not work then check this site https://api.itextpdf.com/iText/java/7.1.15/index.html?com%2Fitextpdf%2Fio%2Ffont%2FIExtraEncoding.html= this is officialapi from iText as well check this How to get the text position from the pdf page in iText 7