Looking to analyze the differences between the word template and the PDF document

Looking for a way to compare two files (one in Word and one in PDF format) to ensure they contain the same information. The Word document will serve as a template for how the PDF should be generated. See below for examples of each:

Word doc:

    <firstname>,<LastName>
    <ID>,<organization>
    <salary>,<place>
    
    Dear <firstname>,
    you are working in the department of <organization> and we are really honored to have you here. Expecting many more successful years of service from you.
    Thanks,

Actual PDF:

    John, Kennedy
    234,google
    USD1245,CA
    
    Dear John,
    you are working in the department of google and we are really honored to have you here. Expecting many more successful years of service from you.
    Thanks,

Does anyone have a suggestion for a comparison logic to verify that both the static and dynamic content are being generated correctly? We are currently using TestComplete with JavaScript for automation.

Answer №1

To start constructing a PDF based on a template, it is advisable to first use regex splitting to isolate the variables in the template. By parsing the initial few lines for all relevant variables, you can then proceed to replace these placeholders with corresponding values extracted from the beginning of the PDF document. If the resulting text matches the content of the PDF, then the template has successfully been used to generate the PDF.

An illustration of how regex splitting can be applied: extract lines from a Word file, split each line, focus on the first three lines, separate them by commas, and assign the variables to their respective indexes. It is important to note that this approach only works if you have prior knowledge of the template structure.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Setting a default value in ng-options can be accomplished by using the ng-init

One way to set a dropdown list with a default value in AngularJS is by using the following code: <select name="repeatSelect" id="repeatSelect" ng-model="repeatSelect" ng-init="repeatSelect = data[0].id"> <option ng-repeat="option in data" val ...

Anticipate commitments during onbeforeunload

Is there a way to trigger a $http.get request when the page is closed? I encountered an issue where promises cannot be resolved because once the final method returns, the page is destroyed. The challenge lies in the fact that onbeforeunload does not wait ...

What is the best way to make multiple HTML tables sortable?

I recently implemented an open-source JavaScript table sorter in my project. You can find more information about it here: However, I encountered an issue where only the most recently added table on my page is sortable. When users press a button, new table ...

Adjust the appearance of input fields that exclusively have the value "1"

When designing my website, I encountered a problem with the style I chose where the number "1" looks like a large "I" or a small "L." I am wondering if there is a way to use JavaScript to dynamically change the font style for input fields that only contai ...

Use Node's express.static method to read and serve files from a specified

I am currently working on a Video Portal Project that involves organizing videos into different folders on the server. Utilizing nodejs technology, my goal is to create a function that can access and display all video content within a specific folder. A ...

Troubleshooting an issue with Laravel's Bootstrap 5.2 dropdown functionality

After setting up a pre-configured navbar from the Bootstrap website, I noticed that the dropdown feature is not working. This issue arose with the latest version of Bootstrap 5.2 which was integrated into my Laravel project without any modifications to the ...

Displaying the mean of data stored within an array, presented in a tabular format

Currently, I am attempting to utilize JavaScript to display the average value within a table. Below is the code that I have implemented. Within my code, I have included a for loop to iterate through the array. However, I am encountering an issue where onl ...

Using conditional logic to render components in VueJS

How can I conditionally display content in a parent component based on a user input variable? If the userinput variable is false, I want to remove the <div class="parent"> and show the PopUp component instead. I've tried using `v-if` ...

angular.js selected row in a table

I am facing an issue with a table that includes the ng-class directive in the following format: <tbody> <tr style="cursor: pointer" class="clickable-row" ng-repeat="firm in device.firmwares" ng-class="{'success': firm.vulnScore< ...

Retrieve content using Ajax request

Hey there, I've been tinkering with pure javascript to dynamically load content using AJAX without having to reload the entire page. document.getElementById('dashboard').addEventListener('click', dashboard); function dashboard(){ ...

Revamp the Design Layout of a Drag-and-Drop Tool

After experimenting with a drag and drop feature using jQuery, I discovered the following useful code snippet. Here's how it functions: $( "#sortable1, #sortable2" ).sortable({ connectWith: ".connectedSortable" }).disableSelection(); #so ...

Using pre-compiled values in an Angular directive within an ng-repeat loop

I'm currently working on a directive that should limit the text within an ng-repeat loop to 50 characters and add an ellipses if it exceeds this length. Here is how my ng-repeat is set up: <li ng-repeat="result in topSuggestions.suggestions"> ...

Tips for attaching inline styles to the body element with a vuejs component

I am new to vue.js and have been learning for a couple of days now. There are still some concepts that I am struggling to understand. I am currently working on creating a dropdown menu that appears when the user clicks on three dots. However, I am facing a ...

What is the best way to align columns after adding or deleting columns in an el-table using Element UI in Vue.js?

Is there a way to develop a table/datagrid using Element UI that allows users to choose which columns are displayed? I've already made an attempt, and you can find it here. I'm also looking for a solution that enables users to adjust the width o ...

How to keep text always locked to the front layer in fabric.js without constantly bringing it to the front

Is it possible to achieve this functionality without using the following methods? canvas.sendBackwards(myObject) canvas.sendToBack(myObject) I am looking to upload multiple images while allowing them to be arranged forward and backward relative to each o ...

I'm having trouble understanding the distinction between this.query and this.query.find(). Can you explain the difference to me?

Currently, I am working on a MERN tutorial where I am developing a full E-commerce application. This is the class that handles querying and various other tasks. constructor(query, querystr) { this.query = query; this.querystr = querystr; con ...

what is the best way to switch classes between 2 buttons using Angular8

Is there a way to create a toggle button effect that adds an 'active' class to BTN1 when it's clicked, and then removes the 'active' class from BTN1 and add it to BTN2 when BTN2 is clicked? Currently, my code only allows for addin ...

Updating the default color of selected text within a webpage's content

Is there a way to modify the default blue color that appears when content is selected on a webpage? I am wondering how to change this selection color to a custom color of choice. ...

I am having trouble retrieving dynamic values from a button using ajax. What could be causing this issue

I decided to create a unique dynamic button that utilizes ajax for calling when it's clicked. Each time the button is clicked, it pulls a fresh list of items from a specific website, resulting in its dynamic behavior. foreach($items as $item_link){ ...

Mastering Node.js: Writing to a Write Stream on the 'finish' Event

I'm currently using Node.js streams to process a text file line by line, apply some transformations, and then generate an SVG file based on the data. However, I am facing an issue where when I try to write the closing tag (</svg>) after all pro ...