Possible to read a PDF file directly from memory?

Just starting out? Need help? Post your questions and find answers here.
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

Possible to read a PDF file directly from memory?

Post by flashbob »

Is it possible to read/open PDF-Content directly from memory instead from file ?

I would like to save the pdf file into a database an then load it directly into memory in order to open it with default pdf reader.
At the moment I save the PDF file to a temporary file before opening it with RunProgram(...).

Perhaps the same procedure could also be used to display images...

Thx in advance.
Last edited by flashbob on Tue Oct 15, 2024 9:56 am, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Possible to read a PDF file directly from memory

Post by Fred »

If you need an external tool to open your pdf, you need to write it to a file, unless I misunderstood your question.
acreis
Enthusiast
Enthusiast
Posts: 204
Joined: Fri Jun 01, 2012 12:20 am

Re: Possible to read a PDF file directly from memory?

Post by acreis »

If you use pdfium to render the document, then you can use:

Code: Select all

                                                                    ;// Function: FPDF_LoadMemDocument
                                                                    ;//          Open and load a PDF document from memory.
                                                                    ;// Parameters:
                                                                    ;//          data_buf    -   Pointer to a buffer containing the PDF document.
                                                                    ;//          size        -   Number of bytes in the PDF document.
                                                                    ;//          password    -   A string used as the password for the PDF file.
                                                                    ;//                          If no password is needed, empty or NULL can be used.
                                                                    ;// Return value:
                                                                    ;//          A handle to the loaded document, or NULL on failure.
                                                                    ;// Comments:
                                                                    ;//          The memory buffer must remain valid when the document is open.
                                                                    ;//          The loaded document can be closed by FPDF_CloseDocument.
                                                                    ;//          If this function fails, you can use FPDF_GetLastError() to retrieve
                                                                    ;//          the reason why it failed.
  Prototype FPDF_LoadMemDocument(*data_buf, size, password.p-unicode);
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

Re: Possible to read a PDF file directly from memory?

Post by flashbob »

Thanks for the info, but I don't want to use additional libs at the moment...
Post Reply