Dear Aspose Support Team,
I am encountering an issue with the Aspose PDF Merge API when running in an on-premise aspose-pdf-cloud
container. The merge operation works correctly in one of our environments but fails in another. Below are the details of the error:
Error Log:
Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HN6S8OC6OQPH", Request id "0HN6S8OC6OQPH:00000002": An unhandled exception was thrown by the application.
System.NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances are not supported. Path: $.TargetSite.MethodHandle.Value.
---> System.NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances are not supported.
at System.Text.Json.Serialization.Converters.UnsupportedTypeConverter`1.Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
...
The error suggests that the serialization of System.IntPtr
is not supported. The merge operation works in one environment but fails in another, even though both environments are using the same version of the Aspose PDF Cloud container.
@sidharth.chauhan
Please provide more details. Example of code, environment settings and your input document.
This is mine nodejs code. We are using on-premises aspose container. This is not related to specific file , this is happening on every file. There is no specific env setting for this.
mergePdfsAsposeOnPremise: async (files) =>
{
try {
let list = [];
let randomStr = Math.random().toString(36).slice(2, 8);
let resultName=`output-${randomStr}.pdf`;
if (Object.keys(files).length) {
let promiseAll = [];
for (const fileKey in files) {
const { originalFilename: fileName, path: localFilePath, order: order } = files[fileKey];
list.push({localFilePath: localFilePath, order: order});
}
list.sort(function(f1, f2) {
return f1.order < f2.order ? -1 : 1;
});
list = list.map(file => file.localFilePath);
}
let asposePdfUrl = 'http://aspose-pdf-cloud.document-service-backend.svc.cluster.local/v3.0/pdf'
let request = {
method: 'put',
url: asposePdfUrl + `/${resultName}/merge`,
headers: {
'accept': 'application/json',
'Content-Type': 'application/json',
},
data: {
List: list
}
};
await axios(request);
const outputPath = path.join('/data', resultName);
const outputPdfStream = fs.createReadStream(outputPath);
const fileSize = commonUtils.getFileSizeFromStreamSync(outputPath);
if (fs.existsSync(outputPath)){
try {
await fse.remove(outputPath);
} catch(err) {
logger.error(err);
}
}
else {
logger.info(`${outputPath} is not found.`);
}
return { outputPdfStream : outputPdfStream, fileSize: fileSize, filesToBeDeletedArray: list};
} catch (error) {
let apiError = new APIError('50090', error, 'Unknown Error');
logger.error(`Error while merging files using aspose onPremise`, apiError);
throw apiError;
}
},
@sidharth.chauhan
We have noticed the reported issues and logged the following tickets in our issue tracking system for further investigation and rectification. We will notify you as soon as these issues are resolved.
PDFCLOUD-4477: PDF Merge API System.IntPtr is not supported
Hello Aspose team,
You can ignore environment thing , this is happening when we have size of total files to merge more than 300MB . It is working fine when file size is less than that.
Just FYI CPU and memory resources are sufficient for aspose pod.
@sidharth.chauhan
thanks for the clarification, I will add new information to the task description
@sidharth.chauhan
The issues you have found earlier (filed as PDFCLOUD-4477) have been fixed in this version 24.10. Please update docker image.