on 2024 Mar 04 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
Request clarification before answering.
Not possible to merge two pdfs and to save the new pdf within CPQ via code because of limitation :
Forbidden .NET Classes and Namespaces
The following .NET namespaces and classes are forbidden in IronPython scripts:
System.IO
System.Data
System.Configuration
Webcom.Configurator.Util.ConnectionStringProvider
System.Environment
System.GC
System.Type
System.Web.WebPages.Razor
System.Reflection
System.Web
System.Diagnostics
If there are scripts that contain System import * and Webcom.Configurator.Util import * and any of the words from the forbidden classes, the system disables saving scripts (for example, saving is disabled if there is System import * and Data in the same script).
For troubleshooting, please contact the SAP CPQ Support team.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
16 | |
5 | |
2 | |
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.