bullet_issue.docx (13.2 KB)
uploading docx then converting into html.after that converting to pdf.this is the total flows.am facing this issue with pdf only…while donwlonading as docx ,there is no issue
@farshadpalayil Unfortunately, I cannot reproduce the problem on my side. I used the following code for testing:
Document doc = new Document("C:\\Temp\\in.docx");
doc.save("C:\\Temp\\out.html");
doc = new Document("C:\\Temp\\out.html");
doc.save("C:\\Temp\\out.pdf");
out.pdf (20.9 KB)
this is my html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="generator" content="Aspose.Words for Java 23.8.0">
<title></title>
<style type="text/css">*::-webkit-scrollbar {
width: 7px;
height: 7px;
}
*::-webkit-scrollbar-track:vertical {
display: none;
opacity: 0;
transition: background-color .2s linear, opacity .2s linear;
-webkit-transition: background-color .2s linear, opacity .2s linear;
width: 10px;
right: 0;
position: absolute;
}
*::-webkit-scrollbar-track:horizontal {
display: none;
opacity: 0;
transition: background-color .2s linear, opacity .2s linear;
-webkit-transition: background-color .2s linear, opacity .2s linear;
height: 10px;
bottom: 0;
position: absolute;
}
*::-webkit-scrollbar-thumb {
background-color: #aaaaaa83;
border-radius: 6px;
transition: background-color .2s linear, width .2s ease-in-out;
-webkit-transition: background-color .2s linear, width .2s ease-in-out;
width: 6px;
right: 2px;
position: absolute;
}
*::-webkit-scrollbar-thumb:hover {
background-color: #999;
height: 11px;
}
html {
cursor: pointer;
}
body {
cursor: default;
}
li {
display: list-item !important;
}
.TableGrid.TableNormal {
word-wrap: break-word;
}
.cke_editable.cke_contents_ltr a[name] {
border: none !important;
background-image: none !important;
}</style>
</head>
<body style="line-height:108%; font-family:Calibri; font-size:11pt">
<div>
<ul type="disc" style="margin:0pt; padding-left:0pt">
<li style="margin-left:34pt; padding-left:2pt; font-family:serif; -aw-font-family:'Symbol'; -aw-font-weight:normal; -aw-number-format:''"><span style="font-family:Calibri">One</span></li>
<li style="margin-left:34pt; padding-left:2pt; font-family:serif; -aw-font-family:'Symbol'; -aw-font-weight:normal; -aw-number-format:''"><span style="font-family:Calibri">Two</span></li>
<li style="margin-left:34pt; margin-bottom:8pt; padding-left:2pt; font-family:serif; -aw-font-family:'Symbol'; -aw-font-weight:normal; -aw-number-format:''"><span style="font-family:Calibri">three</span></li>
</ul>
</div>
</body>
</html>
my code
public static byte[] convertHtmlToPdf(String htmlString) {
byte[] pdfBytes;
try {
try (var byteArrayOutputStream = new ByteArrayOutputStream()) {
InputStream targetStream = new ByteArrayInputStream(htmlString.getBytes(StandardCharsets.UTF_8));
Document document = convertIntoResponsiveDocument(targetStream);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setSaveFormat(SaveFormat.PDF);
document.save(byteArrayOutputStream, pdfSaveOptions);
pdfBytes = byteArrayOutputStream.toByteArray();
}
} catch (Exception exception) {
}
return pdfBytes;
}
private static Document convertIntoResponsiveDocument(InputStream targetStream) throws Exception {
Document document = new Document(targetStream);
LayoutCollector collector = new LayoutCollector(document);
LayoutEnumerator enumerator = new LayoutEnumerator(document);
for (Section section : document.getSections()) {
double maxTableWidth = 0;
for (Table table : section.getBody().getTables())
for (Row row : table.getRows()) {
enumerator.setCurrent(collector.getEntity(row.getFirstCell().getFirstParagraph()));
// Move enumerator to the row.
while (enumerator.getType() != LayoutEntityType.ROW)
enumerator.moveParent();
maxTableWidth = Math.max(maxTableWidth, enumerator.getRectangle().getWidth());
}
PageSetup pageSetup = section.getPageSetup();
double visiblePageWidth = pageSetup.getPageWidth() - pageSetup.getLeftMargin() - pageSetup.getRightMargin();
if (visiblePageWidth < maxTableWidth)
pageSetup.setPageWidth(maxTableWidth + pageSetup.getLeftMargin() + pageSetup.getRightMargin());
}
document.updatePageLayout();
return document;
}
Summary
This text will be hidden
@farshadpalayil Still cannot reproduce the problem. Please make sure the HTML string comes correctly. I have tested with the following code and your HTML and still output PDF looks fine:
List<String> lines = Files.readAllLines(Paths.get("C:\\Temp\\in.html"));
String htmlString = "";
for(String line : lines)
htmlString += line;
ByteArrayInputStream bis = new ByteArrayInputStream(htmlString.getBytes(StandardCharsets.UTF_8));
Document doc = new Document(bis);
doc.save("C:\\Temp\\out.pdf");
is there any dependency with server OS?
because am using windows OS,while testing from my system also there is no issue.
But while using non-production environment we are facing this bullet issue…how can i resolve this issue in production and non production…there we are using linux server
@farshadpalayil As I mentioned, I suspect the problem is in the input HTML string. Could you please make sure it is passed correctly in your Linux environment?
yeah…which is all good…my locally also which is working fine…but in linux server only we are facing issues…
@farshadpalayil Have you tried reading HTML from the file:
Document doc = new Document("in.html");
doc.save("out.pdf");
Does the problem occur in this case on Linux? Also, could you please attach PDF produced in Linux environment on your side?
bullet_issue_2023_10_30-22_26_56.pdf (20.9 KB)
am using document.save(byteArrayOutputStream, pdfSaveOptions); and then downloading
@farshadpalayil Thank you for additional information. As I can see bullets looks correct in the attached PDF document:
sorry by mistake,i have uploaded wrong attachemnt…will upload the correct one…
i tried to upload,but am facing some error while uploading…
403 Forbidden error showing
Processing: bullet_issue_2023_10_30-16_55_49.7z...
@farshadpalayil Unfortunately, the file was not uploaded properly. Please try uploading it one more time.
still i couldn’t upload the proper zip file
@farshadpalayil It is quite odd. I can successfully upload files to the forum. Could you please try uploading the file from other device? As an alternative you can upload the file to google drive and share a link here.
its showing permission issues. Could you please check my permission for upload a file?
@farshadpalayil You have standard basic user permissions, so there should not be any issues with uploading documents. If the problem still persist, please upload the file to google drive and share a link here.
am working in an organization.so i couldn’t upload in google drive…can u share support email id?i will sent through mail