Page 1 of 1

Store PDF in database

PostPosted: Sun Dec 14, 2014 8:12 am
by dotchiejack
Hello,

I have a database with 4 fields,
1: Name
2: Description
3: Photp
4: Pdf
Field 1 and 2 are text files
Field 3 and 4 are ole objects

Field 1,2and 3 are oke for wat i want

Fiekd 4 gives me problems
Field 4 should store PDF files, what is not a problem but they should be visible in or a retangle or a picture field and i can not see how
so record 1 should show
name 1
descrpition 1
foto1
pdf 1
record 2 should show
name2
description 2
foto2
pdf2
etc...
Please some help
THanks

Re: Store PDF in database

PostPosted: Sun Dec 14, 2014 8:46 am
by carlos torres
Dear dotchiejack

You have some options:
1 - Use both path+ filename for the pdf and picture fields.
2 - Encrypt the pfd files and keep them in an specific folder (see Neobinary plugin by David from Argentina)
3 - Store the picture files in a database field as OLE Object

Hope it helps you

regards
carlost

Re: Store PDF in database

PostPosted: Sun Dec 14, 2014 6:28 pm
by stu
What about storing the file path of the PDF in the database, then bring it to neobook in a Webbrowser object and display the pdf with something like: https://github.com/mozilla/pdf.js

Re: Store PDF in database

PostPosted: Mon Dec 15, 2014 3:32 am
by dotchiejack
Hello,
Thank you for your answers , I looked into it but still dont get any further. So i post a screenshot, hopefully it makes everything clearer.

Thanks
Image

Re: Store PDF in database

PostPosted: Mon Dec 15, 2014 10:21 am
by stu
Image

This is the most simple approach of a solution, works fine.

Download:
http://s000.tinyupload.com/index.php?fi ... 6067889522

As you would see the files live in the C drive, folder /pdf/
The database only store the paths and the viewer is actually a simple 'embed' tag that gets 'updated' every time you select a record from the database.

You could make it a lot more complex by using one of the many javascript libraries available online, such as the one I mentioned before.

:D

Re: Store PDF in database

PostPosted: Mon Dec 15, 2014 11:00 am
by dotchiejack
Stu,

For me it is evening now but i will test it out tomorrow morning but if it workks you are great
Thanks

Re: Store PDF in database

PostPosted: Tue Dec 16, 2014 1:15 am
by dotchiejack
Hello Stu,

I did what you said and the viewer works great, thank you for that.
I have another question
Is it possible that the PDF file stored in the database and in the textentry automaticly opens in the viewer?
That would be ideal

Thanks

Re: Store PDF in database

PostPosted: Tue Dec 16, 2014 7:19 am
by stu
Ok, to do that create a OLE field on your Database (maybe the example one) and then create a form so you can Add records to that field.

One you have your PDFs on the database change the example code of 'Select' button for something like:

Code: Select all
dbpPopupValueList "PDFS" "files" "Path" "Title" "Left=8;Top=31;Width=184;RowCount=7" "[FILE]"
BrowserGoTo "WebBrowser2" "[PDFS.files.ActualFile]"


That will reload the browser with your selected PDF, thats because when your on one of your records the variable containing the binary data (PDF) will reconstruct the file on a temp directory. Something like: C:\Users\Username\AppData\Local\Temp\45905968.pdf

That's the way to go homie!

And last but not least I feel in the obligation of pointing the fact that storing files such as pdfs on a database its not a good idea. You could refer to this post for more info: viewtopic.php?f=21&t=20783 or even more info https://www.google.com/?gws_rd=ssl#q=st ... n+database