Image crops while file is converted from Word to PDF

Hello Team,

We are facing the problem while converting word document to PDF format having images.

Image sides are getting cropped in the PDF output.

Attached is the PDF output for your reference.

View the image with 100% zoom size, you will observe the lfet and bottom crop for the very first image in the right hand corner on the top.

Regards,

Hi

Thanks for your inquiry. Could you please attach also source document here for testing? I will try to reproduce the problem on my side and provide you more information.
Which version of Aspose.Words do you use?
Best regards.

Aspose Words: 6.2.0.0
and
Aspose.PDF: 3.9.0.0

Regards,

Hi

Thank you for additional information. But I still need your document to investigate the problem. Please attach your Word document here for testing.
Best regards.

Hi ,
Attaching the document as per requirement.
Waititng for your reply…!!!
Thanks & Regards,
Dwarika

Hi

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words (7.0.0). You can download the latest version of Aspose.Words from here:
https://releases.aspose.com/words/net
Best regards,

Hi,
As we have mentioned in our previous post we are using older versions of Aspose word & PDF which are as follows.
Aspose.Word 6.2.0.0
Aspose.PDF 3.9.0.0
Will You please re-test the same with older versions which i mentioned here.
Is it possible for you to provide us some work-around or update the same dll as we do not want to change our older dll with new one.
Thanks & Regards,
Dwarika,

Hi Dwarika,

Thanks for your inquiry.

  1. No, we cannot provide an update the same dll. Fixes and new features are always included into new versions. So if you need these fixes and features you should update to the newer version.
  2. Unfortunately, I cannot suggest you any other workaround than refactoring your document manually using MS Word.

But anyway, I think, the best option in your case is upgrading to the latest version of Aspose.Words.
Best regards,

Hi,
Thank you for your reply.
As per your suggetion in previous post for using the latest version of Aspose Word ( which is 7.0.0.0) will solve this problem but still i want to confirm some of my doubts regarding migrating the entire product to 7.0.0.0 .
1> Will you please let me know that wheather newer version of Aspose Word dll is fully compitable with the older version 6.2.0.0?
2>There will not be any functionality related changes which is available in Aspose Word version 6.2.0.0( for e.g image plotting, right to left etc) ?
3> Is there any functionality which is avaialble in 6.2.0.0 & not supported in 7.0.0.0 or there is any major behavioural changes for exisitng API or properties.
3>Is there any major code changes required to migrate the product from 6.2.0.0 to 7.0.0.0 for e.g In previous version we are using one special method ( please refer attached file for sample code) for converting word to pdf but now you introduced a new API called

Document doc = new Document("in.doc");
doc.SaveToPdf("out.pdf");

4> If there is a major changes in functionality or addition or removal of new API then how much amount of changes we need to do & which are they?

As i told you in my previous post that our software is pretty stable whch is currently using Aspose word 6.2.0.0 & Aspose Pdf 3.9.0.0 & It is ready to go live after some time.
Changing the Aspose Word dll to newer version is major concern & risk for us.
I hope that you understand our concerns very well, Waiting for your reply !!!
Thanks & Regards,
Dwarika.

Hi Dwarika,

Thanks for your request.

  1. Yes, new version of fully compatible with 6.2.0. There were no breaking changes in API made.
  2. No, there were no changes made related to Aspose.Words existing functionalities.
  3. No, there were no major code changes made in new version. Also, new method of PDF conversion (e.g Document.SaveToPdf) was introduced in Aspose.Words 6.0.0. So Aspose.Words 6.2.0 also has this method.

The current version of Aspose.Words also supports old legacy method of PDF conversion (Aspose.Words+Aspose.Pdf). But is you would like to use this legacy method, I think, you should also upgrade to the latest version of Aspose.Pdf.
4. No, public API was not changed.

I think you should implement test application, which will allow you to automate testing process of key features of Aspose.Words, which you use in your software. This will save your time when you upgrade to the newer versions.
Best regards,

Hi,
As Per your suggestion we have shifted our entire product to latest version of word & pdf .
The versions are as follows
1>Aspose.Word 7.0.0.0
2>Aspose.PDF 4.1.0.0

In addition to that we also changed our legacy method( pls refer attached txt file containing legacy method) to the latest suggested method.

reportDocument.SaveToPdf(0, reportDocument.PageCount, elementDoc, null);

Here elemendoc is a memorystream in which we are storing resultant PDF document.
We found two issues here
1> The origional problem is not solved.please go though attached image (please refer attachement image.png)where images are still cropped & also showned some outer border which is not matching to the origional word document.

The origional word document is also attached with this post.(filename: -OrigionalPRB(version 7.0 .0 .0).doc)

2> As per your comment in previous post the Aspose Word 7.0.0.0 is fully compatible to Aspose Word version 6.2.0.0 but i think there are some issues while converting word document into PDF format

