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.

Mon Nov 21, 2022 9:57 pm

Hello
we try to move our generate doc process to AWS lambda and it works good, except images
for example Paragraph.AppendPicture(From byte[] or from Stream) not working and not getting any errors

sserra
 
Posts: 76
Joined: Tue Jun 13, 2017 4:03 pm

Tue Nov 22, 2022 9:44 am

Hello,

Thanks for your inquiry.
Are you using the latest version Of Spire.Office (Spire.Office 7.11.0)? If not, please update to and test your issue again. If the issue still exists after updating, to help us reproduce your issue and work out a solution for you, please offer the following message. Thanks for your assistance in advance.

1) Your input word document, you can attach here or send it to us via email ([email protected]).
2) Your full test code that can reproduce your issue.
3) Application type, such as Console App, .NET Framework 4.8.
4) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Tue Nov 22, 2022 3:15 pm

please see code below
files is attached
that code works perfectly fine under Windows, but does not work under Amazon Lambda function
for reproduce that issue you need
1) put docx and image file to S3
2) create as lambda function and put code
3) fill out s3path and creds for S3 client
4) execute lambda function

private void LoadDoc()
{
Document SPD = new Document(ReadStream(BucketName, FilePath ));
Paragraph pa2 = SPD.LastParagraph;
pa2.AppendPicture(ReadStream(BucketName, FilePath ));
MemoryStream FileStream = new MemoryStream();

SPD.SaveToStream(FileStream, FileFormat.Docx);
WriteAllBytes(FileStream, S3Path, FileName);
SPD.Close();

}


public Stream ReadStream(string BucketName, string FilePath)
{
AmazonS3Client S3Client = new AmazonS3Client(accesskey, secretkey, Amazon.RegionEndpoint.USWest2);

MemoryStream memStream = new MemoryStream();

GetObjectRequest request = new GetObjectRequest()
{
BucketName = BucketName ,
Key = FilePath
};

using (GetObjectResponse response = S3Client.GetObjectAsync(request).Result)
response.ResponseStream.CopyTo(memStream);

return memStream;

}

public void WriteAllBytes(Stream FileStream, string S3Path, string FileName)
{
PutObjectRequest request = new PutObjectRequest()
{
BucketName = S3Path,
InputStream = FileStream,
Key = FileName
};

PutObjectResponse response = S3Client.PutObjectAsync(request).Result;

}

sserra
 
Posts: 76
Joined: Tue Jun 13, 2017 4:03 pm

Wed Nov 23, 2022 11:00 am

Hello,

Thanks for your inquiry.
According to your messages, I didn’t reproduce your issue, I attached my test steps for your reference.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Doc

cron