I'm trying to generate a PDF file from HTML. I have two long URL in the HTML code. The problem is that just one URL (longURL2) is split to the next line. The other URL (longURL) exceeds the page margin. Could someone help me to figure out why iText does not split the other URL?
My code:
String longURL = "http://localhost/erp/process/see_process.jsp?vp=ATENDING_PROCESS_EMPLOYEE&tr=1493131180671041&ev=1520277948136217";
String longURL2 = "https://stackoverflow.com/questions/48422409/how-to-set-pdf-page-size-a4-when-we-use-itextrenderer-to-generate-pdf-from-thyme";
String htmlCode =
"<p align=\"right\">City Name - March, 5 \r\n2018.</p>"
+ "<p> </p>"
+ "<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sollicitudin consectetur vulputate. "
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Interdum et malesuada fames ac ante ipsum primis in faucibus."
+ "<br/><br/></p>"
+ "<p>" + longURL + "</p>"
+ "<p>" + longURL2 + "</p>"
+ "<p> </p>"
+ "<p> </p><center>"
+ "<p><b>My First Name \r\nLast Name</b><br>My Department</p>"
+ "</center>";
File dest = new File("C:/Temp/target_pdf_file.pdf");
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
pdf.setDefaultPageSize(PageSize.A4);
ConverterProperties converterProperties = new ConverterProperties();
FontProvider dfp = new DefaultFontProvider(true, true, true);
converterProperties.setFontProvider(dfp);
HtmlConverter.convertToPdf(htmlCode, pdf, converterProperties);