Page 1 of 1

Copy HTML files from Appery to access with api call

Posted: Fri Feb 06, 2015 5:34 am
by Aeneas McBurney

Is there a way to save or render html files including any css and font files to an area that can be then accessed by an api to convert to pdf? If I try and open an html file from the database it downloads it rather than displays the file.

Thanks,
Aeneas


Copy HTML files from Appery to access with api call

Posted: Fri Feb 06, 2015 7:01 am
by Evgene Karachevtsev

Hello Aeneas,

1) You can add HTML component and set there any html structure you want, because we don't know how you are trying to convert it to pdf.
2) Yes if you make a call to DB collection Files, it will download it to the app, but you can parse it somehow, or try to set as innerHTML property of preinstalled HTML(div) component


Copy HTML files from Appery to access with api call

Posted: Fri Feb 06, 2015 7:16 am
by Aeneas McBurney

Thanks for your reply.

The API accepts a url to an html file. If I send the database file path it doesn't work and if I just pass the html string the css and font files don't get referenced. Is there somewhere I can put these file to then send url reference to API to convert?


Copy HTML files from Appery to access with api call

Posted: Tue Feb 10, 2015 1:32 am
by Yurii Orishchuk

Hi Aeneas,

Please specify details where you do you use this file.. Is this iframe, or other DOM-based HTML system or something else?

Regards.


Copy HTML files from Appery to access with api call

Posted: Tue Feb 10, 2015 1:39 am
by Aeneas McBurney

Hi, yes I want to use it in an external API call.

Eg this doesn't work using the below file link.....

http://api.page2images.com/restfullin...


Copy HTML files from Appery to access with api call

Posted: Thu Feb 12, 2015 12:28 am
by Yurii Orishchuk

Hi Aeneas,

unfortunatly we don't know about this 3rd party api..

It seems this api does not load external resources(like CSS and JS).

Please learn about this api may be there should be specified some additional parameters like "load external resources".

Regards.


Copy HTML files from Appery to access with api call

Posted: Thu Feb 12, 2015 3:11 am
by Aeneas McBurney

Leaving the api aside is there a way to copy an html file to an area that you can open to view in a browser? If you reference the files database URL it downloads the file. I don't want this to happen as just want to view the html file.


Copy HTML files from Appery to access with api call

Posted: Fri Feb 13, 2015 3:19 am
by Yurii Orishchuk

Hi Aeneas,

Yes - you can create in App sources needed HTML file and then access this file.

See details:
http://prntscr.com/64g58i/direct

Then you can access this file with following URL:
http://appery.io/app/view/93534752-d9...

Regards.


Copy HTML files from Appery to access with api call

Posted: Fri Feb 13, 2015 3:31 am
by Aeneas McBurney

How do I copy these to app sources from my app at run time so they are available on the fly?


Copy HTML files from Appery to access with api call

Posted: Mon Feb 16, 2015 5:13 am
by Yurii Orishchuk

Hi Aeneas,

These files are static and could not be available to edit on runtime.

If you need to return dynamic HTML content you can use server script code for this goal.

Here is a simple server code that will return HTML:

precode

var responseBody = {},
requestParams = {},
paramKeys = request.keys();

for (var key = 0; key < paramKeys&#46;length; key++) {
requestParams[paramKeys[key]] = request&#46;get(paramKeys[key]);
}

&#47;&#47;Here you can specify your HTML code (for example you can fetch it from DB)&#46;
responseBody = "<html><head><title>Hello world</title></head><body>Hello world content</body></html>&quot

response&#46;success(responseBody, "text/html");

/code/pre

Note: currently this code uses static HTML content but you get it from DB or other API.

Regards.