Pls review bellow files, and kindly help with the defects(from docx to pdf). Thanks.
When I open the bellow docx in office 365 or mac, it looks good, bu not in office 2007.
After converting to pdf, from anywhere the pdf is much not the same as docx.
test updated.docx (112.0 KB)
test updated.pdf (105.2 KB)
@merlin1234
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): WORDSNET-25053
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.
@alexey.noskov
Thanks for putting the issue into the working list. Just a little curious, doens’t the ticket number start with WORDSJAVA as i am studiing java aspose words?
Per my digging, when I set the text wrapper outside the logo image to “in line with text” on the page header, it shows the right layout, anyway I can do that in java codes?
@merlin1234 Yes, the problem occurs because Aspose.Words does not support floating shapes in header/footer t the moment (as well as MS Word 2007). This feature has been added into MS word in 2013 version. We are currently work on it.
You can make shape inline by setting ShapeBase.WrapType to WrapType.INLINE
@merlin1234 The shape in the original document has negative left shift:
But when you make the shape inline, it is positioned according to the indent of it’s parent paragraph. So it is required to adjust the parent paragraph indent to get the correct result:
Document doc = new Document("C:\\Temp\\in.docx");
Iterable<HeaderFooter> headerFooters = doc.getChildNodes(NodeType.HEADER_FOOTER, true);
for (HeaderFooter hf : headerFooters)
{
Iterable<Shape> shapes = hf.getChildNodes(NodeType.SHAPE, true);
for (Shape s : shapes)
{
if (s.isTopLevel())
{
s.setWrapType(WrapType.INLINE);
Paragraph parent = s.getParentParagraph();
double newIndent = parent.getParagraphFormat().getLeftIndent() + s.getLeft();
parent.getParagraphFormat().setLeftIndent(newIndent);
}
}
}
doc.save("C:\\Temp\\out.docx");
doc.save("C:\\Temp\\out.pdf");
out.pdf (158.7 KB)
But please note the workaround will work only for this concrete document, when the shape is the only child of the paragraph.
Hi. @alexey.noskov
Really appreciate.
As we are pursuing a quick deployment, while we are waiting for the solid fix in your future release, we now want to make it work to all of our docx templates, so currently, the workaround is an acceptable way.
Could you also check with the below template for me? It seems WrapType.INLINE or not setting will miss some parts.
Original docx
22H-000014_RPT_updated.docx (1.6 MB)
Set WrapType.INLINE, no logo
Set WrapType.INLINE, no text “Test Report”
@merlin1234 The problem in this case occurs because there are 3 floating shapes in the same paragraph in the header and setting paragraph left margin shifts the shapes outside the page bounds. If use the following code and simply change the wrap type of the shapes, they are rendered:
Document doc = new Document("C:\\Temp\\in.docx");
Iterable<HeaderFooter> headerFooters = doc.getChildNodes(NodeType.HEADER_FOOTER, true);
for (HeaderFooter hf : headerFooters)
{
Iterable<Shape> shapes = hf.getChildNodes(NodeType.SHAPE, true);
for (Shape s : shapes)
{
if (s.isTopLevel())
{
s.setWrapType(WrapType.INLINE);
}
}
}
doc.save("C:\\Temp\\out.docx");
doc.save("C:\\Temp\\out.pdf");
But position is incorrect. I am afraid there is no programmatic workaround for this case. The only way to fix this is editing your template manually in MS Word and using table to place the shapes on the different sides of the page.
Hi, @alexey.noskov
Thanks.
That solution you suggests is the best we can get to, we decide to go with that path.
More suggestions I would like to hear from you are:
- Will the shape table feature be supported by this year?
- If I want to include a fonts folder, it has a large size(>500m) when I looked at C;/WINDWOS/FONTS/ , any suggestions if we can reduce the size or only use the ones that are necessary? We have multiple templates and still increasing, so it seems not a good way to overview every template and find the fonts it use.
Hi,@alexey.noskov:
if we are using ECS to deploy our application, where Aspose is included , any better way to manage Fonts resources supposed we have a reasonable size folder(resource)?
Could it be a configured resource or just use a relative path, or we can mount a resource folder, as I found from API documentation FontSourceBase looks not widely support different resources based on the container(like ECS)…
Thanks very much.
@merlin1234 If you are limited with disk space, you can store the fonts remotely and load them as StreamFontSource
. For example you can use StreamFontSource
for fonts stored in S3 like described here:
https://docs.aspose.com/words/net/integration-in-aws-lambda/#how-to-use-fonts-stored-in-s3-storage-in-aws-lambda
The example is in C#, but the main idea is the same for Java. The same approach can be used for fonts from other external sources.
Also, when you work with external font sources, it would be useful to cache font search information. Please see the following article for more information:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/#save-and-load-a-font-search-cache
1 Like
The issues you have found earlier (filed as WORDSNET-25053) have been fixed in this Aspose.Words for Java 23.5 update.