Skip to content

pavadik/PdfTo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PdfToTextDocx

A .NET console app for converting PDF files from a folder into txt, docx, or both formats.

The app extracts:

  • page-by-page text;
  • images into a separate images folder;
  • relative links to saved images inside the generated txt and docx files.

Features

  • Converts a single PDF file or all PDFs in a folder.
  • Optional recursive folder scanning.
  • Generates txt, docx, or both output formats.
  • Saves extracted images separately.
  • Keeps image references in the converted text.
  • Does not require Microsoft Word to be installed.

Requirements

  • .NET 8 SDK or newer.

Build

dotnet build

Usage

dotnet run -- --input "C:\PDF" --output "C:\PDF\out" --format both

Options:

  • --input, -i - input folder with PDF files, or a path to a single PDF file.
  • --output, -o - output folder. If omitted, a converted folder is created next to the input path.
  • --format, -f - txt, docx, or both. Default: both.
  • --recursive, -r - scan nested folders for PDF files.
  • --no-overwrite - fail instead of overwriting existing txt or docx files.

Examples

Convert all PDF files in a folder to TXT and DOCX:

dotnet run -- -i "C:\PDF" -o "C:\PDF\out" -f both

Convert one PDF file to DOCX only:

dotnet run -- -i "C:\PDF\file.pdf" -o "C:\PDF\out" -f docx

Scan nested folders and generate TXT files:

dotnet run -- -i "C:\PDF" -o "C:\PDF\out" -f txt --recursive

Output Structure

Each PDF gets its own output folder:

out/
  file/
    file.txt
    file.docx
    images/
      file_p001_img001.png
      file_p002_img001.jpg

Generated text files include image references like this:

[Image page 1, #1: images/file_p001_img001.png]

If an image encoding cannot be converted into a common image format, the image bytes are saved as .bin and the reference is marked as raw bytes.

Notes

This app extracts text that already exists in the PDF. Scanned PDFs without a text layer require OCR, which is not included.

License

This project is licensed under the MIT License. See LICENSE.

About

A .NET console app for converting PDF files to TXT or DOCX, with extracted images saved separately and linked in the output text.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages