Using the free version of spire.doc. I am opening a template and saving multiple pages and then combining them into one document. All works well until I try to save the combined document as a PDF. Oddly it will work if there is only one page in the combined document, but fails if there is more then one page.
Is there something wrong with the code below?
Is there a limit on the SaveToFile PDF format in the free version?
Do I need to add the spire.pdf component to my project as well?
The exception error for what it is worth is:
Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: 'System.Collections.Generic.ObjectComparer`1[sprᯚ]'.
thanks,
nja
Combining the individual files
===================
- Code: Select all
//foreach (FileInfo file in downloadedMessageInfo.GetFiles())
while (x < filecount)
{
//string fileName = Server.MapPath(Path.Combine("/", "App_Documents/Templates/CheckPreviewTemplate.docx"));
string fileMerge = Server.MapPath(Path.Combine("/", "App_Documents/Checks/" + files[x].Name));
//Create word document
Document documentMerge = new Document();
documentMerge.LoadFromFile(fileMerge, FileFormat.Docx);
// copy the new section, i.e. the new page, to the first file opened
foreach (Section sec in documentMerge.Sections)
{
document.Sections.Add(sec.Clone());
}
// increment our page counter
x++;
}
serving up a multi-page word document => WORKS
==================================================
- Code: Select all
//Save doc file to the download location and trigger the download in the javascript
document.SaveToFile(Server.MapPath(Path.Combine("/", "App_Documents/NewDocuments/Combined.docx")), FileFormat.Docx);
- Code: Select all
$.post(url, { idArray: ids }, function (data) {
$("#resultMessage").html(data.message);
if (data.success) {
// on success open the new file
window.open('/App_Documents/NewDocuments/Combined.docx', '_blank');
}
});
serving up a multi-page PDF document => FAILS
==================================
- Code: Select all
document.SaveToFile(Server.MapPath(Path.Combine("/", "App_Documents/NewDocuments/Combined.PDF")), FileFormat.PDF);
$.post(url, { idArray: ids }, function (data) {
$("#resultMessage").html(data.message);
if (data.success) {
// on success open the new file
window.open('/App_Documents/NewDocuments/Combined.PDF', '_blank');
}
});