Table alignment in Aspose.Words generated PDF


#1

I’m having the exact same issue, was it resolved in some newer versoin ? is there a way to overcome it in the problematic version (i.e. 18.6 ) ?
thanks.


Table cells with Wrapped text do not auto resize in PDF
#2

@danielshmaya,

Please ZIP and upload your input Word document and Aspose.Words 19.7 generated PDF file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.


#3

I have only 18.2 version of aspose so I can’t send file generated in later version , I just wanted to know if this issue was fixed in later version .
any way I’m attaching 2 documents word and PDF, both were created using same aspose api,
while the word document autofit worked prperly but the pdf didn’t .
by the way when converting binaries of the created word document to pdf, the pdf file is saved correctly. but this way I have the overhaed of saving the doc as word and then I have to create new document for the pdf using the word doc as inputstream which might consume more memory and processing time which is problemtic for very large documents.
docs-examples.zip (102.8 KB)


#4

I was able to reproduce on 19.7 , see attached files. I guess it wasn’t solve also in the latest version of aspose …doc-example2.zip (99.8 KB)


#5

@danielshmaya,

After an initial test with the licensed latest version of Aspose.Words for Java i.e. 19.7, we were unable to reproduce this issue on our end. Please see this output PDF (awjava-19.7.pdf (1.6 MB)) that we generated from “Octane_backlog items_by_rest_api (7).docx” by using the following simple code:

Document doc = new Document("E:\\doc-example2\\Octane_backlog items_by_rest_api (7).docx");
doc.save("E:\\doc-example2\\awjava-19.7.pdf");

So, we would suggest you please upgrade to the latest version of Aspose.Words for Java. Hope, this helps.


#6

hi thanks for the fast reply,
yet I want again to make it clear, as I mentioned in my previioes replay of this thread :

by the way when converting binaries of the created word document to pdf, the pdf file is saved correctly. but this way I have the overhaed of saving the doc as word and then I have to create new document for the pdf using the word doc as inputstream which might consume more memory and processing time which is problemtic for very large documents.

in shortly, same code : save as word vs save as pdf produce different result file.
and another side efect of such case is that calling to getPageCount result with incorrect number (actulay the number of pages with autofit problem).

if you need more info let me know.
thanks,


#7

@danielshmaya,

Can you please list the steps that we can follow on our end to reproduce the same issue (same output as can be seen in your ‘Octane_backlog items_by_rest_api (13).pdf’)? Also, please share simplified source code to reproduce the problem on our end. Thanks for your cooperation.


#8

sure adding simple implemintation , just run main function it will :

  • create document with some table includes one column contain very long word
  • save as docx and count pages
  • save as pdf and count pages
  • save as docx , convert it to pdf and count pages

output of this function :

pageCount for c:\temp\test_doc.pdf = 3
pageCount for c:\temp\test_doc.docx = 3
pageCount before conversion = 3
pageCount after conversion = 6

thanks.
WordWriter.zip (2.4 KB)


#9

@danielshmaya,

We are working on your query and will get back to you soon.


#10

@danielshmaya,

Please call ‘updatePageLayout’ method inside the ‘createFile’ to get the equal number of page counts i.e. 6.

protected void createFile(String saveFilePath, int saveFormat) {
    try {
        if (SaveFormat.PDF == saveFormat) {
            saveFilePath += ".pdf";
        }
        if (SaveFormat.DOCX == saveFormat) {
            saveFilePath += ".docx";
        }
        wordDocument.save(saveFilePath, SaveOptions.createSaveOptions(saveFormat));
        wordDocument.updatePageLayout();
        System.out.println("pageCount for "+saveFilePath+" = " + getPagesCount(wordDocument));

    } catch (Exception e) {
        System.out.println("error at createFile");
    }
}

#11

looks like it solve my issue on the example code I gave you,

just small correction, putting the wordDocument.updatePageLayout(); after the wordDocument.save(…) does solve the count issue but not the malformed PDF.

In order to get correct PDF I had to put the wordDocument.updatePageLayout(); before the wordDocument.save(…).

Thanks very much for the help.


#12

@danielshmaya,

It is great that you were able to achieve what you were looking for. Please let us know any time you have any further queries.