How to Extract Actual Text and Alternative Text from PDF Files
Question details
The user wants to find methods to extract both actual text and hidden alternative text (alt text) from single or multiple PDF documents.
- Product
- PDF Editors
- Device & OS
- not provided
- Scenario
- Attempting to retrieve readable text and accessibility metadata (alternative text for images) from PDFs for auditing, archiving, or processing purposes.
- Observed behavior
- While standard text can be easily accessed or scripted, alternative text is hidden deep within the PDF's accessibility structure tree and is generally unexposed to basic JavaScript extraction methods.
Before attempting to extract alternative text, ensure your PDF is properly 'tagged' for accessibility, as untagged PDFs will not contain the structure tree required to hold alternative text attributes.
Save or Export PDF to Plain Text
The simplest way to extract the actual text from a PDF file is by using the built-in export or save-as functionality.
This method is highly effective for extracting standard text content from a document. However, it will strip away images, formatting, and hidden alternative text, leaving you with purely readable characters.
Launch your PDF editor and open the file from which you want to extract the text.
Click on 'File' in the top menu bar, then select 'Export To' or 'Save As Other' depending on your software version.
Select 'Text (Plain)' or 'Microsoft Word' as your output format. Click 'Save' to generate a file containing all the actual text extracted from the PDF.
Extract Actual Text using JavaScript
Use a custom JavaScript script within your PDF editor to iterate through and extract all words on the pages.
Use an Accessibility-Aware SDK for Alternative Text
To extract alternative text, you must utilize specialized PDF processing tools or SDKs capable of reading the PDF structure tree.
Extract Text from PDFs Instantly with WPS PDF
If you are looking for an easy way to extract actual text from PDF files without writing complex JavaScript, WPS Office provides built-in, one-click PDF-to-Word and PDF-to-Text conversion tools.
- 1. Open your PDF file: Launch WPS Office and open the PDF document you want to extract text from.
- 2. Select the conversion tool: Go to the 'Tools' tab on the top ribbon and click on 'PDF to Word' or 'Export to Text'.
- 3. Complete the extraction: Choose your preferred save location and click 'Start' to instantly convert the PDF and extract all readable text.

Frequently Asked Questions
Why can't I extract alternative text using standard PDF JavaScript?
Alternative text is embedded within the document's underlying logical structure tree (accessibility tags) rather than the visible text layer. Standard JavaScript APIs in most PDF editors only interact with the visible content stream, making them unable to retrieve hidden structural attributes without specialized plugins.
Is it possible to extract text from multiple PDFs at the same time?
Yes, for actual text, you can use batch processing tools like the Acrobat Action Wizard or the batch conversion feature in WPS PDF. For alternative text, batch processing generally requires a custom script written with a third-party accessibility PDF SDK to process a folder of files sequentially.
What happens to the images when I save a PDF as plain text?
When you export or save a PDF as plain text (.txt), all visual elements, including images, graphics, and formatting, are completely discarded. Only the actual readable text characters are preserved in the final output file.




