Compile errors after updating to the latest release of ASPOSE


#1

We have some old software written by Aspose internal consultants (!) that we have been running unchanged for several years. Now we want to upgrade to the latest release of Aspose software and are encountering some compile errors due to API changes that have occurred in the past few years.

As no one on our team is an Aspose expert, could someone please help us and provide the updated syntax that we need?

Help is much appreciated.

================================================================

ASPOSE.Email

Errors:

Error BC30516 Overload resolution failed because no accessible ‘Save’ accepts this number of arguments.
Error BC30451 ‘MailMessageSaveOptions’ is not declared. It may be inaccessible due to its protection level.

Line of code:

mailMsg.Save(ms, /* stream
MailMessageSaveType.MHtmlFormat,
MailMessageSaveOptions.WriteHeaderToMht Or
MailMessageSaveOptions.WriteCompleteEmailAddressToMht)

================================================================

ASPOSE.PDF

Errors:

Error BC30002 Type ‘Aspose.Pdf.InteractiveFeatures.XYZExplicitDestination’ is not defined.
Error BC30002 Type ‘Aspose.Pdf.InteractiveFeatures.GoToAction’ is not defined.

Lines of code:

link.Destination = New Aspose.Pdf.InteractiveFeatures.XYZExplicitDestination(prevDst.PageNumber,
prevDst.Left, prevDst.Top, prevDst.Zoom)

pdfOutline.Action = New Aspose.Pdf.InteractiveFeatures.GoToAction(pdfDocument.Pages(TOCPageNo))

pdfOutline.Action = New Aspose.Pdf.InteractiveFeatures.GoToAction(pdfDocument.Pages(Regex.Match(row(“Page”), “\d+”).Value - bookmarksPageAdjust))


#2

@IraD,

I have observed your requirements. For your query concerning to Aspose.Email, I suggest you to please use following sample code on your end.

MhtSaveOptions mhtSaveOptions = new MhtSaveOptions
{
//Specify formatting options required
MhtFormatOptions = MhtFormatOptions.WriteHeader | MhtFormatOptions.WriteCompleteEmailAddress,
};

        eml.Save(new MemoryStream(), mhtSaveOptions);

For further information, you can please refer to this documentation article, Saving Mail Message as MHTML.

For your inquiry concerning to Aspose.PDF, we will share the feedback shortly.


#3

@IraD

With respect to Aspose.PDF for .NET API, we would like to update you that XYZExplicitDestination as well as GoToAction Class has been moved under Aspose.Pdf.Annotations namespace. Please add reference to Aspose.Pdf.Annotations or you can use full qualified name as Aspose.Pdf.Annotations.GoToAction. Moreover, these changes were implemented in Aspose.PDF for .NET 11.6 as mentioned in respective Release Notes.

We hope this will be helpful. In case you still face any issue, please feel free to contact us.


#4

Thank you, Farhan! I made the changes you suggested and my code now compiles.


#5

It is not, however, the end of the story.

In simplest form, our application takes multiple documents of varying types and combines them into a single PDF adding a Table of Contents with one entry for each of the documents being combined. The application uses 4 Aspose DLLs: PDF, Words, Cells and Email.

With the minor changes to syntax for Email and PDF described above (with thanks), we have upgraded the software to use release 18.6 of all the DLLs. The application compiles and executes. However, the output of our application is different!

Keeping Cells, PDF and Email constant at 18.6, we have identified that using different versions of ASPOSE.Words accounts for the differences in our results.

Prior to our changes, the application used ASPOSE.Words 15.1 and we were happy with the results.

Using ASPOSE.Words 16.2, everything remains the same.

Using ASPOSE.Words 16.3, an extra (blank) page appears in the output. We can probably live with this.

But as of ASPOSE.Words 18.2, the Table of Contents is no longer correct, containing only the first entry. This is not usable for us.


#6

@IraD,

I have observed your comments. Can you please share sample project to reproduce issue so that we may further investigate to help you out.


#7

Thank you Adnan. Please see attachments.ASPOSEConsolidation2.zip (1.5 MB)
ReadMe.pdf (278.3 KB)
SampleDocs.zip (30.0 KB)


#8

@IraD,

Thanks for your inquiry. We have executed your shared project and faced following exception message.

Microsoft Excel cannot access the file ‘\fs1\fs1f\Users\Share0\FISTWindows\Spreadsheets\CSR_IFBInstructionsTemplate.xltx’.

You are using Aspose.Cells, Aspose.Email, Aspose.PDF and Aspose.Words in your application. It seems that your query is more related to Aspose.Words. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Please attach the output document that shows the undesired behavior.
  • Please attach the expected output document that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.


#9

CSR_IFBInstructionsTemplate.zip (6.4 KB)
7-12-2018 2-30-21 PM.jpg (101.3 KB)

Sorry. Please see if the instructions in the attached help.


#10

@IraD,

Thanks for sharing the detail. We have tested the scenario using latest version of Aspose.Words for .NET 18.7 and have not found the shared issue. Please use Aspose.Words for .NET 18.7. We have attached the output PDF with this post for your kind reference. - 20184912 114926_Result.pdf (89.0 KB)


#11

Tahir,

This surprises me very much as we have run this test about 50 times. So I will look again and advise.

Thank you,
Ira


#12

@IraD,

Please upgrade to the latest versions of Aspose products. Please check the attached packages.config file that we used to test the scenario.
packages.zip (271 Bytes)


#13

Yes, this is what I have I the packages.config file.

I have been working on this all morning. I have made about 25 runs looking at things. I still get only one line in the TOC.

I have a little more to look at…


#14

Tahir,

Please read the attached.

IraMoreInfo.pdf (330.9 KB)


#15

@IraD,

Thanks for your inquiry. Please share the following detail here for further testing.

  • After calling addTableOfContents() method, please save your final document to DOCX and share it.
  • Please share your output PDF that shows the undesired behavior.
  • Please share complete detail of your use case.

We will investigate the issue and provide you more information on it.


#16

Tahir,

Attached find a zip of the output directory and also an image that shows how the .docx was preserved.

I am unclear of what you mean by my use case. Do you mean the reason for this application overall? Or something about this execution?

IraAsposeOut.zip (103.2 KB)
7-16-2018 9-20-25 AM.jpg (104.1 KB)


#17

@IraD,

Thanks for sharing the detail.

Please download the application shared by you and test the scenario using latest versions of Aspose products. We have put the “Doc A.docx” and “Doc B.jpg” files in “asposein” folder and tested the scenario. We have not found the TOC issue.

In your case, you are setting custom style for paragraphs. Please make sure that you are calling addCustomBookmark method correctly.

The output document (DOCX) shared by you have paragraph before the image. Its style is “Normal”. It should be “Aspose_Custom_Bookmark_Style”. Please make sure that you are setting it correctly.


#18

Tahir,

Yes I get the same problem when I run the project I sent you.

Regarding the paragraph style, this is not something I have touched. If you look in the vicinity of line 1354 in the AsposeDocument class, you will see the style referenced.

Regarding your testing: Are Doc A.docx and Doc B.jpg the ONLY two documents in the input folder? When you run the application, it creates a ZIP file in the input folder.

When I run the application with exactly two documents in the input folder, I get the output I showed you. Only one line in the TOC. But a side effect of the application is the creation of a zip in the input folder. So when I run the application again, every thing works! Take the zip files out of the input folder, it fails. With extra files in the folder, it works.

The extra zip in the input folder is bypassed in the process, but it is reflected in the log. Can you show me a log file for a run that works with the version number in the log file as well?


#19

@IraD,

Thanks for your inquiry. We have attached the log, PDF and Word files with this post. Dosc.zip (197.8 KB)
This is not a bug in Aspose.Words API. You are facing incorrect TOC becase the custom style (Aspose_Custom_Bookmark_Style) is not set for paragraph before the image. Please debug the code of addCustomBookmark method to test this scenario.

Please open the attached DOCX in MS Word and move the cursor to the paragraph before image and check its style. For detail, please check “custom style.png” in Docs.zip.


#20

@IraD,

We have found the root cause of the issue that you are facing. You are facing this issue while merging the Word documents. Please note that Aspose.Words mimics the behavior of MS Word. If you merge the documents after adding custom style and insert TOC field using MS Word, you will get the same output (one line in TOC). The document merge process changes the style of “doc b.jpg” to Normal style. This is expected behavior of Aspose.Words and MS Word.

In your case, we suggest you please use ImportFormatMode as UseDestinationStyles instead of KeepSourceFormatting in mergeWordDocuments().

Replace following line of code
mergedDoc.AppendDocument(wordDoc, ImportFormatMode.KeepSourceFormatting)
with
mergedDoc.AppendDocument(wordDoc, ImportFormatMode.UseDestinationStyles)