on 03-04-2024 4:34 PM
Hi SAP Community,
I try to load pdf's via a global script from additional files directory. I call the pdfs and receive a System.IO.MemoryStream objects.How can I merge multiple pdfs with the given code capabilities?
Additionally, I have to convert System.IO.MemoryStream objects to a FileStream object to store it again in content files directory. How can I achieve this due to the fact that system namespace System.IO forbidden?
My orientation was the following documentation: SAP Docu
################################################################################
### Define Parameter ###
File1 = '001.pdf'
File2 = '002.pdf'
BaseUrl = 'additionalfiles'
PathToDataSheet1 = BaseUrl + File1
PathToDataSheet2 = BaseUrl + File2
### Get the Pdf files ###
GetDatasheetFile = FileHelper.GetStreamFromPath(PathToDataSheet1)
GetDatasheetFile = FileHelper.GetStreamFromPath(PathToDataSheet2)
### Convert MemoryStream to HTTPContent ###
HTTPContent1 = ?
HTTPContent2 = ?
### Merge files ###
MergedFile = ?
### Store Merged file ###
#add headers using AddContentHeaders() method
MergedFile.AddContentHeaders('Content-Type', 'application/pdf')
#making MultipartFormDataContent and specifying its name
MultiPartContent = MultipartFormDataContent()
MultiPartContent.Add(StreamContent(MergedFile), "file", "MergedFile.pdf")
# add new file to managed content
urlSetSpesificContentFile = baseUrl + '/api/v1/admin/files/ContentFile'
NewSpesificContentFile = RestClient.Put(urlSetSpesificContentFile, headers, MultiPartContent)
@LukaPilipovic Maybe you could help me with my coding issue here or know someone which maybe has the experience to know a solution for this issue.
Kind regards
Alexander
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.