The problem that i found is there are some blank spaces added in between of content,Please refer attached image (filename:-issue#2.png) for further reference. The origional word document is also attached to the same post ( file name:-issue#2.doc)
This problem is not reproduced in following scenario.
1>if we use older version of Aspose Word 6.2.0.0 & PDF 3.9.0.0
2>if we use the legacy method for converting the word file into PDF format.

As i said in my earlier post that our product is pretty stable with old Aspose word & pdf dll & legacy method. Our product is going to live in coming days.Since we do not want any compatibility issues.
As i said migrating entire application is a biggest risk & threat to our project since your newer version is not compitable with older version it affects our project functionality which is already stable.
I think you can understand our problem & suggest us some way to come over the origional problem.
Waiting for Your reply!!!
Thanks & Regards,
Dwarika

Hi Dwarika,
Thanks for your request.

  1. I cannot see any image cropping on your screenshot. Could you please highlight place where the image is cropped? Maybe I missed something. Also, please attach your output PDF instead of image.
  2. I managed to reproduce the problem with borders around the pictures. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.
  3. I cannot reproduce the problem 2 on my side. Do you generate the document programmatically? Such kind of problem can occur if you have two table one after another. If so I can suggest you two workarounds of this issue for now:

a. You can insert an empty paragraph between table. Please see the following code:

// Open document.
Document doc = new Document(@"Test001\in.doc");
// Get collection of tables
NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);
Paragraph spliter = new Paragraph(doc);
spliter.ParagraphBreakFont.Size = 1;
// loop through all tables
foreach(Table table in tables)
{
    // Check if the next node after the tabel is another table.
    // If so, insert an empty paragraph between tables.
    if (table.NextSibling != null && table.NextSibling.NodeType == NodeType.Table)
        table.ParentNode.InsertAfter(spliter.Clone(true), table);
}
// Save output document
doc.SaveToPdf(@"Test001\out.pdf");

b. You can merge table into one table:

// Open document.
Document doc = new Document(@"Test001\in.doc");
// Get collection of tables
NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);
Paragraph spliter = new Paragraph(doc);
spliter.ParagraphBreakFont.Size = 1;
// loop through all tables
foreach(Table table in tables)
{
    // Check if the next node after the tabel is another table.
    if (table.NextSibling != null && table.NextSibling.NodeType == NodeType.Table)
    {
        Table nextTable = (Table) table.NextSibling;
        // Append all rows form the current table to the next.
        while (table.HasChildNodes)
            nextTable.Rows.Insert(0, table.LastRow);
    }
}
// Save output document
doc.SaveToPdf(@"Test001\out.pdf");

Hope this helps.
Best regards,

Hi AndreyN ,
Thanks for your instant reply.
I just want to remind you that i am using the Aspose.Word & Pdf with following versions.
Aspose.Word 7.0.0.0
Aspose.PDF 4.1.0.0
also i am using the following method to convert word document into pdf format.

// here elementdoc is a memory stream.
reportDocument.SaveToPdf(0, reportDocument.PageCount, elementDoc, null);

As per your comments in previous post, the Actual word document & pdf document is attached with this post.also for better understanding of the problem the relevent images also attached( problem area is encircled with red mark).
1> if you can observe the page no 1 in PDF you can easily observe that the verify image is not completely visible it is getting cropped at the bottom.(please see attached issue#1 for further reference).( may be visual effect produced due to border issue)
2> As per your comments in prevous post, The borders around images is a known problem, we want to give some more information to you that the images are displaying within a floating textboxes.(please refer Image_Display_Code.txt file attached with this post).
3>pleae refer last page ( page no 7 ) of pdf you will find there is an space get added between table no2 & table no3 only in PDF document which is not matching the output produced in word format.(please refer issue-3.png)

as i told u in my previous post the issue#3 is not there if we use the old dll & old legacy method of converting word into pdf.
Want to ask one more question if we used direct method of PDF conversion, Do we still requires the PDF dll & references?

Issue #1 & # 2 is still not solved in latest aspose version(origional problem)

Issue #3 is a major concerns for us since your constantly suggesting us to use new method for pdf conversion, but it is not fully compitable to aspose version 6.2.0.0
I think you understand our problem & will provide some intermitiate solution to avoid compatibility issue.
Thanks & Regards,
Dwarika

Hi

Thank you for additional information.

  1. You are right, this visual effect occurs due to border issues. If you try to set zoom of your PDF document 150% and compare the picture with original there is no differences. Please see Compare.png.
  2. You will be notified as soon as it is resolved.
  3. Have you tried using one of two workarounds, which I described in my previously post?

If you use direct method of PDF conversion it is not needed to use Aspose.Pdf.
Best regards,

Hi AndreyN,
Thanks for your your code suggestion & service.

  1. I am agreed to your point that images are not getting cropped since it looks like cropped due to the border problem.
  2. Can you provide some time-estimate to us about when will this problem will get resolved.( not exact but probable time estimate ).
  3. For issue#3, Are you able to reproduced the problem at your end?

As i told you that this( issue #3) problem is not with aspose version 6.2.0.0 & PDF version 3.9.0.0 , So is it compatibility issue?
Thanks & Regards,
Dwarika,

Thanks for your request.

  1. Unfortunately, I cannot provide you any reliable estimate regarding this issue at the moment. Please expect a reply before next hotfix (within 4-5 weeks).
  2. Yes, your request has been linked to the appropriate issue. As a workaround you can use the code provided you earlier.

Bets regards,

For Point 2: Borders seen around images in PDF.
This issue is holding our product to go in production. It is very critical to be resolved. We request you to provide an workaround at an earliest.

Hi

Thanks for your request. Unfortunately, the issue is still unresolved, and I cannot provide you any reliable estimate regarding this at the moment. You will be notified as soon as it is fixed.
Best regards,

Hello Dwarika,
My name is Alex I have analysed the borders problem. I checked the document and found that it contains one png image. I had saved it in a standalone file and then I tried to create a pdf file from this png using the Acrobate. I’ve got the same result as if I use Aspose.Words (see the file attached). Thus in this case we can say that Aspose.Words creates a pdf file exactly in the same way as Adobe software does it. Moreover saving your document as pdf using Office 2007 leads to the same result. Quick check the png file structure shows that the borders appears on the edges of transparent areas of png. I think this is a designed behavior for this usecase in general. I am going to close the problem as WAD. My sugestion to you is either to leave it as is or to rework the image (maybe by splitting to the several images).
Yours sincerely,
Alex

The issues you have found earlier (filed as 10736) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.