Hi,
Can we convert .txt file to PDF through Aspose using Java code?
Hi,
Can we convert .txt file to PDF through Aspose using Java code?
Please check below documentation article that explains how to convert a .txt file into PDF using Aspose.PDF for Java:
Hi,
How to set font folder for Aspose PDF?
You can use below code snippet to set font folder in Aspose.PDF:
FontRepository.getSources().clear();
ArrayList<String> localFontPaths = new ArrayList<String>();
localFontPaths.add(dataDir + "customfonts\\");
FontRepository.setLocalFontPaths(localFontPaths);
FontRepository.reloadFonts();
Hi,
Using Aspose Pdf I have converted texts file to Pdf and one of the text file not converting properly.
Can we align the column text same as input text file?
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): PDFJAVA-42522
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.
Any update on this? Will there be any code solution?
The ticket has recently been logged in our issue management system. We will definitely look into its details and as soon as it is investigated, we will share updates with you. The solution to this requirement can be a new property in the API to handle such formatting from the .txt file. Nevertheless, we will let you know as soon as we make some progress towards ticket resolution. Please be patient and spare us some time.
We are sorry for the inconvenience.
I just wanted to know if it has any quick solution, but yes that explains. Thank you.
Hello, has this issue been fixed, yet?
Sadly, no updates are made yet towards ticket resolution. Your concerns have already been recorded and we will surely inform you once some progress is made in this regard. Please spare us some time.
We are sorry for the inconvenience.
For proper rendering of this text to PDF (or even viewing it in text editors), monospaced fonts should be used, such as “Consolas” or “Courier”. A list of popular monospaced fonts can be found here: List of monospaced typefaces - Wikipedia.
You can set the font using the following code: text.getTextState().setFont(new FontRepository().findFont(“Courier”));
If there is not enough space on the line to render all the text with the default font size, the font size should be decreased. Additionally, you can reduce the page margins. Please use the code below with all of these recommendations:
...
// Add a new page in Pages collection of Document
Page page = pdfDocument.getPages().add();
page.getPageInfo().getMargin().setLeft(30);
page.getPageInfo().getMargin().setRight(10);
// Create an instance of TextFragmet and pass the text from reader object to its
// constructor as argument
TextFragment text = new TextFragment(Files.readString(txtDocumentFileName, ENCODING));
text.getTextState().setFontSize(7);
text.getTextState().setFont(new FontRepository().findFont("Courier"));
...