Free Support Forum - aspose.cloud

Exception when trying to add Header object

Hi,

I am trying to add Text Header to PDF file using PostDocumentTextHeader and PostDocumentTextFooter methods over API Reference but getting following error.

{
“error”: {
“code”: “errorAmazonS3Storage”,
“message”: “AmazonS3 Storage exception: The specified key does not exist. Bucket ‘afc-filestorage’, FilePath ‘96368/f87185cc-8155-4b6a-874f-1979bc9397d8/string’”,
“description”: “Operation Failed. The remote server returned an error: (404) Not Found.”,
“innerError”: {
“requestId”: null,
“date”: “2020-09-01T18:16:45.8444579Z”
}
}
}

I am using default storage but wonder why this error is appearing. Furthermore, I have also tried to insert an image using PostInsertImage method but the resultant file do not have image object. My App SID = 9a3184aa-1337-41a6-9f67-f4312fe7a5d8

Thanks

@codewarior

Please double check your parameter values, as per the error message it seems you are passing some parameter value string. Kindly check the following cURL examples, these will help you to accomplish the task.

Insert Text into the page header:

curl -X POST "https://api.aspose.cloud/v3.0/pdf/target.pdf/header/text?startPageNumber=1&endPageNumber=2&folder=Temp"
-H "accept: application/json" 
-H "authorization: Bearer [Access_Token]" 
-H "Content-Type: application/json" 
-H "x-aspose-client: Containerize.Swagger" 
-d "{\"Background\":true,\"HorizontalAlignment\":\"Center\",\"Opacity\":1.0,\"Rotate\":\"None\",\"RotateAngle\":10.0,\"XIndent\":0.0,\"YIndent\":0.0,\"Zoom\":1.0,\"TextAlignment\":\"Center\",\"Value\":\"Header\",\"TextState\":{\"FontSize\":14.0,\"Font\":\"Arial Bold\",\"ForegroundColor\":{\"A\":255,\"R\":0,\"G\":255,\"B\":0},\"BackgroundColor\":{\"A\":255,\"R\":255,\"G\":0,\"B\":0},\"FontStyle\":\"Bold\"},\"LeftMargin\":1.0,\"TopMargin\":20.0,\"RightMargin\":2.0}"

Insert Image into the page header:

curl -X POST "https://api.aspose.cloud/v3.0/pdf/Test_sample.pdf/header/image?startPageNumber=1&endPageNumber=2&folder=Temp" 
-H "accept: application/json" 
-H "authorization: Bearer [Access_Token]" 
-H "Content-Type: application/json" 
-H "x-aspose-client: Containerize.Swagger" 
-d "{\"Background\":true,\"HorizontalAlignment\":\"Center\",\"Opacity\":1.0,\"Rotate\":\"None\",\"RotateAngle\":0.0,\"XIndent\":0.0,\"YIndent\":0.0,\"Zoom\":0.1,\"FileName\":\"Temp/aspose.jpg\",\"LeftMargin\":1.0,\"TopMargin\":20.0,\"RightMargin\":2.0}"

Please share your input document along with the code, we will investigate it and guide you.

Hi Tilal,

Thanks for the response. The error occurred when only a few parameters were provided. However, upon the provision of complete list, the API worked fine. I will try the same approach for PostInsertImage method. In case of any related query, I will let you know.

{
“LineSpacing”: “FontSize”,
“WrapMode”: “ByWords”,
“HorizontalAlignment”: “FullJustify”,
“LeftMargin”: 10,
“RightMargin”: 10,
“TopMargin”: 20,
“BottomMargin”: 20,
“Rectangle”: {
“LLX”: 100,
“LLY”: 600,
“URX”: 300,
“URY”: 200
},
“Rotation”: 10,
“SubsequentLinesIndent”: 10,
“VerticalAlignment”: “Center”,
“Lines”: [
{
“HorizontalAlignment”: “Left”,
“Segments”: [
{
“Value”: “Hello World…”,
“TextState”: {
“FontSize”: 18,
“Font”: “Arial”,
“ForegroundColor”: {
“A”: 0x00,
“R”: 0x33,
“G”: 0x33,
“B”: 0x99
},
“BackgroundColor”: {
“A”: 0x00,
“R”: 0xCC,
“G”: 0xFF,
“B”: 0xCC
},
“FontStyle”: “Regular”,
“FontFile”: “Allura-Regular.otf”
}
}
]
}
]
}

1 Like

@codewarior

You may share your code. We will investigate the issue and share our findings.