Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.
Thu Jul 23, 2020 5:27 pm
I am pulling a docx file from a resource in our asp.net azure website.
The code works fine in development mode, but errors out when deployed to Azure.
This is the code. It crashes on doc.SaveToSream( method.
- Code: Select all
public MemoryStream GetPDFDocumentStream(MacDbContext ctx, int psfAppID)
{
var resourcePath = ReflectionUtil.GetManifestResourceStreamNameByFileName("PsfApplicationTemplate.docx");
var assembly = Assembly.GetExecutingAssembly();
var newPdfStream = new MemoryStream();
using (Stream stream1 = assembly.GetManifestResourceStream(resourcePath))
{
var data = GetModelAsDataTable(ctx, psfAppID);
var doc = new Spire.Doc.Document(stream1);
doc.MailMerge.HideEmptyParagraphs = true;
doc.MailMerge.Execute(data);
doc.SaveToStream(newPdfStream, Spire.Doc.FileFormat.PDF);
}
return newPdfStream;
}
Login to view the files attached to this post.
-
terrence@mactexas.com
-
- Posts: 95
- Joined: Tue May 19, 2015 8:09 pm
Fri Jul 24, 2020 10:28 am
Hello,
Please use the following code to convert word file to PDF on Azure server.
- Code: Select all
Document doc = new Document();
doc.LoadFromStream(stream1);
ToPdfParameterList topdf = new ToPdfParameterList();
topdf.UsePSCoversion = true;
doc.SaveToStream(newPdfStream, topdf);
If you have any issue, please feel free to contact us.
Sincerely,
Sofia
E-iceblue support team
-
Sofia.Yang
-
- Posts: 84
- Joined: Tue Jul 14, 2020 1:41 am
Fri Jul 24, 2020 4:05 pm
Thank you, that worked.
-
terrence@mactexas.com
-
- Posts: 95
- Joined: Tue May 19, 2015 8:09 pm
Mon Jul 27, 2020 1:05 am
Hello,
Thanks for your response.
If you encounter any issues related to our product, just feel free to contact us.
Have a nice day!
Sincerely,
Sofia
E-iceblue support team
-
Sofia.Yang
-
- Posts: 84
- Joined: Tue Jul 14, 2020 1:41 am