Extract text from papers, EPUBs, and old archive scans.

Research corpora run PDF-heavy, with EPUB references and scanned TIFF from older archives. txtfetch reads all three, and two-column layouts still need a second look.

the-problem

Literature review tools and archive digitisation projects live on PDF. Older archives add EPUB and scanned TIFF, often the only surviving copy of a paper. A two-column layout reads out of order when a parser flattens it into one text stream. Ligatures and hyphenated line breaks turn a common word into two broken tokens.

how-txtfetch-solves-it

txtfetch reads PDF, EPUB, and scanned TIFF through the same endpoint. It returns text, not typed citation or metadata fields. OCR runs automatically on TIFF pages and on PDF pages with no text layer. Two-column layouts, ligatures, and hyphenated line breaks are real problems. /fixes covers how to check for and correct each one.

  • One endpoint reads PDF, EPUB, and scanned TIFF.
  • OCR runs automatically on TIFF pages and on PDF pages with no text layer.
  • Two-column layouts can come back interleaved, and /fixes/columns-out-of-order covers the check.
  • /fixes documents ligature and hyphenated-line-break repair for this corpus.
  • Async job and webhook mode covers digitising a large archive.
  • A batch of mixed PDF, EPUB, and scanned TIFF files needs no branching logic on your side.
curl
curl -X POST https://api.txtfetch.com/v1/extract \
  -H "Authorization: Bearer $TXTFETCH_KEY" \
  -F file=@paper.pdf
Python
import os
import requests

with open("paper.pdf", "rb") as f:
    r = requests.post(
        "https://api.txtfetch.com/v1/extract",
        headers={"Authorization": f"Bearer {os.environ['TXTFETCH_KEY']}"},
        files={"file": f},
    )

print(r.json()["extracted_text"])
JavaScript
import { readFile } from "node:fs/promises";

const file = new Blob([await readFile("paper.pdf")]);
const form = new FormData();
form.append("file", file, "paper.pdf");

const res = await fetch("https://api.txtfetch.com/v1/extract", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.TXTFETCH_KEY}` },
  body: form,
});

const { extracted_text } = await res.json();
console.log(extracted_text);
Go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"mime/multipart"
	"net/http"
	"os"
)

type extractResponse struct {
	Status        string `json:"status"`
	ExtractedText string `json:"extracted_text"`
}

func main() {
	f, err := os.Open("paper.pdf")
	if err != nil {
		panic(err)
	}
	defer f.Close()

	var body bytes.Buffer
	writer := multipart.NewWriter(&body)
	part, err := writer.CreateFormFile("file", "paper.pdf")
	if err != nil {
		panic(err)
	}
	if _, err := io.Copy(part, f); err != nil {
		panic(err)
	}
	writer.Close()

	req, err := http.NewRequest("POST", "https://api.txtfetch.com/v1/extract", &body)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("TXTFETCH_KEY"))
	req.Header.Set("Content-Type", writer.FormDataContentType())

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	var result extractResponse
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		panic(err)
	}
	fmt.Println(result.ExtractedText)
}
{
  "status": "success",
  "extracted_text": "..."
}

faq

Does txtfetch fix two-column reading order automatically?
It extracts in reading order for most PDFs. /fixes/columns-out-of-order covers the cases that still need a check.
Can txtfetch read a scanned TIFF from an old archive?
Yes. OCR runs automatically on TIFF pages, the same as a scanned PDF page.
Does txtfetch handle EPUB files?
Yes. EPUB is one of the formats read through the same endpoint as PDF and TIFF.

related-reading

Start on the free plan.

Run your own documents through it before you commit. The Hobby plan needs no card.

Get started →

See the pricing →