I would like to verify that there are a few basic fields on the template before I save it to my file structure.
what I would like to do is take the IFormFile that is the file I have uploaded, and load that into a document so that spire can get the mail merge field and I can do some quick validation.
Here is a generic version of what I'm looking for
Here is my Model
- Code: Select all
public class AddLetterViewModel
{
[Required]
[Display(Name = "Letter Title")]
public string LetterTitle { get; set; }
[Required]
[Display(Name = "Letter File")]
public IFormFile LetterDoc { get; set; }
}
and here is the (roughly) desired code in the controller
- Code: Select all
Document doc = new Document();
doc.LoadFromFile(AddLetterViewModel.LetterDoc.FileName);
// this is for an extension that I created for the validation it requires a spire.doc Document
var resultModel = new ModelStateResults();
var result = doc.VerifyDocument(resultModel);
doc.Close();
if this validates as true then it creates the file in the file structure, and database entry for retrieval later.
Obviously the above doesn't work, but I'm hoping for some assistance to point me in the right direction.