HOW do you import a PDF from a URL

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
rbross
Posts: 441
Joined: Wed Nov 19, 2014 4:13 am
Location: Coventry, Connecticut USA

HOW do you import a PDF from a URL

Post by rbross »

1. Help says IMPORT DOCUMENT Statement.StatementDocument FROM 'c:/mydocuments/myfile.doc'
Can you use BO.Attribute that contains the path of the file to import the document or does it have to be a hard coded path?
2. Has anyone IMPORTED or download a PDF from a URL so it can be imported into a Document Attribute so it can be displayed on a form?
Roger Ross
AwareIM 8.7 (build 3025) ~ MS-SQL ~ Windows 10 ~
AwareIM 8.5 (build 2828) ~ MS-SQL ~ Windows 10 ~
weblike
Posts: 1165
Joined: Sun Dec 02, 2012 12:00 pm
Location: Europe

Re: HOW do you import a PDF from a URL

Post by weblike »

Hi,

Yes you can use an Attribute that contains the path and I suggest to do so.

I use this method in my apps. Also I do NOT recommend to store the documents in DB (the DB becomes huge and not good for the app).

In my apps I make a folder for each tenant and I store his documents in that folder.

MAKE DIRECTORY '<<SystemSettings.PDFInvoicesPath>>\'+CustomerCompanyBO.ID+'\DOCS'

I don't have time right now, but I can prepare a small bsv for you if you want, just let me know. Provide me details and I will do it closer to your needs (no charge).. :)

cheers,
Thx,
George
________________________________
Developer Edition
AwareIM: v8.5, build 2824
OS: Windows Server 2012
DB: MySql 5.6.42
CalD
Posts: 146
Joined: Sun May 08, 2016 10:20 pm

Re: HOW do you import a PDF from a URL

Post by CalD »

How can you download the pdf from a url and store it for future reference?
Roger is dealing with an API which provides a link to the PDF, but the link is temporary so we need to download it and store it for our own App to be able to access as needed in the future....

Cheers,
Callum
intra
Posts: 279
Joined: Thu Oct 11, 2012 1:30 pm
Location: Australia

Re: HOW do you import a PDF from a URL

Post by intra »

Is there supporting documentation of the API?

Interested.
Avid Linux user....
ACDC
Posts: 1143
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: HOW do you import a PDF from a URL

Post by ACDC »

Install "Curl" on your server (cURL is a free very powerful lightweight command line tool and library for transferring data with URLs.) https://curl.haxx.se/

Then use Execute Program in AwareIM , something like ' curl -O http://example.com/download/myfile.zip.' This will download the file to a folder and let you use IMPORT DOCUMENT in AwareiM

Familiarise yourself with all the command line options in Curl to achieve the correct command that matches the api you are interfacing to.
Jaymer
Posts: 2459
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: HOW do you import a PDF from a URL

Post by Jaymer »

George,
yes please.
start a demo BSV for dealing with PDFs.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
weblike
Posts: 1165
Joined: Sun Dec 02, 2012 12:00 pm
Location: Europe

Re: HOW do you import a PDF from a URL

Post by weblike »

Jaymer wrote:George,
yes please.
start a demo BSV for dealing with PDFs.
Hi,

In this scenario ACDC pointed very well how to download a PDF from a URL.

You have to install cURL on your system. It's very simple: https://www.youtube.com/watch?v=4QNWUbrLpCk

I have made a sample bsv to Roger, but this one contains particular things/links to his business, I cannot publish that. :)

I've talked with him today and he will publish the final bsv under TIPS&Tricks.

With PDF's you can have many scenarios. For example you can create them form your app, transforming a HTML report to PDF with a command line tool like https://wkhtmltopdf.org/ .

If you provide your specific scenario I will reply to your specific needs.

Cheers,
Thx,
George
________________________________
Developer Edition
AwareIM: v8.5, build 2824
OS: Windows Server 2012
DB: MySql 5.6.42
rbross
Posts: 441
Joined: Wed Nov 19, 2014 4:13 am
Location: Coventry, Connecticut USA

Re: HOW do you import a PDF from a URL

Post by rbross »

George,

Having an issue with MAKE DIRECTORY
I need to create the folders to store the PDF documents under the \C:\AwareIM\Tomcat\webapps\AwareIM\
So we can display the PDF in an iframe, the PDF needs to be located under the Tomcat folder
So the complete path would like like:
C:\AwareIM\Tomcat\webapps\AwareIM\PDFDocuments\Company#\Venue#
portion in red is what I need to create.
My Rule looks like this:
If Venues IS NEW OR Venues.PDFDocumentFolder IS UNDEFINED Then
MAKE DIRECTORY 'C:\AwareIM\Tomcat\webapps\AwareIM\PDFDocuments\'+Venues.sc_TenantID+'\'+Venues.ID
Venues.PDFDocumentFolder='C:\AwareIM\Tomcat\webapps\AwareIM\PDFDocuments'+Venues.sc_TenantID+'\'+Venues.ID

I get this error:
MakeDirError.JPG
MakeDirError.JPG (18.65 KiB) Viewed 14806 times
Roger Ross
AwareIM 8.7 (build 3025) ~ MS-SQL ~ Windows 10 ~
AwareIM 8.5 (build 2828) ~ MS-SQL ~ Windows 10 ~
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: HOW do you import a PDF from a URL

Post by BobK »

George,

Try using 2 MAKE DIRECTORY commands:

MAKE DIRECTORY 'C:\AwareIM\Tomcat\webapps\AwareIM\PDFDocuments\'+Venues.sc_TenantID
MAKE DIRECTORY 'C:\AwareIM\Tomcat\webapps\AwareIM\PDFDocuments\'+Venues.sc_TenantID+'\'+Venues.ID

That is how it worked back in 2009 see http://www.awareim.com/forum/viewtopic. ... ORY#p13778
Bob
Post Reply