Display
Display

Reputation: 21

Result report conversion HTMLtoPDF in SerenityBDD framework using itextpdf

Hi have a Serenity BDD framework and I am trying to convert my index.html report to itextpdf but its not generating the report I have checked the paths and the java class but it not generating , I have added the necessary dependencies in pom.xml and java class

           <groupId>com.itextpdf</groupId>
           <artifactId>itext7-core</artifactId>
           <version>7.2.0</version>
           <type>pom</type>
       </dependency>
       <!-- iText HTML-to-PDF -->
       <dependency>
           <groupId>com.itextpdf</groupId>
           <artifactId>html2pdf</artifactId>
           <version>6.1.0</version>
       </dependency>````
**The java class added under utils folder-**
import com.itextpdf.html2pdf.HtmlConverter;
import java.io.*;
public class htmltopdf {
   public static void main(String[] args) {
       try {
           // Paths
           String htmlFilePath = "target/site/serenity/index.html";
           String pdfFilePath = "Serenity-Report.pdf";
           // Convert HTML to PDF
           HtmlConverter.convertToPdf(new File(htmlFilePath), new File(pdfFilePath));
           System.out.println("PDF generated successfully: " + pdfFilePath);
       } catch (Exception e) {
           e.printStackTrace();
       }
   }
}

Upvotes: 0

Views: 20

Answers (0)

Related Questions