Hi Team,
We are generating document using aspose java and once we generated the document we are saving same document as pdf but for one scenario the column which we appended for table is showing wrongly in pdf but in word it looks fine.
We are just saving document by using ByteArrayOutputStream by using below code.
Document document = getDocument(input); // untill here document looks good
ByteArrayOutPutStream outputStream = new ByteArrayOutPutStream();
document.save(outputStream,SaveFormat.PDF);
Thanks,
Priyanka.
@priyanka9 Unfortunately, it is impossible to analyze the problem using screenshots. Could you please attach your input and output document along with runnable code that will allow us to reproduce the problem.
Hi @alexey.noskov ,
I created project but unfortunately getting some PDF convertion error. But you can refer the file and cnvertion logic how we are doing.
aspose_test.zip (657.2 KB)
Thanks,
Aruna.
@priyanka9 Thank you for additional information. I do not see the problem you have shown on the screenshots above in the PDF document you have attached. In your code as I can see you are simply converting DOCX document to PDF. I have tested the scenario on my side and the produced PDF document also does not have the mentioned problem. So unfortunately I cannot reproduce the problem on my side.
Ok thanks @alexey.noskov ,
We will only check from our end.
1 Like
Hi Team,
Sometimes for few documents we are facing below issue and unable to replicate this issue through sample project. Can you please check and suggest some solution for us.
Issue : We are generating word document and same document we need to convert to pdf (content is same for both word and pdf) as we required pdf also. So we are using below code for that but we are seeing issue like my word document have 5 pages and after saving into pdf when i open pdf it have 5 pages but content is same only one line is goign to next page with that entire page is showing empty like below
Word Docuemnt :
After converting it into pdf :
Sample Project : But Unfortunately not able to reproduce here but same pdf version and same code only using in our project not sure why not able to reproduce here.
aspose_test - 2661.zip (825.0 KB)
Workaround tried :
- used document.updatePageLayout() method to force a layout update to ensure page count and alignment remain the same.
- Used PdfSaveOptions with below properties
Note : This is not happening for all documents happening only for few documents
Thanks,
Priyanka.
@priyanka9 I cannot reproduce the problem on my side. The problem with document layout might occur because the fonts used in the documents are not available in the environment where documents are converted to PDF. To build an accurate document layout the fonts are required. If Aspose.Words cannot find the fonts used in the document the fonts are substituted. This might lead into the layout differences due to differences in fonts metrics. You can implement IWarningCallback to get a notification when font substitution is performed.
The following articles can be useful for you:
https://docs.aspose.com/words/java/specify-truetype-fonts-location/
https://docs.aspose.com/words/java/install-truetype-fonts-on-linux/
ok will go through these links thanks 
But just informing we are keeping all the fonts which are required to generate the document in application classpath and referring through below code while generating document and pdf convertion also happening in same place(environment)
1 Like
@priyanka9 If you implement IWarningCallback you will be sure whether font substitution is performed.
Hi @alexey.noskov ,
We have observed one thing actually issue is not happeing while converting document into pdf its happening when i save my finaldocument into pdf which got generated after replacing all replacingargs.
So when i use below line i can see the parag last line is moving to next page.
Document document = res.getFinalDocument();
document.save("FinalDocument.pdf",SaveFormat.pdf);
But if i save same document as docx it is workign fine.
document.save("FinalDocument.pdf",SaveFormat.docx);
application/vnd.openxmlformats-officedocument.wordprocessingml.document
for pdf it is using application/pdf
And fonts also we are using same fonts whatever we kepts on claspath
Can you please give some suggestions here we tried a lot but still no use.
@priyanka9 As you may know MS Word documents are flow by their nature and there is no “page” concept. The consumer applications reflows the document’s content into pages on the fly.
MS Word documents are flow documents and they have structure very similar to Aspose.Words Document Object Model. But on the other hand PDF documents are fixed page format documents.
So how MS Word renders document depends on the fonts available in the environment where you are viewing the document. The same as rendering DPF document depends on the fonts available in the environment where it is rendered, as mentioned above.