Hi Team,
i an using a placeholder <<[investmentObj] -html>> in doc file to read the html content where its works in local machine but when deployed to server the bullet points not coming in desired format bullet point get replaced with ?. attached the snap of both and highlighted in yellow color-
notWorkingSnap
workingSnap
Below is the html object -
"investmentObj": "<!DOCTYPE html ><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta charset=\"UTF-8\" /><title></title><meta name=\"Generator\" content=\"PowerTools for Open XML\" /><style>span { white-space: pre-wrap; }\r\ntable.pt-000000 {\r\n border-collapse: collapse;\r\n border: none;\r\n margin-left: 0;\r\n margin-bottom: .001pt;\r\n}\r\ntr.pt-000001 {\r\n height: 0.86in;\r\n}\r\ntd.pt-000002 {\r\n vertical-align: top;\r\n width: 255.6pt;\r\n border-top-style: none;\r\n padding-top: 0;\r\n border-right-style: none;\r\n padding-right: 5.4pt;\r\n border-bottom-style: none;\r\n padding-bottom: 0;\r\n border-left-style: none;\r\n padding-left: 5.4pt;\r\n}\r\np.pt-Normal {\r\n margin-bottom: 0;\r\n text-align: justify;\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 10pt;\r\n line-height: 108%;\r\n margin-top: 0;\r\n margin-left: 0;\r\n margin-right: 0;\r\n}\r\nspan.pt-DefaultParagraphFont {\r\n color: #000000;\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 10pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n}\r\nspan.pt-DefaultParagraphFont-000003 {\r\n color: #000000;\r\n \r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 10pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n}\r\np.pt-Normal-000004 {\r\n margin-bottom: 0;\r\n text-align: justify;\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 11pt;\r\n line-height: 108%;\r\n margin-top: 0;\r\n margin-left: 0;\r\n margin-right: 0;\r\n}\r\nspan.pt-000005 {\r\n color: #000000;\r\n font-size: 11pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n}\r\ntd.pt-000006 {\r\n vertical-align: top;\r\n width: 261pt;\r\n border-top-style: none;\r\n padding-top: 0;\r\n border-right-style: none;\r\n padding-right: 5.4pt;\r\n border-bottom-style: none;\r\n padding-bottom: 0;\r\n border-left-style: none;\r\n padding-left: 5.4pt;\r\n}\r\nspan.pt-DefaultParagraphFont-000007 {\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 10pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n}\r\np.pt-000008 {\r\n margin-bottom: 0;\r\n margin-left: 0.10in;\r\n text-indent: -0.10in;\r\n text-align: justify;\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 11pt;\r\n line-height: 108%;\r\n margin-top: 0;\r\n margin-right: 0;\r\n}\r\nspan.pt-000009 {\r\n color: black;\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 11pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n display: inline-block;\r\n text-indent: 0;\r\n width: 0.100in;\r\n}\r\np.pt-000010 {\r\n margin-bottom: 0;\r\n margin-left: 0.10in;\r\n text-indent: -0.10in;\r\n text-align: justify;\r\n font-family: 'Arial', 'sans-serif';\r\n font-size: 11pt;\r\n line-height: 108%;\r\n margin-top: 0;\r\n margin-right: 0;\r\n}\r\np.pt-Normal-000011 {\r\n line-height: 107.9%;\r\n margin-bottom: 8pt;\r\n text-align: justify;\r\n font-family: Calibri;\r\n font-size: 11pt;\r\n margin-top: 0;\r\n margin-left: 0;\r\n margin-right: 0;\r\n}\r\nspan.pt-000012 {\r\n font-size: 11pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n}\r\nbody { margin: 0.01cm auto; max-width: 20cm; padding: 0; }</style></head><body><div><div align=\"left\"><table dir=\"ltr\" class=\"pt-000000\"><tr class=\"pt-000001\"><td class=\"pt-000002\"><p dir=\"ltr\" class=\"pt-Normal\"><span xml:space=\"preserve\" class=\"pt-DefaultParagraphFont\">The </span><span class=\"pt-DefaultParagraphFont-000003\">Test Fund</span><span xml:space=\"preserve\" class=\"pt-DefaultParagraphFont\"> seeks to match the performance and overall characteristics of the </span><span class=\"pt-DefaultParagraphFont-000003\">S&P 500 Index</span><span xml:space=\"preserve\" class=\"pt-DefaultParagraphFont\"> in a risk-controlled, cost-effective manner.</span></p><p dir=\"ltr\" class=\"pt-Normal-000004\"><span xml:space=\"preserve\" class=\"pt-000005\"> </span></p><p dir=\"ltr\" class=\"pt-Normal-000004\"><span xml:space=\"preserve\" class=\"pt-000005\"> </span></p></td><td class=\"pt-000006\"><p dir=\"ltr\" class=\"pt-Normal\"><span class=\"pt-DefaultParagraphFont\">The Fund's approach to quality indexing aims to</span><span class=\"pt-DefaultParagraphFont-000007\">:</span></p><p dir=\"ltr\" class=\"pt-000008\"><span class=\"pt-000009\">â˘</span><span class=\"pt-DefaultParagraphFont\">Minimize tracking error</span></p><p dir=\"ltr\" class=\"pt-000008\"><span class=\"pt-000009\">â˘</span><span class=\"pt-DefaultParagraphFont-000007\">Manage transaction costs</span></p><p dir=\"ltr\" class=\"pt-000010\"><span class=\"pt-000009\">â˘</span><span class=\"pt-DefaultParagraphFont-000007\">Utilize a full replication approach</span></p></td></tr></table></div><p dir=\"ltr\" class=\"pt-Normal-000011\"><span xml:space=\"preserve\" class=\"pt-000012\"> </span></p></div></body></html>"
@aspwanupsinha I have tested the scenario on my side and unfortunately, cannot reproduce the problem. Here is the test code:
String investmentObj = "<!DOCTYPE html ><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta charset=\"UTF-8\" /><title></title><meta name=\"Generator\" content=\"PowerTools for Open XML\" /><style>span { white-space: pre-wrap; }\r\ntable.pt-000000 {\r\n border-collapse: collapse;\r\n border: none;\r\n margin-left: 0;\r\n margin-bottom: .001pt;\r\n}\r\ntr.pt-000001 {\r\n height: 0.86in;\r\n}\r\ntd.pt-000002 {\r\n vertical-align: top;\r\n width: 255.6pt;\r\n border-top-style: none;\r\n padding-top: 0;\r\n border-right-style: none;\r\n padding-right: 5.4pt;\r\n border-bottom-style: none;\r\n padding-bottom: 0;\r\n border-left-style: none;\r\n padding-left: 5.4pt;\r\n}\r\np.pt-Normal {\r\n margin-bottom: 0;\r\n text-align: justify;\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 10pt;\r\n line-height: 108%;\r\n margin-top: 0;\r\n margin-left: 0;\r\n margin-right: 0;\r\n}\r\nspan.pt-DefaultParagraphFont {\r\n color: #000000;\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 10pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n}\r\nspan.pt-DefaultParagraphFont-000003 {\r\n color: #000000;\r\n \r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 10pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n}\r\np.pt-Normal-000004 {\r\n margin-bottom: 0;\r\n text-align: justify;\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 11pt;\r\n line-height: 108%;\r\n margin-top: 0;\r\n margin-left: 0;\r\n margin-right: 0;\r\n}\r\nspan.pt-000005 {\r\n color: #000000;\r\n font-size: 11pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n}\r\ntd.pt-000006 {\r\n vertical-align: top;\r\n width: 261pt;\r\n border-top-style: none;\r\n padding-top: 0;\r\n border-right-style: none;\r\n padding-right: 5.4pt;\r\n border-bottom-style: none;\r\n padding-bottom: 0;\r\n border-left-style: none;\r\n padding-left: 5.4pt;\r\n}\r\nspan.pt-DefaultParagraphFont-000007 {\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 10pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n}\r\np.pt-000008 {\r\n margin-bottom: 0;\r\n margin-left: 0.10in;\r\n text-indent: -0.10in;\r\n text-align: justify;\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 11pt;\r\n line-height: 108%;\r\n margin-top: 0;\r\n margin-right: 0;\r\n}\r\nspan.pt-000009 {\r\n color: black;\r\n font-family: 'Arial Narrow', 'sans-serif';\r\n font-size: 11pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n display: inline-block;\r\n text-indent: 0;\r\n width: 0.100in;\r\n}\r\np.pt-000010 {\r\n margin-bottom: 0;\r\n margin-left: 0.10in;\r\n text-indent: -0.10in;\r\n text-align: justify;\r\n font-family: 'Arial', 'sans-serif';\r\n font-size: 11pt;\r\n line-height: 108%;\r\n margin-top: 0;\r\n margin-right: 0;\r\n}\r\np.pt-Normal-000011 {\r\n line-height: 107.9%;\r\n margin-bottom: 8pt;\r\n text-align: justify;\r\n font-family: Calibri;\r\n font-size: 11pt;\r\n margin-top: 0;\r\n margin-left: 0;\r\n margin-right: 0;\r\n}\r\nspan.pt-000012 {\r\n font-size: 11pt;\r\n font-style: normal;\r\n font-weight: normal;\r\n margin: 0;\r\n padding: 0;\r\n}\r\nbody { margin: 0.01cm auto; max-width: 20cm; padding: 0; }</style></head><body><div><div align=\"left\"><table dir=\"ltr\" class=\"pt-000000\"><tr class=\"pt-000001\"><td class=\"pt-000002\"><p dir=\"ltr\" class=\"pt-Normal\"><span xml:space=\"preserve\" class=\"pt-DefaultParagraphFont\">The </span><span class=\"pt-DefaultParagraphFont-000003\">Test Fund</span><span xml:space=\"preserve\" class=\"pt-DefaultParagraphFont\"> seeks to match the performance and overall characteristics of the </span><span class=\"pt-DefaultParagraphFont-000003\">S&P 500 Index</span><span xml:space=\"preserve\" class=\"pt-DefaultParagraphFont\"> in a risk-controlled, cost-effective manner.</span></p><p dir=\"ltr\" class=\"pt-Normal-000004\"><span xml:space=\"preserve\" class=\"pt-000005\"> </span></p><p dir=\"ltr\" class=\"pt-Normal-000004\"><span xml:space=\"preserve\" class=\"pt-000005\"> </span></p></td><td class=\"pt-000006\"><p dir=\"ltr\" class=\"pt-Normal\"><span class=\"pt-DefaultParagraphFont\">The Fund's approach to quality indexing aims to</span><span class=\"pt-DefaultParagraphFont-000007\">:</span></p><p dir=\"ltr\" class=\"pt-000008\"><span class=\"pt-000009\">â˘</span><span class=\"pt-DefaultParagraphFont\">Minimize tracking error</span></p><p dir=\"ltr\" class=\"pt-000008\"><span class=\"pt-000009\">â˘</span><span class=\"pt-DefaultParagraphFont-000007\">Manage transaction costs</span></p><p dir=\"ltr\" class=\"pt-000010\"><span class=\"pt-000009\">â˘</span><span class=\"pt-DefaultParagraphFont-000007\">Utilize a full replication approach</span></p></td></tr></table></div><p dir=\"ltr\" class=\"pt-Normal-000011\"><span xml:space=\"preserve\" class=\"pt-000012\"> </span></p></div></body></html>";
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("<<[investmentObj] -html>>");
ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, investmentObj, "investmentObj");
doc.save("/temp/out_linux.docx");
In both Windows and Linux environments bullets are shown properly.
As I can see in your HTML you use span
with bullet symbol to emulate list items:
<p dir=\"ltr\" class=\"pt-000010\"><span class=\"pt-000009\">â˘</span><span class=\"pt-DefaultParagraphFont-000007\">Utilize a full replication approach</span></p>
Have your tried using regular <ul>
and <li>
HTML list.
Hi Team, If i am using <ul><li>
tag then its working as expected, but in our scenario we are converting a doc file to html using some plugin and somehow that unable to create the tags for bullet points and bullent special char. But wondering how it works for you in linux/unix env as our deployment server is same but its not working.
One more issue we found if we pass any word with apostrophe like : Administrationâs then in generated document it prints with ? like : Administration?s.
i am using aspose word 23.3 linq engine here and placeholder like : <<[investmentObj] -html>>
. here interesting fact is while i am getting apostrophe in html file or contenets then getting ? but at the same time if i am using plain text without html the its working fine and agains these issued are when in trying in deployed server in local env its all good
@aspwanupsinha What is your output document format? Could you please attach your actual output document here for our reference? Also, please make sure the mentioned characters are shown properly in the HTML string passed to Aspose.Words.
Output document format is PDF.
Here actually we are converting .docx file to html using Aspose html converter (Convert DOCX To HTML Java and then using the same .html to generate the document. And for this we are using linq engine syntax <<[investmentObj] -html>> in our word template.
attached the docx,html and generted doc screenshot below, please let me know if anything else needed from my side. It gives ? against ââ â and few other special character as well. Please look into this as this became a big blocker in our delivery now.
test-docs.zip (54.3 KB)
@aspwanupsinha Thank you for additional information, but could you please attach an actual PDF or XPS output document here for our reference. Unfortunately, screenshot does not allow to analyze the problem and I cannot reproduce the problematic output on my side using the provided input.
As you requested please find the attached pdf, Go Through the Investment Objective section where we tried to read the html content, and you will find ? against the special char and bullet points.
405_Test_20230608.pdf (90.0 KB)
@aspwanupsinha Thank you for additional information. As I can see Fonwood
font is used in your document. This font is used by Aspose.Words when no other alternative fonts are available in the environment.
To build an accurate document layout the fonts are required. If Aspose.Words cannot find the fonts used in the document the fonts are substituted . This might lead into the layout and appearance difference. You can implement IWarningCallback to get a notification when font substitution is performed.
The following articles can be useful for you:
https://docs.aspose.com/words/java/specify-truetype-fonts-location/
https://docs.aspose.com/words/java/install-truetype-fonts-on-linux/
Please try either installing or providing the fonts required to render the document. This should resolve the problem.
Attached the template i am using and where i am using font : Arial Narrow i dont see anywhere i a using âFonwoodâ and even dont see this font in html files. So could you please let me know from where you get this font.
M_Equity_Domestic_JB_AsposeTest_Template.docx (5.2 MB)
@aspwanupsinha Yes, you are right, your document does not use Fonwood
. This font is embedded into Aspose.Words and is used as a last resort font, when Aspose.Words cannot font an alternative font for rendering document. Please try implementing IWarningCallback to get a notification when Aspose.Words performs font substitution. This will get you a hint what font is missed.
Hi Team,
I tested it out its not a font issue, the issue with chars (â â and â ) which are not supported by aspose at Unix/Linux env probably. Our Application is hosted in Google App engine conatiner and their we seeing this issue and in local its working fine.
For example test with this example string in aspose word with linq placeholder
Sample string : Tetâs Testinâg âFâund
attaches the output screenshot gainst the above test below -
Please share some idea how we can fix this, as due to this issue only we are unable to promote our code in higher env.
@aspwanupsinha Unfortunately, I still cannot reproduce the problem on my side. Here is test code I have used in Linux:
String test = "Tetâs Testinâg âFâund";
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("<<[test]>>");
ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, test, "test");
doc.save("/temp/out_linux.pdf");
Here is the produced output: out_linux.pdf (10.2 KB)
Could you please make sure the string is properly read from the data source and and the passes string contains proper characters. This looks like string encoding issue.
I have managed to produce incorrect output if read the string from file without specifying the encoding:
String test = new String(Files.readAllBytes(Paths.get("/temp/test.txt")));
out_linux_bad.pdf (11.1 KB)
But the output is correct if specify correct encoding:
String test = new String(Files.readAllBytes(Paths.get("/temp/test.txt")), StandardCharsets.UTF_8);
we are using JsonDataSource here, how to add correct encoding?
String data = {} // json data
InputStream jsonIS = new ByteArrayInputStream(data.getBytes());
JsonDataLoadOptions options = new JsonDataLoadOptions();
options.setSimpleValueParseMode(1);
JsonDataSource jsonDataSource=new JsonDataSource(jsonIS,options);
// Create a Reporting Engine.
ReportingEngine engine = new ReportingEngine();
engine.setOptions(ReportBuildOptions.ALLOW_MISSING_MEMBERS);
engine.buildReport(doc, jsonDataSource);
@aspwanupsinha We have managed to reproduce the problem with JsonDataSource
.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSJAVA-2868
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
do we have nay update on Issue ID(s): WORDSJAVA-2868
as we started getting ? for ÂŽ char/symbol.
@aspwanupsinha Unfortunately there are no news regarding WORDSJAVA-2868. The issue is currently in the queue for analysis. I have asked the responsible developer to take a look at it shortly. Please accept our apologies for your inconvenience.
we are using your licensed product for one of our key deliveries and for us this becomes a major issue, So I would request please look into this issue asapâŚ
@aspwanupsinha We will keep you updated and let you know once the issue is resolved or we have more information for you. Once again, please accept our apologies for your inconvenience.
do we have any alternate way to fix this now as we need to present this higher team?
Note we are getting ? against symbol - ÂŽ â˘
@aspwanupsinha Unfortunately, there is no workaround of this issue yet. The issue is currently in analysis. Once analysis is done we will provide you a fix or propose a workaround.