Skip to main content
Known Participant
October 23, 2024
Question

creating a word document using coldfusion

  • October 23, 2024
  • 2 replies
  • 412 views

Hello

 

I havent been using ColdFusion for years. Not a novice but after more than 10 years it would be true to say probably very rusty and not up to date on CF best practices.

 

I havea requirement to create a document (well parts of the document using ColdFusion).

 

I essentially want to creat a document that has a fair amout of text in it (i want to create a contract between half a dozen people - I will get the names of the people using a query and the results of the query will then be available to include in various places in the document.

 

Thanks in advance for any tips on the best way to do this.

 

 

    This topic has been closed for replies.

    2 replies

    Paolo Olocco
    Participating Frequently
    October 26, 2024

    Hi, if you want is it possible to use Java Apache POI but the best way is to choose PDF alternative.

    Here a sample guide in Java https://www.baeldung.com/java-microsoft-word-with-apache-poi

    BKBK
    Community Expert
    Community Expert
    October 23, 2024

    I would suggest you create not a Word document, but an HTML document instead. Create it within a CFM page, of course, perhaps using an HTML form or table. Use CSS to style the HTML to your needs.

     

    I am assuming that you wish to generate a separate contract for each user. You could, for each user, use a query to fetch the details of the user from the database and populate the fields in the HTML. You could then generate a PDF from the HTML using cfdocument or cfhtmltopdf.

     

    In an application I worked on years ago, the signature of each user had been recorded beforehand and stored in the database as a small image. The image had the same dimensions for each and every user.  The image would be obtained from the database, and the <img> tag was used to place it on the precise signature-location in an HTML document.

     

    Nowadays it is customary to digitally documents (even after they've been manually signed). You can use cfpdf to digitally sign PDFs.