Some equations don’t align in the same way as is displayed in the input file. attached the input and output file screenshots and file
code snippet:
String texFileName = getFileNameWithoutExtension(outputFileName) + TEX_EXTENSION;
String texFilePath = directoryPath + PATH_SEPARATOR + texFileName;
Files.copy(inputStream, Path.of(texFilePath), StandardCopyOption.REPLACE_EXISTING);
// Create Document object to load the LaTeX file
TeXLoadOptions teXLoadOptions = new TeXLoadOptions();
Document document = new Document(texFilePath, teXLoadOptions);
PdfPageEditor pageEditor = new PdfPageEditor();
pageEditor.bindPdf(document);
pageEditor.setPageSize(PageSize.getA4());
// Save to PDF
pageEditor.save(directoryPath + PATH_SEPARATOR + outputFileName);
pageEditor.close();
LOGGER.info(MessageConstants.CONVERTED_LATEX_TO_PDF);
dependency:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-total</artifactId>
<version>23.8</version>
<type>pom</type>
</dependency>
Endogenous investment.docx (599.7 KB)
@TandFSP
Please attach the input Tex file.
@TandFSP
I think you are using the Aspose.Words library?
Then the topic should be moved to the appropriate section.
There is no docx->TeX conversion in Pdf product family.
Hi @sergei.shibanov ,
it is docx to pdf only.
code snippet:
com.aspose.words.Document document = new com.aspose.words.Document(inputStream);
FontSettings fontSettings = FontSettings.getDefaultInstance();
com.aspose.words.FolderFontSource folderFontSource = new com.aspose.words.FolderFontSource(getFontDirectory(), true);
fontSettings.setFontsSources(new FontSourceBase[] { new SystemFontSource(), folderFontSource });
document.setFontSettings(fontSettings);
// document.updateTableLayout();
if (!StringUtils.isEmpty(runningHead))
{
HeaderFooter primaryHeader = document.getFirstSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_PRIMARY);
if (primaryHeader != null)
{
String primaryHeaderText = primaryHeader.getText();
if (!StringUtils.isEmpty(primaryHeaderText) && primaryHeaderText.toLowerCase().contains(runningHead.toLowerCase()))
primaryHeader.remove();
}
}
//justify the paragaraoh alignment
Iterable<Paragraph> paragraphs = document.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph p : paragraphs)
{
if (p.getParagraphFormat().getAlignment() == ParagraphAlignment.DISTRIBUTED)
p.getParagraphFormat().setAlignment(ParagraphAlignment.JUSTIFY);
}
// as per https://forum.aspose.com/t/blank-pages-are-added-in-file/270804?u=tandfsp to avoid new page added by section break
for (Section s : document.getSections())
{
int start = s.getPageSetup().getSectionStart();
if (start == SectionStart.EVEN_PAGE || start == SectionStart.ODD_PAGE)
s.getPageSetup().setSectionStart(SectionStart.NEW_PAGE);
}
if (removeWaterMark)
{
Watermark watermark = document.getWatermark();
if (watermark.getType() == WatermarkType.TEXT)
{
watermark.remove();
}
}
if (removeLineNumbers)
{
PageSetup pageSetup = document.getFirstSection().getPageSetup();
pageSetup.setLineNumberCountBy(0);
}
com.aspose.words.PdfSaveOptions pdfSaveOptions = new com.aspose.words.PdfSaveOptions();
pdfSaveOptions.setUpdateFields(false);
document.save(directoryPath + PATH_SEPARATOR + outputFileName, pdfSaveOptions);
LOGGER.info(MessageConstants.CONVERTED_WORD_TO_PDF);
input file:
Endogenous investment.docx (599.7 KB)
please check this as per the initial screenshots
@TandFSP
I will move this topic to the appropriate section - they will help you there.
@TandFSP
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-26096
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.
The issues you have found earlier (filed as WORDSNET-26096) have been fixed in this Aspose.Words for Java 24.5 update.
Excellent. Is this fix also be available on .Net ?
@TandFSP Yes, the issue is also resolved in .NET version of Aspose.Words. You can get the latest version from NuGet:
https://www.nuget.org/packages/Aspose.Words