We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Rtf to pdf content not rendered correctly

Hi,
Im having issue where the content in my rtf is rendered wrongly in my pdf.

the value supposed to be
2. 70MM X 1,515MM X C - QTY:200MT AT USD964/MT
but after convert to pdf it become
3. 70MM X 1,515MM X C - QTY:200MT AT USD964/MT

I’m currently using aspose-words-17.5-jdk16…I tried to replace it with aspose-words-22.2-jdk16.jar,however this issue still exist

aspose render.zip (65.1 KB)

@senyee89 Unfortunately, I cannot reproduce the problem on my side. I have used the following simple code for testing:

Document doc = new Document(@"C:\Temp\Document.rtf");
doc.Save(@"C:\Temp\out.pdf");

Could you please attach your output PDF and code, which will allow us to reproduce the problem? We will check the problem once again and provide you more information.

Hi,

These are the code

    try {
        Document doc = new Document( new ByteArrayInputStream( input ) );

        byte[] watermarkHeader;
        byte[] watermarkFooter;
        log.info( "IslamAcc >>> " + islamicAcc );
        if ( islamicAcc ) {
            // islamic logo
            watermarkHeader = resources.getLogo2( );
            watermarkFooter = resources.getFooter_i( );
        } else {
            // conventional logo
            watermarkHeader = resources.getLogo( );
            watermarkFooter = resources.getFooter_c( );
        }

        parser.addAsposeHeader( doc, watermarkHeader );
        parser.addAsposeFooter( doc, watermarkFooter );
        String fontPath = resourceManager.get( "aspose.font.path" );
        FontSettings.getDefaultInstance( ).setFontsFolder( fontPath, true );

        // Save document to Pdf file format
        doc.save( outputStream, SaveFormat.PDF );
    } catch ( Exception e ) {
        log.error( "Exception in asposeConvertRtf2Pdf ", e );
    }

tf_view_advice.zip (74.7 KB)

@senyee89 Thank you for additional information. As I can see you are using quite old 17.5 version of Aspose.Words for Java. I have tested with the latest 22.2 version of Aspose.Words for Java and the problem is not reproducible. Please try using the latest version and let us know if the problem still persist on your side.

Hi,
As I mentioned I already replace it with aspose-words-22.2-jdk16.jar,however the same issue still exist

@senyee89 Could you please attach the output document produced by the latest 22.2 version of Aspose.Words for Java. Also, please attach the fonts you are using for conversion and XPS output, so we can deeper analyze the problem.

Downloads.zip (649.5 KB)

I’m not sure what font is using…but i will upload the font folder based on the fontpath mentioned in code to you and the output product by latest version.

@senyee89 Courier New font is used in your PDF document. Please see the attached screenshot:

@alexey.noskov hi, any updates on this issue?

@senyee89 Unfortunately, I do not see the requested resources for further issue analysis. Please attach the output document produced by the latest 22.2 version of Aspose.Words for Java. Also, please attach the fonts you are using for conversion and XPS output.

Sorry, i attached the wrong attachment .font n output.zip (144.1 KB)

the font folder too big, i cant upload all…these are the contents in the folder.do let me know which folder u will need?

@senyee89 Thank you for additional information Please attach your Courier New font. As I can see this is the only font used for rendering the text.
Also, please convert your document to XPS on your side and attach the output file here. You should zip it to upload.

render issue 20220304.zip (3.4 MB)

i tried to convert the pdf to xps from aspose tools. not sure is it the correct way to do so.

@senyee89 Thank you for additional information. But unfortunately, I still cannot reproduce the problem on my side. To convert document to XPS you should simply specify XPS extension or use SaveFormat.XPS. Could you please try converting your document using the following simple code:

Document doc = new Document("C:\\Temp\\in.rtf");
doc.setFontSettings(new FontSettings());
doc.getFontSettings().setFontsFolder("C:\\Temp\\fonts\\", true);
doc.save("C:\\Temp\\out.pdf");
doc.save("C:\\Temp\\out.xps");

where "C:\\Temp\\fonts\\" contains fonts you have attached.

20220307 render.zip (485.8 KB)

Hi, i’ve attached the rtf file, pdf and xps file.

@senyee89 Finally I have managed to reproduce the problem on my side with the document you have recently attached. The document is actually TXT document and upon loading Aspose.Words mistakenly detects numbers with decimal point as list items. The problem has been logged as WORDSNET-23562. We will keep you informed and let you know once it is resolved.
As a temporary workaround, you can use DocumentBuilder and insert TXT content into the document instead of loading TXT document. For example see the following code:

String fileName = "C:\\Temp\\TRJBU054933.rtf";
if(FileFormatUtil.detectFileFormat(fileName).getLoadFormat() == LoadFormat.TEXT)
{
    DocumentBuilder builder = new DocumentBuilder();
    builder.write(Files.readString(Path.of(fileName)));
    builder.getDocument().save("C:\\Temp\\out.pdf");
}