Generate report

814
1
03-22-2017 09:00 AM
MateiAlexandra_Ioana
New Contributor

Hi ! I'm making a webgis application and  I want to generate a report (pdf or word document format), using a predefined template, and i want to populate it with data from attribute table. I must mention that I'm using javascript api and the application will be hosted on github, so I don't have a server. Is there a solution to do that?

Thank you

0 Kudos
1 Reply
ThomasSolow
Occasional Contributor III

As far as I know there isn't anything in the Esri JavaScript API to help you with this directly.

In JavaScript you can write text to a blob and save the blob as a file.  There are lot of hacky ways to do this in JavaScript (an alternate approach is this).  None of these are particularly elegant (at least that I'm aware of).  Check out the JavaScript File and Blob classes or data URI encoding for more information.

You could also use something like this, which should simplify things and support more (all?) browsers.

Since you're interested in .docx and/or pdf you're probably going to want to look for some other libraries, unless you want to learn the formats for those kinds of files and construct them manually. This looks promising for pdfs.  It looks like it allows you to write text and canvas to a pdf.

In general the file support in JavaScript is kind of a mess.  It's not hard to write something to a text file and "download" it to the user's file system, but anything other than that and I suspect you're going to have to pull in some libraries.

0 Kudos