2
$\begingroup$

I can import text from a PDF using

text = Import[filename, "Plaintext"];

I'd like to do the same thing using FormFunction, but am unsure how. I've tried the following:

FormFunction[
 "file" -> "PDF",
 #file &,
 "Text"
 ]

which seems to import an image of the PDF. I've also tried

FormFunction["file" -> "Text", 
 #file &,
 "Text"
 ]

which doesn't allow PDFs to be entered. Any advice would be greatly appreciated.

$\endgroup$
  • $\begingroup$ Does my answer fit your needs?> $\endgroup$ – Kuba Jan 2 at 13:24
  • $\begingroup$ Yes, apologies for the delay. $\endgroup$ – aasantos Jan 7 at 13:23
1
$\begingroup$

If you want to import a specific element of a pdf you can use "Text" type and proceed with ImportString and elements spec:

FormFunction[
  "file" -> "Text"
, ImportString[#file, {"PDF", "Plaintext"}] &
] 

It does not mean you will always get what you expect. It depends what the pdf really contains. Text inside can be e.g. rasterized.

Closely related: https://mathematica.stackexchange.com/a/148358/5478

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.