Aeneas McBurney
Posts: 0
Joined: Mon Jun 16, 2014 7:49 am

Copy HTML files from Appery to access with api call

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Copy HTML files from Appery to access with api call

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

Aeneas McBurney
Posts: 0
Joined: Mon Jun 16, 2014 7:49 am

Copy HTML files from Appery to access with api call

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?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Copy HTML files from Appery to access with api call

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.

Aeneas McBurney
Posts: 0
Joined: Mon Jun 16, 2014 7:49 am

Copy HTML files from Appery to access with api call

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...

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Copy HTML files from Appery to access with api call

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.

Aeneas McBurney
Posts: 0
Joined: Mon Jun 16, 2014 7:49 am

Copy HTML files from Appery to access with api call

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.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Copy HTML files from Appery to access with api call

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.

Aeneas McBurney
Posts: 0
Joined: Mon Jun 16, 2014 7:49 am

Copy HTML files from Appery to access with api call

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Copy HTML files from Appery to access with api call

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.

Return to “Issues”