I am looking for a simple, affordable library to read pdf files into FMX applications

Any recommendations, anyone ?

1 Like

Have a look at PDFium for FireMonkey

I haven’t used it… but I think it will meet your requirements as described.

1 Like

Thanks, I had spotted their other products for the different platforms. But not this one. Will give it a go

I’d be interested in hearing Rohit’s opinions on how you go with Winsoft.

I started prototyping with Winsoft’s FMX ones (e.g. camera, barcode) back in the XE4 days. For the PDF report generation I used an eval TMS (?) one which had more documentation and examples, but still buggy and missing features, but did the job well enough for a C++ cross platform POC.

I had a little bit of hassle with FMX and a little bit of hassle with Pdfium and discovered the absence of TOpenDialog on Android.

I have the Windows version running. I will try the Android tomorrow. If successful, I will make the project available on my website.

At the end, the amount of code required to extract text from the pdf is only about 6 lines.

1 Like

Is this just for viewing PDFs, or manipulating them in some way, or anything else?

Just for extracting text. I shall try the Android later today. I have hopes that it will work.

My fallback was going to be to install a webservice on my website and get the app to send the document there for extraction.

Its all working. This time, no hassles with the library, just the ruddy IDE kept crashing every time I tweaked the fmx form. I have made all my test code available Fmx PDF Test .

It contains the full source, a compiled apk and a compiled exe (with the dll). If you want to compile it, you will need to install PDFium, they have a trial version.

Finally, there is no OpenDialog on Android. I have made available four folders that you can select from, to grab the pdf file. If it doesn’t find any files there, it shows you the path, so you can copy a pdf there with a file manager. I use X-plore.

Sorry to be resurrecting this ancient thread. Thanks for the recommendation on PDFium. I used it to build an app that allows me to create a PDF for school permission slips. Given the slip is always the same, it just makes it simpler to fill it using an app versus the tedium of going into the PDF directly. It was good to play with the PDF technology anyway.

2 Likes

I don’t know what is VCL specific in these repos …

also relevant … GitHub - bblanchon/pdfium-binaries: 📰 Binary distribution of PDFium

For those interested I had a little play with several PDF component evaluations and open-source libraries in v10.4 and v11 Rad Studio. Some extremely powerful features, but TBH a bit of overkill for extracting text from a PDF.

I agree with Rohit, WinSoft’s PDFium wrapper wins the day, for instance

void __fastcall TForm4::SpeedButton1Click(TObject *Sender) {
      TFileStream *FileStream;
      FPdf->FileName = OpenDialog->FileName;
      FPdf->PageNumber = 0;
      FPdf->Active = true;
      String FileName = ExtractFileName(FPdf->FileName);
      FileStream = new TFileStream(FileName + ".txt", fmCreate);
      for (int i = 0; i < FPdf->PageCount; i++) {

            FPdf->PageNumber = i + 1;
            UTF8String Text = UTF8Encode(FPdf->Text(0, 2000));

            if (Text != "") {
                  FileStream->WriteBuffer((void*)&Text[1], Text.Length());
                  FileStream->WriteBuffer((void*)&sLineBreak[1], 2);
                  FileStream->WriteBuffer((void*)&sLineBreak[1], 2);
            }
      }
      FileStream->Free();
      Memo1->Lines->LoadFromFile(FileName + ".txt");
}
1 Like

Since this thread popped up again, @GrahameDGrieve did a presentation on PDF’s in July 2023. Here is the recording below. I don’t think it has anything about FMX, but probably still has some useful information on PDF’s.

1 Like

What do you mean by read ?

Regards,
Andrew Pratt