Txt to PDF conversion issues


Hi, I am trying to convert a txt file to pdf format according to: Convert text to pdf
In the converted pdf file, the lines break not as they break in the text file. I suppose there is a configuration that should change the maximum row length but I couldn’t find such an option.
files.zip (64.1 KB)

I have also tried the option that written in https://github.com/aspose-pdf/Aspose.PDF-for-Java/blob/master/Examples/src/main/java/com/aspose/pdf/examples/AsposePdfExamples/DocumentConversion/ConvertTextFileToPDFFormat.java
and got a bad result:
output1.pdf (36.8 KB)

I would like to get help to find the right and best way to convert txt to pdf file.



Please ZIP and upload your input Text file here for testing. Please also provide a comparison screenshot highlighting the problematic areas in Aspose.Words generated PDF file and attach it here for our reference. Please point out the exact problematic places for this issue. We will then investigate the issue on our end and provide you more information.


Please see the attached zip files that contains that input, output and also some highlights (as png files). filesAndHighlights.zip (144.0 KB)

The second method of conversion as I write before was bad, this is the result: output1.pdf (36.8 KB)



Even MS Word 2019 will cause the same problem if you open this .txt file with MS Word 2019 and then ‘Save As’ to PDF. However, you can fix this issue by reducing the Left and Right Page margins by using the following Aspose.Words’ code:


Document doc = new Document(@"E:\filesAndHighlights\input.txt");

PageSetup ps = doc.FirstSection.PageSetup;
ps.LeftMargin = 0.36 * 72; // 0.5 inch
ps.RightMargin = 0.36 * 72;


Document doc = new Document("E:\\filesAndHighlights\\input.txt");

PageSetup ps = doc.getFirstSection().getPageSetup();
ps.setLeftMargin(0.36 * 72); // 0.5 inch
ps.setRightMargin(0.36 * 72);


Attachment: 19.8.pdf (30.0 KB)


Thanks, I hope this configuration will be good for additional text files that I will convert to pdf.



Aspose.Words tries to mimic the behavior of MS Word. Please let us know if you have any troubles in future and we will be glad to look into this further for you in case where Aspose.Words’ behavior differs to what MS Word produces.