I have used java word package “16.7.0” to convert 506644822_VAULT.doc to 506644822_VAULT.pdf. The 506644822 line below bar code is missing in the pdf file. Seem like a bug in the word conversion package, please help to fix this issue.
My code:
String descPath = "c:\506644822_VAULT.pdf";
String srcFile = "c:\506644822_VAULT.doc";
DocumentBuilder builder;
// Load word file
com.aspose.words.Document dstDoc = null;
try
{
dstDoc = new com.aspose.words.Document(srcFile);
if (dstDoc == null)
{
return false;
}
createNewFile.debug("Converting to black font");
builder = new DocumentBuilder(dstDoc);
builder.getFont().setColor(Color.BLACK);
setNodesToBlack(dstDoc);
dstDoc.save(descPath, SaveFormat.PDF);
return true;
}
catch (Exception e)
{
lastMsg = String.format("%s failed. %s. ", saveOpts, e.getMessage());
createNewFile.error(lastMsg);
createNewFile.error(e);
return false;
}
finally
{
if (dstDoc != null)
{
// dstDoc.dispose();
dstDoc = null;
}
if (bDeleteSource)
{
deleteFile(srcFile);
}
}
Hi Brett,
Thanks for your inquiry. Please embed the fonts inside your input document and share it here for testing along with code of setNodesToBlack method. We will investigate the issue on our side and provide you more information. To embed a TrueType font in a saved document in Microsoft Office Word 2013, follow these steps:
- First, select the File option from the Word ribbon at the top of the screen.
- From the options bar on the left-hand side, choose Options.
- A Word Options window will come up. Select the Save option from the banner on the left-hand side.
- Under Preserve fidelity when sharing this document select the check box next to Embed fonts in the file. Then click OK.
Hi Tahir,
I attached original file with embed font. Below is the setNodesToBlack() method.
Thank you
Phillip Tran.
public boolean setNodesToBlack(CompositeNode parentNode) throws Exception
{
// This is the most efficient way to loop through immediate children of a node.
for (Node childNode = parentNode.getFirstChild(); childNode != null; childNode = childNode.getNextSibling())
{
// Do some useful work.
if (childNode.getNodeType() == NodeType.RUN)
{
// Say we found the node that we want, do something useful.
Run run = (Run)childNode;
run.getFont().setColor(Color.BLACK);
}
// Recurse into the node if it is a composite node.
if (childNode.isComposite())
setNodesToBlack((CompositeNode)childNode);
}
return true;
}
Hi Brett,
Thanks for sharing the detail. We have tested the scenario using latest version of Aspose.Words for Java 16.8.0 and have not found the shared issue. Please use Aspose.Words for Java 16.8.0. We have attached the output Pdf with this post for your kind reference.