diff --git a/Aspose.Pdf.Cloud.Sdk.Core.sln b/Aspose.Pdf.Cloud.Sdk.Core.sln deleted file mode 100644 index 7fe465f4..00000000 --- a/Aspose.Pdf.Cloud.Sdk.Core.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29411.108 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspose.Pdf.Cloud.Sdk.Core", "src\Aspose.Pdf.Cloud.Sdk\Aspose.Pdf.Cloud.Sdk.Core.csproj", "{92ED9056-EC18-4591-B2BA-34FBDDC59B93}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspose.Pdf.Cloud.Sdk.Test.Core", "src\Aspose.Pdf.Cloud.Sdk.Test\Aspose.Pdf.Cloud.Sdk.Test.Core.csproj", "{39E66748-F38A-417C-9398-CB4F0FC0B3E7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {92ED9056-EC18-4591-B2BA-34FBDDC59B93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {92ED9056-EC18-4591-B2BA-34FBDDC59B93}.Debug|Any CPU.Build.0 = Debug|Any CPU - {92ED9056-EC18-4591-B2BA-34FBDDC59B93}.Release|Any CPU.ActiveCfg = Release|Any CPU - {92ED9056-EC18-4591-B2BA-34FBDDC59B93}.Release|Any CPU.Build.0 = Release|Any CPU - {39E66748-F38A-417C-9398-CB4F0FC0B3E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {39E66748-F38A-417C-9398-CB4F0FC0B3E7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {39E66748-F38A-417C-9398-CB4F0FC0B3E7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {39E66748-F38A-417C-9398-CB4F0FC0B3E7}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {16443E20-7934-4890-91C4-A39FD2562510} - EndGlobalSection -EndGlobal diff --git a/LICENSE.TXT b/LICENSE.txt similarity index 100% rename from LICENSE.TXT rename to LICENSE.txt diff --git a/README.md b/README.md index 34568535..169900ff 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,13 @@ XLS, XLSX, PPTX, DOC, DOCX, MobiXML, JPEG, EMF, PNG, BMP, GIF, TIFF, Text ## Read PDF Formats MHT, PCL, PS, XSLFO, MD -## Enhancements in Version 25.5 -- Add a method for comparing pdf files. +## Enhancements in Version 25.7 +- Add possibility to hide subject field in signature appearance. - A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET. +## Bugs fixed in Version 25.7 +- PostDeleteStamps removing stamps from PDF page is incorrect. + ## Unit Tests Aspose PDF SDK includes a suite of unit tests. These Unit Tests also serves as examples of how to use the Aspose PDF SDK. diff --git a/Uses-Cases/Annotations/Annotations.csproj b/Uses-Cases/Annotations/Annotations.csproj new file mode 100644 index 00000000..683240af --- /dev/null +++ b/Uses-Cases/Annotations/Annotations.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/Uses-Cases/Annotations/AnnotationsHelper.cs b/Uses-Cases/Annotations/AnnotationsHelper.cs new file mode 100644 index 00000000..212a51ca --- /dev/null +++ b/Uses-Cases/Annotations/AnnotationsHelper.cs @@ -0,0 +1,111 @@ +using Aspose.Pdf.Cloud.Sdk.Api; +using Aspose.Pdf.Cloud.Sdk.Model; +using Newtonsoft.Json; + +namespace Annotations +{ + public class ConfigParams + { + public string CrdentialPath { get; } = "..\\credentials.json "; + public string LOCAL_FOLDER { get; } = "C:\\Samples"; + public string REMOTE_TEMP_FOLDER { get; } = "TempPdfCloud"; + public string PDF_DOCUMENT { get; } = "sample.pdf"; + public string PDF_OUTPUT { get; } = "output_sample.pdf"; + public int PAGE_NUMBER { get; } = 1; + + public string ANNOTATION_ID { get; } = "GE5TAOZTHA2CYMRZGUWDIMBZFQZTEMA"; + + public string NEW_HL_ANNOTATION_TEXT { get; } = "NEW HIGHLIGHT TEXT ANNOTATION"; + public string NEW_HL_ANNOTATION_DESCRIPTION { get; } = "This is a sample highlight annotation"; + public string NEW_HL_ANNOTATION_SUBJECT { get; } = "Highlight Text Box Subject"; + public string NEW_HL_ANNOTATION_CONTENTS { get; } = "Highlight annotation sample contents"; + + public string NEW_SO_ANNOTATION_TEXT { get; } = "NEW STRIKEOUT TEXT ANNOTATION"; + public string NEW_SO_ANNOTATION_DESCRIPTION { get; } = "This is a sample strikeout annotation"; + public string NEW_SO_ANNOTATION_SUBJECT { get; } = "Strikeout Text Box Subject"; + public string NEW_SO_ANNOTATION_CONTENTS { get; } = "Strikeout annotation sample contents"; + + public string NEW_UL_ANNOTATION_TEXT { get; } = "NEW UNDERLINE TEXT ANNOTATION"; + public string NEW_UL_ANNOTATION_DESCRIPTION { get; } = "This is a sample underline annotation"; + public string NEW_UL_ANNOTATION_SUBJECT { get; } = "Underline Text Box Subject"; + public string NEW_UL_ANNOTATION_CONTENTS { get; } = "Underline annotation sample contents"; + + public string NEW_FT_ANNOTATION_TEXT { get; } = "NEW FREE TEXT ANNOTATION"; + public string NEW_FT_ANNOTATION_DESCRIPTION { get; } = "This is a sample annotation"; + public string NEW_FT_ANNOTATION_SUBJECT { get; } = "Free Text Box Subject"; + public string NEW_FT_ANNOTATION_CONTENTS { get; } = "Free Text annotation sample contents"; + + public string REPLACED_CONTENT { get; } = "This is a replaced sample annotation"; + } + + public class Credentials + { + public string Id { get; set; } + public string Key { get; set; } + } + + public class AnnotationsHelper + { + public PdfApi pdfApi { get; private set; } + public ConfigParams config { get; private set; } + + public AnnotationsHelper() + { + config = new ConfigParams(); + string jsCredText = File.ReadAllText(config.CrdentialPath); + Credentials cred = JsonConvert.DeserializeObject(jsCredText); + pdfApi = new PdfApi(cred.Key, cred.Id); + } + + public async Task UploadFile(string fileName) + { + using (var file = File.OpenRead(Path.Combine(config.LOCAL_FOLDER, fileName))) + { + FilesUploadResult response = await pdfApi.UploadFileAsync(Path.Combine(config.REMOTE_TEMP_FOLDER, fileName), file); + if (response == null) + Console.WriteLine("UploadFile(): Unexpected error - no response!"); + else if (response.Errors != null && response.Errors.Count > 0) + foreach (var error in response.Errors) + Console.WriteLine("UploadFile(): {0} -> {1}", [error.Code, error.Message]); + else + Console.WriteLine("UploadFile(): File '{0}' successfully uploaded.", fileName); + } + } + + public async Task DownloadFile(string fileName, string outputName, string outputPrefix) + { + Stream stream = pdfApi.DownloadFile(Path.Combine(config.REMOTE_TEMP_FOLDER, fileName)); + using var fileStream = File.Create(Path.Combine(config.LOCAL_FOLDER, outputPrefix + outputName)); + stream.Position = 0; + await stream.CopyToAsync(fileStream); + Console.WriteLine("DownloadFile(): File '{0}' successfully downloaded.", outputPrefix + outputName); + } + + public async Task DeletePopupAnnotationsAsync(string documentName, string parentAnnotation, string remoteFolder) + { + // Delete popup annotations for typed parent annotation in the page in the PDF document. + PopupAnnotationsResponse response = await pdfApi.GetDocumentPopupAnnotationsAsync(documentName, folder: config.REMOTE_TEMP_FOLDER); + if (response == null) + Console.WriteLine("DeletePopupAnnotations(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("DeletePopupAnnotations(): Unexpected error '{0}'!", response.Status); + else + { + foreach (PopupAnnotationWithParent annotation in response.Annotations.List) + { + if (annotation.Parent.Id == parentAnnotation) + { + string popupContents = annotation.Contents; + AsposeResponse response2 = await pdfApi.DeleteAnnotationAsync(documentName, annotation.Id, folder: remoteFolder); + if (response2 == null) + Console.WriteLine("DeletePopupAnnotations(): Unexpected error!"); + else if (response2.Code < 200 || response2.Code > 299) + Console.WriteLine("DeletePopupAnnotations(): Failed to delete popup annotation '{0}' from the document.", popupContents); + else + Console.WriteLine("DeletePopupAnnotations(): popup annotations '{0}' with '{1}' contents deleted from the document '{1}.", annotation.Id, popupContents, documentName); + } + } + } + } + } +} diff --git a/Uses-Cases/Annotations/DeletePageAnnotations.cs b/Uses-Cases/Annotations/DeletePageAnnotations.cs new file mode 100644 index 00000000..ef903058 --- /dev/null +++ b/Uses-Cases/Annotations/DeletePageAnnotations.cs @@ -0,0 +1,22 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Annotations +{ + public class DeletePageAnnotations + { + public async static Task MakeDeleteAsync(AnnotationsHelper helper, string documentName, int pageNumber, string outputName, string remoteFolder) + { + // Delete annotation from the PDF document. + await helper.UploadFile(documentName); + AsposeResponse response = await helper.pdfApi.DeletePageAnnotationsAsync(documentName, pageNumber, folder: remoteFolder); + if (response == null) + Console.WriteLine("DeletePageAnnotations(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("DeletePageAnnotations(): Failed to delete annotation from the document."); + else { + Console.WriteLine("DeletePageAnnotations(): annotations on page '{0}' deleted from the document '{1}.", pageNumber, documentName); + await helper.DownloadFile(documentName, outputName, "del_page_annotations_"); + } + } + } +} diff --git a/Uses-Cases/Annotations/DeleteTextAnnotation.cs b/Uses-Cases/Annotations/DeleteTextAnnotation.cs new file mode 100644 index 00000000..43b19667 --- /dev/null +++ b/Uses-Cases/Annotations/DeleteTextAnnotation.cs @@ -0,0 +1,24 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Annotations +{ + public class DeleteTextAnnotation + { + public async static Task MakeDeleteAsync(AnnotationsHelper helper, string documentName, string annotationId, string outputName, string remoteFolder) + { + // Delete annotation from the PDF document. + await helper.UploadFile(documentName); + AsposeResponse response = await helper.pdfApi.DeleteAnnotationAsync(documentName, annotationId, folder: remoteFolder); + if (response == null) + Console.WriteLine("DeleteTextAnnotation(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("DeleteTextAnnotation(): Failed to delete annotation from the document."); + else + { + await helper.DeletePopupAnnotationsAsync(documentName, annotationId, remoteFolder); + Console.WriteLine("DeleteTextAnnotation(): annotations '{0}' deleted from the document '{1}.", annotationId, documentName); + await helper.DownloadFile(documentName, outputName, "del_text_annotations_"); + } + } + } +} diff --git a/Uses-Cases/Annotations/GetAnnotationById.cs b/Uses-Cases/Annotations/GetAnnotationById.cs new file mode 100644 index 00000000..ce3fbfe2 --- /dev/null +++ b/Uses-Cases/Annotations/GetAnnotationById.cs @@ -0,0 +1,23 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Annotations +{ + public class GetAnnotationById + { + public static async Task RequestTextAnnotationAsync(AnnotationsHelper helper, string documentName, string annotationId, string remoteFolder) + { + // Get annotation by Id in the PDF document. + await helper.UploadFile(documentName); + + string annotationResult = string.Empty; + TextAnnotationResponse response = await helper.pdfApi.GetTextAnnotationAsync(documentName, annotationId, folder: remoteFolder); + + if (response == null) + Console.WriteLine("RequestTextAnnotationAsync(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("RequestTextAnnotationAsync(): Failed to request text annotation from the document."); + else + Console.WriteLine("RequestTextAnnotationAsync(): annotation '{0}' with '{1}' contents successfully found in the document '{2}.", response.Annotation.Id, response.Annotation.Contents, documentName); + } + } +} diff --git a/Uses-Cases/Annotations/GetAnnotations.cs b/Uses-Cases/Annotations/GetAnnotations.cs new file mode 100644 index 00000000..f01b34dc --- /dev/null +++ b/Uses-Cases/Annotations/GetAnnotations.cs @@ -0,0 +1,34 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Annotations +{ + public class GetAnnotations + { + public static async Task RequestAnnotationsOnPageAsync(AnnotationsHelper helper, string documentName, int pageNumber, string remoteFolder) + { + // Get annotations from the page in the PDF document. + await helper.UploadFile(documentName); + + string annotationResult = string.Empty; + AnnotationsInfoResponse response = await helper.pdfApi.GetPageAnnotationsAsync(documentName, pageNumber, folder: remoteFolder); + + if (response == null) + Console.WriteLine("RequestAnnotationsOnPageAsync(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("RequestAnnotationsOnPageAsync(): Failed to request annotations from the document."); + else + { + foreach (AnnotationInfo annotation in response.Annotations.List) + { + Console.WriteLine("RequestAnnotationsOnPageAsync(): annotation '{0}' with '{1}' contents get from the '{2}' page of the document '{3}.", [annotation.Id, annotation.Contents, pageNumber, documentName]); + if (string.IsNullOrEmpty(annotationResult) && + annotation.AnnotationType == AnnotationType.Text) + { + annotationResult = annotation.Id; + } + } + } + return annotationResult; + } + } +} \ No newline at end of file diff --git a/Uses-Cases/Annotations/NewFreetextAnnotation.cs b/Uses-Cases/Annotations/NewFreetextAnnotation.cs new file mode 100644 index 00000000..7464f00b --- /dev/null +++ b/Uses-Cases/Annotations/NewFreetextAnnotation.cs @@ -0,0 +1,47 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Annotations +{ + public class NewFreetextAnnotation + { + public static async Task Append(AnnotationsHelper helper, string documentName, int pageNumber, string outputName, string remoteFolder) + { + await helper.UploadFile(documentName); + + List annotations = new List + { + new FreeTextAnnotation( + Name: "Freetext_NEW_Annotation", + Rect: new Rectangle(100,350, 450,400), + Flags: new List() { AnnotationFlags.Default }, + HorizontalAlignment: HorizontalAlignment.Left, + Intent: FreeTextIntent.FreeTextTypeWriter, + Justification: Justification.Center, + RichText: helper.config.NEW_FT_ANNOTATION_TEXT, + Subject: helper.config.NEW_FT_ANNOTATION_SUBJECT, + Contents: helper.config.NEW_FT_ANNOTATION_CONTENTS, + Title: helper.config.NEW_FT_ANNOTATION_DESCRIPTION, + ZIndex: 1, + TextStyle: new TextStyle( + FontSize: 20, + Font: "Arial", + ForegroundColor: new Color( A: 0xFF, R: 0x00, G: 0xFF, B: 0x00), + BackgroundColor: new Color( A: 0xFF, R: 0xFF, G: 0x00, B: 0x00) + ), + Modified: "03/27/2025 00:00:00.000 AM" + ) + }; + AsposeResponse response = await helper.pdfApi.PostPageFreeTextAnnotationsAsync(documentName, pageNumber, annotations, folder: remoteFolder); + + if (response == null) + Console.WriteLine("NewFreetextAnnotation(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("NewFreetextAnnotation(): Failed to append text annotation to the document."); + else + { + Console.WriteLine("NewFreetextAnnotation(): annotations '{0}' added to the document '{1}.", helper.config.NEW_FT_ANNOTATION_TEXT, documentName); + await helper.DownloadFile(documentName, outputName, "add_text_annotation_"); + } + } + } +} diff --git a/Uses-Cases/Annotations/NewHighlightAnnotation.cs b/Uses-Cases/Annotations/NewHighlightAnnotation.cs new file mode 100644 index 00000000..af1511c6 --- /dev/null +++ b/Uses-Cases/Annotations/NewHighlightAnnotation.cs @@ -0,0 +1,47 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Annotations +{ + public class NewHighlightAnnotation + { + public static async Task Append(AnnotationsHelper helper, string documentName, int pageNumber, string outputName, string remoteFolder) + { + await helper.UploadFile(documentName); + + List annotations = new List + { + new HighlightAnnotation( + Name: "Highlight_NEW_Annotation", + Rect: new Rectangle(100,350, 450,400), + Flags: new List() { AnnotationFlags.Default }, + HorizontalAlignment: HorizontalAlignment.Left, + VerticalAlignment: VerticalAlignment.Top, + RichText: helper.config.NEW_HL_ANNOTATION_TEXT, + Subject: helper.config.NEW_HL_ANNOTATION_SUBJECT, + Contents: helper.config.NEW_HL_ANNOTATION_CONTENTS, + Title: helper.config.NEW_HL_ANNOTATION_DESCRIPTION, + ZIndex: 1, + Color: new Color(A: 0xFF, R: 0x00, G: 0xFF, B: 0x00), + QuadPoints: new List() { + new Point(X: 10, Y: 10), + new Point(X: 20, Y: 10), + new Point(X: 10, Y: 20), + new Point(X: 10, Y: 10) + }, + Modified: "03/27/2025 00:00:00.000 AM" + ) + }; + AsposeResponse response = await helper.pdfApi.PostPageHighlightAnnotationsAsync(documentName, pageNumber, annotations, folder: remoteFolder); + + if (response == null) + Console.WriteLine("NewHighlightAnnotation(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("NewHighlightAnnotation(): Failed to append highlight annotation to the document."); + else + { + Console.WriteLine("NewHighlightAnnotation(): annotations '{0}' added to the document '{1}.", helper.config.NEW_HL_ANNOTATION_TEXT, documentName); + await helper.DownloadFile(documentName, outputName, "add_highlight_annotation_"); + } + } + } +} diff --git a/Uses-Cases/Annotations/NewStrikeoutAnnotation.cs b/Uses-Cases/Annotations/NewStrikeoutAnnotation.cs new file mode 100644 index 00000000..a1ea831b --- /dev/null +++ b/Uses-Cases/Annotations/NewStrikeoutAnnotation.cs @@ -0,0 +1,47 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Annotations +{ + public class NewStrikeoutAnnotation + { + public static async Task Append(AnnotationsHelper helper, string documentName, int pageNumber, string outputName, string remoteFolder) + { + await helper.UploadFile(documentName); + + List annotations = new List + { + new StrikeOutAnnotation( + Name: "Strikeout_NEW_Annotation", + Rect: new Rectangle(100,350, 450,400), + Flags: new List() { AnnotationFlags.Default }, + HorizontalAlignment: HorizontalAlignment.Left, + VerticalAlignment: VerticalAlignment.Top, + RichText: helper.config.NEW_SO_ANNOTATION_TEXT, + Subject: helper.config.NEW_SO_ANNOTATION_SUBJECT, + Contents: helper.config.NEW_SO_ANNOTATION_CONTENTS, + Title: helper.config.NEW_SO_ANNOTATION_DESCRIPTION, + ZIndex: 1, + Color: new Color(A: 0xFF, R: 0x00, G: 0xFF, B: 0x00), + QuadPoints: new List() { + new Point(X: 10, Y: 10), + new Point(X: 20, Y: 10), + new Point(X: 10, Y: 20), + new Point(X: 10, Y: 10) + }, + Modified: "03/27/2025 00:00:00.000 AM" + ) + }; + AsposeResponse response = await helper.pdfApi.PostPageStrikeOutAnnotationsAsync(documentName, pageNumber, annotations, folder: remoteFolder); + + if (response == null) + Console.WriteLine("NewStrikeoutAnnotation(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("NewStrikeoutAnnotation(): Failed to append strikeout annotation to the document."); + else + { + Console.WriteLine("NewStrikeoutAnnotation(): annotations '{0}' added to the document '{1}.", helper.config.NEW_SO_ANNOTATION_TEXT, documentName); + await helper.DownloadFile(documentName, outputName, "add_strikeout_annotation_"); + } + } + } +} diff --git a/Uses-Cases/Annotations/NewUnderlineAnnotation.cs b/Uses-Cases/Annotations/NewUnderlineAnnotation.cs new file mode 100644 index 00000000..f7864847 --- /dev/null +++ b/Uses-Cases/Annotations/NewUnderlineAnnotation.cs @@ -0,0 +1,47 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Annotations +{ + public class NewUnderlineAnnotation + { + public static async Task Append(AnnotationsHelper helper, string documentName, int pageNumber, string outputName, string remoteFolder) + { + await helper.UploadFile(documentName); + + List annotations = new List + { + new UnderlineAnnotation( + Name: "Underline_NEW_Annotation", + Rect: new Rectangle(100,350, 450,400), + Flags: new List() { AnnotationFlags.Default }, + HorizontalAlignment: HorizontalAlignment.Left, + VerticalAlignment: VerticalAlignment.Top, + RichText: helper.config.NEW_UL_ANNOTATION_TEXT, + Subject: helper.config.NEW_UL_ANNOTATION_SUBJECT, + Contents: helper.config.NEW_UL_ANNOTATION_CONTENTS, + Title: helper.config.NEW_UL_ANNOTATION_DESCRIPTION, + ZIndex: 1, + Color: new Color(A: 0xFF, R: 0x00, G: 0xFF, B: 0x00), + QuadPoints: new List() { + new Point(X: 10, Y: 10), + new Point(X: 20, Y: 10), + new Point(X: 10, Y: 20), + new Point(X: 10, Y: 10) + }, + Modified: "03/27/2025 00:00:00.000 AM" + ) + }; + AsposeResponse response = await helper.pdfApi.PostPageUnderlineAnnotationsAsync(documentName, pageNumber, annotations, folder: remoteFolder); + + if (response == null) + Console.WriteLine("NewUnderlineAnnotation(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("NewUnderlineAnnotation(): Failed to append underline annotation to the document."); + else + { + Console.WriteLine("NewUnderlineAnnotation(): annotations '{0}' added to the document '{1}.", helper.config.NEW_UL_ANNOTATION_TEXT, documentName); + await helper.DownloadFile(documentName, outputName, "add_underline_annotation_"); + } + } + } +} diff --git a/Uses-Cases/Annotations/Program.cs b/Uses-Cases/Annotations/Program.cs new file mode 100644 index 00000000..7e08780d --- /dev/null +++ b/Uses-Cases/Annotations/Program.cs @@ -0,0 +1,17 @@ +using Annotations; + +AnnotationsHelper helper = new AnnotationsHelper(); +ConfigParams config = helper.config; + +string annotationId = await GetAnnotations.RequestAnnotationsOnPageAsync(helper, config.PDF_DOCUMENT, config.PAGE_NUMBER, config.REMOTE_TEMP_FOLDER); +await GetAnnotationById.RequestTextAnnotationAsync(helper, config.PDF_DOCUMENT, annotationId, config.REMOTE_TEMP_FOLDER); + +await DeletePageAnnotations.MakeDeleteAsync(helper, config.PDF_DOCUMENT, config.PAGE_NUMBER, config.PDF_OUTPUT, config.REMOTE_TEMP_FOLDER); +await DeleteTextAnnotation.MakeDeleteAsync(helper, config.PDF_DOCUMENT, config.ANNOTATION_ID, config.PDF_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await NewHighlightAnnotation.Append(helper, config.PDF_DOCUMENT, config.PAGE_NUMBER, config.PDF_OUTPUT, config.REMOTE_TEMP_FOLDER); +await NewStrikeoutAnnotation.Append(helper, config.PDF_DOCUMENT, config.PAGE_NUMBER, config.PDF_OUTPUT, config.REMOTE_TEMP_FOLDER); +await NewUnderlineAnnotation.Append(helper, config.PDF_DOCUMENT, config.PAGE_NUMBER, config.PDF_OUTPUT, config.REMOTE_TEMP_FOLDER); +await NewFreetextAnnotation.Append(helper, config.PDF_DOCUMENT, config.PAGE_NUMBER, config.PDF_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ReplaceAnnotation.ModifyAsync(helper, config.PDF_DOCUMENT, config.PDF_OUTPUT, config.ANNOTATION_ID, config.REMOTE_TEMP_FOLDER); \ No newline at end of file diff --git a/Uses-Cases/Annotations/ReplaceAnnotation.cs b/Uses-Cases/Annotations/ReplaceAnnotation.cs new file mode 100644 index 00000000..66a61d0c --- /dev/null +++ b/Uses-Cases/Annotations/ReplaceAnnotation.cs @@ -0,0 +1,47 @@ +using Aspose.Pdf.Cloud.Sdk.Model; +using System.Runtime.Intrinsics.X86; + +namespace Annotations +{ + public class ReplaceAnnotation + { + public static async Task GetAnnotationAsync(AnnotationsHelper helper, string documentName, string annotationId, string remoteFolder) + { + // Get annotation by Id in the PDF document. + TextAnnotation annotationResult = null; + TextAnnotationResponse response = await helper.pdfApi.GetTextAnnotationAsync(documentName, annotationId, folder: remoteFolder); + + if (response == null) + Console.WriteLine("GetAnnotationAsync(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("GetAnnotationAsync(): Failed to request text annotation from the document."); + else + { + Console.WriteLine("GetAnnotationAsync(): annotation '{0}' with '{1}' contents successfully found in the document '{2}.", response.Annotation.Id, response.Annotation.Contents, documentName); + annotationResult = response.Annotation; + } + return annotationResult; + } + + public static async Task ModifyAsync(AnnotationsHelper helper, string documentName, string outputName, string annotationId, string remoteFolder) + { + // Change annotation on the page in the PDF document. + await helper.UploadFile(documentName); + TextAnnotation annotation = await ReplaceAnnotation.GetAnnotationAsync(helper, documentName, annotationId, remoteFolder); + + annotation.Contents = helper.config.REPLACED_CONTENT; + annotation.Icon = TextIcon.Star; + + TextAnnotationResponse response = await helper.pdfApi.PutTextAnnotationAsync(documentName, annotationId, annotation, folder: remoteFolder); + if (response == null) + Console.WriteLine("ModifyAnnotation(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ModifyAnnotation(): Failed to request text annotation from the document."); + else + { + Console.WriteLine("ModifyAnnotation(): annotation '{0}' successfully modified in the document '{1}.", annotationId, documentName); + await helper.DownloadFile(documentName, outputName, "replaced_annotatiom_"); + } + } + } +} \ No newline at end of file diff --git a/Uses-Cases/ChangeLayout/ChangeLayout.csproj b/Uses-Cases/ChangeLayout/ChangeLayout.csproj new file mode 100644 index 00000000..683240af --- /dev/null +++ b/Uses-Cases/ChangeLayout/ChangeLayout.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/Uses-Cases/ChangeLayout/ChangeLayoutHelper.cs b/Uses-Cases/ChangeLayout/ChangeLayoutHelper.cs new file mode 100644 index 00000000..8630151c --- /dev/null +++ b/Uses-Cases/ChangeLayout/ChangeLayoutHelper.cs @@ -0,0 +1,184 @@ +using Aspose.Pdf.Cloud.Sdk.Api; +using Aspose.Pdf.Cloud.Sdk.Model; +using Newtonsoft.Json; + +namespace ChangeLayout +{ + public class ConfigParams + { + public string CrdentialPath { get; } = "..\\credentials.json "; + public string LOCAL_FOLDER { get; } = "C:\\Samples"; + public string REMOTE_TEMP_FOLDER { get; } = "TempPdfCloud"; + public string PDF_DOCUMENT { get; } = "sample.pdf"; + public string PDF_OUTPUT { get; } = "output_sample.pdf"; + + public Rotation ROTATE_PAGES_ANGLE = Rotation.On90; + public string ROTATE_PAGES { get; } = "1-3"; + + + public string CROP_PAGE_TEMP_FILE { get; } = "sample_temp_file.png"; + public string CROP_LOCAL_RESULT_DOCUMENT_NAME { get; } = "output_sample.pdf"; + public int CROP_PAGE_NUMBER { get; } = 3; + public int CROP_HEIGHT { get; } = 400; + public int CROP_WIDTH { get; } = 300; + public int CROP_LLX { get; } = 100; + public int CROP_LLY { get; } = 200; + + public string RESIZE_PDF_HTML_FILE { get; } = "sample_temp_file.html"; + public string RESIZE_RESULT_DOCUMENT_NAME { get; } = "output_sample.pdf"; + public int RESIZE_PAGE_NUMBER { get; } = 2; + public int RESIZE_NEW_PAGE_WIDTH { get; } = 1000; + public int RESIZE_NEW_PAGE_HEIGHT { get; } = 500; + + public int CROP_PAGE_WIDTH { get; set; } = 0; + public int CROP_PAGE_HEIGHT { get; set; } = 0; + } + + public class Credentials + { + public string Id { get; set; } + public string Key { get; set; } + } + + public class ChangeLayoutHelper + { + public PdfApi pdfApi { get; private set; } + public ConfigParams config { get; private set; } + + public ChangeLayoutHelper() + { + config = new ConfigParams(); + string jsCredText = File.ReadAllText(config.CrdentialPath); + Credentials cred = JsonConvert.DeserializeObject(jsCredText); + pdfApi = new PdfApi(cred.Key, cred.Id); + } + + public async Task UploadFile(string fileName) + { + using (var file = File.OpenRead(Path.Combine(config.LOCAL_FOLDER, fileName))) + { + FilesUploadResult response = await pdfApi.UploadFileAsync(Path.Combine(config.REMOTE_TEMP_FOLDER, fileName), file); + if (response == null) + Console.WriteLine("UploadFile(): Unexpected error - no response!"); + else if (response.Errors != null && response.Errors.Count > 0) + foreach (var error in response.Errors) + Console.WriteLine("UploadFile(): {0} -> {1}", [ error.Code, error.Message]); + else + Console.WriteLine("UploadFile(): File '{0}' successfully uploaded.", fileName); + } + } + + public async Task DownloadFile(string fileName, string outputPrefix) + { + Stream stream = pdfApi.DownloadFile(Path.Combine(config.REMOTE_TEMP_FOLDER, fileName)); + using var fileStream = File.Create(Path.Combine(config.LOCAL_FOLDER, outputPrefix + fileName)); + stream.Position = 0; + await stream.CopyToAsync(fileStream); + Console.WriteLine("DownloadFile(): File '{0}' successfully downloaded.", outputPrefix + fileName); + } + + public async Task GetPageInfo(string document, int pageNumber) + { + DocumentPageResponse response = await pdfApi.GetPageAsync(document, pageNumber, folder: config.REMOTE_TEMP_FOLDER); + if (response == null) + Console.WriteLine("GetPageInfo(): Unexpected error - no response!"); + else if (response.Code != 200) + Console.WriteLine("GetPageInfo(): Code {0} -> Status '{1}'", [response.Code, response.Status]); + else + { + Page page = response.Page; + Rectangle rectangle = page.Rectangle; + Console.WriteLine("GetPageInfo(): page {0} => id: '{1}', lLx: '{2}', lLY: '{3}', uRX: '{4}', uRY: '{5}'", + [pageNumber, page.Id, rectangle.LLX, rectangle.LLY, rectangle.URX, rectangle.URY]); + config.CROP_PAGE_HEIGHT = (int)(Math.Round(rectangle.URY ?? 0) - Math.Round(rectangle.LLY ?? 0)); + config.CROP_PAGE_WIDTH = (int)(Math.Round(rectangle.URX ?? 0) - Math.Round(rectangle.LLX ?? 0)); + } + } + + public async Task ExtractPdfPage(string document, int pageNumber, int width, int height) + { + string imageFile = document + ".png"; + Stream stream = await pdfApi.GetPageConvertToPngAsync(document, pageNumber, width, height, config.REMOTE_TEMP_FOLDER); + using var fileStream = File.Create(Path.Combine(config.LOCAL_FOLDER, imageFile)); + stream.Position = 0; + await stream.CopyToAsync(fileStream); + + UploadFile(imageFile); + Console.WriteLine("ExtractPdfPage(): Page #{0} extracted as image {1}.", [pageNumber, imageFile]); + + return imageFile; + } + + public async Task CreatePdfDocument(string newDocument, int width, int height) + { + DocumentProperties docProps = new DocumentProperties( + List: new List() { + new DocumentProperty(Name: "prop1", Value: "Value1", BuiltIn: false) + } + ); + + DisplayProperties dispProps = new DisplayProperties() + { + CenterWindow = true, + HideMenuBar = true, + Direction = Direction.L2R, + DisplayDocTitle = true, + HideToolBar = true, + HideWindowUI = true, + NonFullScreenPageMode = PageMode.UseThumbs, + PageLayout = PageLayout.TwoPageLeft, + PageMode = PageMode.UseThumbs + }; + + DefaultPageConfig pageConfig = new DefaultPageConfig(height, width); + + DocumentConfig document_config = new DocumentConfig( + DocumentProperties: docProps, + DisplayProperties: dispProps, + DefaultPageConfig: pageConfig, + PagesCount: 1 + ); + + DocumentResponse response = await pdfApi.PostCreateDocumentAsync(newDocument, document_config, folder: config.REMOTE_TEMP_FOLDER); + + if (response != null && response.Code == 200) + { + Console.WriteLine("CreatePdfDocument(): Document '{0}' created.", newDocument); + return response; + } + else + { + Console.WriteLine("CreatePdfDocument(): Unexpected error!!!"); + return null; + } + } + + public async Task InsertPageAsImage(string document, string imageFileValue, int llx, int lly) + { + ImageStamp imageStamp = new ImageStamp( + Background: true, + HorizontalAlignment: HorizontalAlignment.None, + VerticalAlignment: VerticalAlignment.None, + Rotate: Rotation.None, + RotateAngle: 0, + Opacity: 1, + XIndent: -llx, + YIndent: -lly, + Zoom: 1, + FileName: Path.Combine(config.REMOTE_TEMP_FOLDER, imageFileValue) + ); + + AsposeResponse response = await pdfApi.PostPageImageStampsAsync(document, 1, new List() { imageStamp}, folder: config.REMOTE_TEMP_FOLDER ); + if (response != null && response.Code == 200) + { + Console.WriteLine("InsertPageAsImage(): Document '{0}' with stamp '{1}' created.", [document, imageFileValue]); + return response; + } + else + { + Console.WriteLine("CreatePdfDocument(): Unexpected error!!!"); + return null; + } + } + } +} diff --git a/Uses-Cases/ChangeLayout/CropDocumentPage.cs b/Uses-Cases/ChangeLayout/CropDocumentPage.cs new file mode 100644 index 00000000..c57d7e79 --- /dev/null +++ b/Uses-Cases/ChangeLayout/CropDocumentPage.cs @@ -0,0 +1,39 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace ChangeLayout +{ + public class CropDocumentPage + { + private ChangeLayoutHelper _helper; + + public CropDocumentPage(ChangeLayoutHelper helper) + { + _helper = helper; + } + + public async Task MakeCropDocumentPage(string document, string outputDocument, int pageNumber, int llx, int lly, int width, int height) + { + await _helper.UploadFile(document); + await _helper.GetPageInfo(document, pageNumber); + string imageFile = await _helper.ExtractPdfPage(document, pageNumber, _helper.config.CROP_PAGE_WIDTH, _helper.config.CROP_PAGE_HEIGHT); + DocumentResponse? newPdf = await _helper.CreatePdfDocument(outputDocument, width, height); + if (newPdf == null) + Console.WriteLine("MakeCropDocumentPage(): Unexpected error - new document is NULL"); + else if (newPdf.Code != 200) + Console.WriteLine("MakeCropDocumentPage(): Failed to create new PDF document!"); + else + { + AsposeResponse? response = await _helper.InsertPageAsImage(outputDocument, imageFile, llx, lly); + if (response == null) + Console.WriteLine("MakeCropDocumentPage(): Unexpected error - insert image return NULL"); + else if (newPdf.Code != 200) + Console.WriteLine("MakeCropDocumentPage(): Failed to insert image to the new PDF document!"); + else + { + Console.WriteLine("cropPage(): Page successfully cropped."); + await _helper.DownloadFile(outputDocument, "cropped_"); + } + } + } + } +} \ No newline at end of file diff --git a/Uses-Cases/ChangeLayout/Program.cs b/Uses-Cases/ChangeLayout/Program.cs new file mode 100644 index 00000000..26e51494 --- /dev/null +++ b/Uses-Cases/ChangeLayout/Program.cs @@ -0,0 +1,13 @@ +using ChangeLayout; + + +ChangeLayoutHelper helper = new ChangeLayoutHelper(); + +RotateDocumentsPages rotate = new RotateDocumentsPages(helper); +await rotate.MakeRotateDocumentsPages(helper.config.PDF_DOCUMENT, helper.config.ROTATE_PAGES_ANGLE.ToString(), helper.config.ROTATE_PAGES); + +ResizeDocumentAllPages resize = new ResizeDocumentAllPages(helper); +await resize.MakeResizeDocumentAllPages(helper.config.PDF_DOCUMENT, helper.config.RESIZE_PDF_HTML_FILE, helper.config.RESIZE_NEW_PAGE_WIDTH, helper.config.RESIZE_NEW_PAGE_HEIGHT); + +CropDocumentPage crop = new CropDocumentPage(helper); +await crop.MakeCropDocumentPage(helper.config.PDF_DOCUMENT, helper.config.CROP_LOCAL_RESULT_DOCUMENT_NAME, helper.config.CROP_PAGE_NUMBER, helper.config.CROP_LLX, helper.config.CROP_LLY, helper.config.CROP_WIDTH, helper.config.CROP_HEIGHT); \ No newline at end of file diff --git a/Uses-Cases/ChangeLayout/ResizeDocumentAllPages.cs b/Uses-Cases/ChangeLayout/ResizeDocumentAllPages.cs new file mode 100644 index 00000000..29be2844 --- /dev/null +++ b/Uses-Cases/ChangeLayout/ResizeDocumentAllPages.cs @@ -0,0 +1,54 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + + +namespace ChangeLayout +{ + public class ResizeDocumentAllPages + { + private ChangeLayoutHelper _helper; + + public ResizeDocumentAllPages(ChangeLayoutHelper helper) + { + _helper = helper; + } + + public async Task MakeResizeDocumentAllPages(string document, string htmlTempDoc, int pageWidth, int pageHeight) + { + await _helper.UploadFile(document); + string htmlTempPath = Path.Combine(_helper.config.REMOTE_TEMP_FOLDER, htmlTempDoc); + AsposeResponse response = await _helper.pdfApi.PutPdfInStorageToHtmlAsync( + document, htmlTempPath, + documentType: HtmlDocumentType.Xhtml.ToString(), + outputFormat: OutputFormat.Folder.ToString(), + folder: _helper.config.REMOTE_TEMP_FOLDER + ); + if (response == null) + Console.WriteLine("MakeResizeDocumentAllPages(): Unexpected error - no response in Pdf to Html convert!"); + else if (response.Code != 200) + Console.WriteLine("MakeResizeDocumentAllPages(): Error -> Code {0} -> Status '{1}'", [response.Code, response.Status]); + else + { + Console.WriteLine("MakeResizeDocumentAllPages(): temporary file '{0}' successfully created.", htmlTempDoc); + string outputDocument = "resized_" + document; + await _helper.pdfApi.PutHtmlInStorageToPdfAsync( + outputDocument, htmlTempPath, + dstFolder: _helper.config.REMOTE_TEMP_FOLDER, + htmlFileName: htmlTempDoc, + height: pageHeight, + width: pageWidth + ); + + if (response == null) + Console.WriteLine("MakeResizeDocumentAllPages(): Unexpected error - no response in html to Pdf convert!"); + else if (response.Code != 200) + Console.WriteLine("MakeResizeDocumentAllPages(): Error -> Code {0} -> Status '{1}'", [response.Code, response.Status]); + else + { + Console.WriteLine("resizePages(): Pages successfully resized."); + await _helper.DownloadFile(outputDocument, "resized_doc_"); + } + } + + } + } +} \ No newline at end of file diff --git a/Uses-Cases/ChangeLayout/RotateDocumentsPages.cs b/Uses-Cases/ChangeLayout/RotateDocumentsPages.cs new file mode 100644 index 00000000..0a3e47d4 --- /dev/null +++ b/Uses-Cases/ChangeLayout/RotateDocumentsPages.cs @@ -0,0 +1,28 @@ +using Aspose.Pdf.Cloud.Sdk.Api; +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace ChangeLayout +{ + public class RotateDocumentsPages + { + private ChangeLayoutHelper _helper; + + public RotateDocumentsPages(ChangeLayoutHelper helper) + { + _helper = helper; + } + + public async Task MakeRotateDocumentsPages(string document, string rotateAngle, string pages) + { + await _helper.UploadFile(document); + AsposeResponse response = await _helper.pdfApi.PostDocumentPagesRotateAsync(document, rotateAngle, pages, folder: _helper.config.REMOTE_TEMP_FOLDER); + if (response.Code != 200) + Console.WriteLine("MakeRotateDocumentsPages(): Unexpected error!"); + else { + Console.WriteLine("MakeRotateDocumentsPages(): Pages '{0}' successfully rotated!"); + + await _helper.DownloadFile(document, "rotated_"); + } + } + } +} \ No newline at end of file diff --git a/Uses-Cases/Conversions/Conversions.csproj b/Uses-Cases/Conversions/Conversions.csproj new file mode 100644 index 00000000..683240af --- /dev/null +++ b/Uses-Cases/Conversions/Conversions.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/Uses-Cases/Conversions/ConversionsHelper.cs b/Uses-Cases/Conversions/ConversionsHelper.cs new file mode 100644 index 00000000..c22548c8 --- /dev/null +++ b/Uses-Cases/Conversions/ConversionsHelper.cs @@ -0,0 +1,103 @@ +using Aspose.Pdf.Cloud.Sdk.Api; +using Aspose.Pdf.Cloud.Sdk.Model; +using Newtonsoft.Json; + +namespace Conversions +{ + public class ConfigParams + { + public string CrdentialPath { get; } = "c:\\Projects\\ASPOSE\\Pdf.Cloud\\Credentials\\credentials.json"; + public string LOCAL_FOLDER { get; } = "C:\\Samples"; + public string REMOTE_TEMP_FOLDER { get; } = "TempPdfCloud"; + public string PDF_DOCUMENT { get; } = "sample.pdf"; + + public string JPEG_FILE_NAME { get; } = "sample.jpg"; + public string BMP_FILE_NAME { get; } = "sample.bmp"; + public string PNG_FILE_NAME { get; } = "sample.png"; + public string GIF_FILE_NAME { get; } = "sample.gif"; + + public string PDF_BMP_OUTPUT { get; } = "output_bmp.pdf"; + public string PDF_JPEG_OUTPUT { get; } = "output_jpeg.pdf"; + public string PDF_PNG_OUTPUT { get; } = "output_png.pdf"; + public string PDF_GIF_OUTPUT { get; } = "output_gif.pdf"; + + public string HTML_FILE_NAME { get; } = "sample.html"; + public double PDF_HTML_WIDTH { get; } = 600; + public double PDF_HTML_HEIGHT { get; } = 850; + public string PDF_HTML_OUTPUT { get; } = "output_html.pdf"; + + public string MHTML_FILE_NAME { get; } = "sample.mht"; + public string PDF_MHTML_OUTPUT { get; } = "output_mht.pdf"; + + public string MD_FILE_NAME { get; } = "sample.md"; + public string PDF_MD_OUTPUT { get; } = "output_md.pdf"; + + public string EPUB_FILE_NAME { get; } = "sample.epub"; + public string PDF_EPUB_OUTPUT { get; } = "output_epub.pdf"; + + public string PCL_FILE_NAME { get; } = "sample.pcl"; + public string PDF_PCL_OUTPUT { get; } = "output_pcl.pdf"; + + public string PS_FILE_NAME { get; } = "sample.ps"; + public string PDF_PS_OUTPUT { get; } = "output_ps.pdf"; + + public string PDF_OUTPUT { get; } = "output_sample.pdf"; + public string DOC_OUTPUT { get; } = "output_sample.doc"; + public string DOCX_OUTPUT { get; } = "output_sample.docx"; + public string EPUB_OUTPUT { get; } = "output_sample.epub"; + public string HTML_ZIP_OUTPUT { get; } = "output_sample_html.zip"; + public string TIFF_OUTPUT { get; } = "output_sample.tiff"; + public string SVG_ZIP_OUTPUT { get; } = "output_sample_svg.zip"; + public string XLS_OUTPUT { get; } = "output_sample.xls"; + public string XLSX_OUTPUT { get; } = "output_sample.xlsx"; + public string PPTX_OUTPUT { get; } = "output_sample.pptx"; + public string XML_OUTPUT { get; } = "output_sample.xml"; + public string MXML_OUTPUT { get; } = "output_sample.mobi"; + public string TEX_OUTPUT { get; } = "output_sample.tex"; + public string XPS_OUTPUT { get; } = "output_sample.xps"; + } + + public class Credentials + { + public string Id { get; set; } + public string Key { get; set; } + } + + public class ConversionsHelper + { + public PdfApi pdfApi { get; private set; } + public ConfigParams config { get; private set; } + + public ConversionsHelper() + { + config = new ConfigParams(); + string jsCredText = File.ReadAllText(config.CrdentialPath); + Credentials cred = JsonConvert.DeserializeObject(jsCredText); + pdfApi = new PdfApi(cred.Key, cred.Id); + } + + public async Task UploadFile(string fileName) + { + using (var file = File.OpenRead(Path.Combine(config.LOCAL_FOLDER, fileName))) + { + FilesUploadResult response = await pdfApi.UploadFileAsync(Path.Combine(config.REMOTE_TEMP_FOLDER, fileName), file); + if (response == null) + Console.WriteLine("UploadFile(): Unexpected error - no response!"); + else if (response.Errors != null && response.Errors.Count > 0) + foreach (var error in response.Errors) + Console.WriteLine("UploadFile(): {0} -> {1}", [error.Code, error.Message]); + else + Console.WriteLine("UploadFile(): File '{0}' successfully uploaded.", fileName); + } + } + + public async Task DownloadFile(string fileName) + { + Stream stream = pdfApi.DownloadFile(Path.Combine(config.REMOTE_TEMP_FOLDER, fileName)); + using var fileStream = File.Create(Path.Combine(config.LOCAL_FOLDER, fileName)); + stream.Position = 0; + await stream.CopyToAsync(fileStream); + Console.WriteLine("DownloadFile(): File '{0}' successfully downloaded.", fileName); + } + } +} diff --git a/Uses-Cases/Conversions/ConvertBMPToPDF.cs b/Uses-Cases/Conversions/ConvertBMPToPDF.cs new file mode 100644 index 00000000..3b0d6586 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertBMPToPDF.cs @@ -0,0 +1,34 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertBMPToPDF + { + public static async Task Convert(ConversionsHelper helper, string bmpFile, string pdfOutput, string remoteFolder) + { + await helper.UploadFile(bmpFile); + + List imageTemplateList = new List { + new ImageTemplate(ImagePath: Path.Combine(remoteFolder, bmpFile), ImageSrcType: ImageSrcType.Common) + }; + + ImageTemplatesRequest imageTemplatesRequest = new ImageTemplatesRequest( + IsOCR: true, + OCRLangs: "eng", + ImagesList: imageTemplateList + ); + + AsposeResponse response = await helper.pdfApi.PutImageInStorageToPdfAsync(pdfOutput, imageTemplatesRequest, dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertBMPToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertBMPToPDF(): Failed to convert BMP to PDF."); + else + { + Console.WriteLine("ConvertBMPToPDF(): image file '{0}' successfully converted to '{1}' file.", bmpFile, pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} \ No newline at end of file diff --git a/Uses-Cases/Conversions/ConvertEPUBToPDF.cs b/Uses-Cases/Conversions/ConvertEPUBToPDF.cs new file mode 100644 index 00000000..e1527602 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertEPUBToPDF.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertEPUBToPDF + { + public static async Task Convert(ConversionsHelper helper, string epubFile, string pdfOutput, string remoteFolder) + { + await helper.UploadFile(epubFile); + + string srcPath = Path.Combine(remoteFolder, epubFile); + + AsposeResponse response = await helper.pdfApi.PutEpubInStorageToPdfAsync(pdfOutput, srcPath, dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertEPUBToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertEPUBToPDF(): Failed to convert EPUB to PDF."); + else + { + Console.WriteLine("ConvertEPUBToPDF(): file '{0}' successfully converted to '{1}' file.", epubFile, pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertGIFToPDF.cs b/Uses-Cases/Conversions/ConvertGIFToPDF.cs new file mode 100644 index 00000000..a6947229 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertGIFToPDF.cs @@ -0,0 +1,34 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertGIFToPDF + { + public static async Task Convert(ConversionsHelper helper, string gifFile, string pdfOutput, string remoteFolder) + { + await helper.UploadFile(gifFile); + + List imageTemplateList = new List { + new ImageTemplate(ImagePath: Path.Combine(remoteFolder, gifFile), ImageSrcType: ImageSrcType.Common) + }; + + ImageTemplatesRequest imageTemplatesRequest = new ImageTemplatesRequest( + IsOCR: true, + OCRLangs: "eng", + ImagesList: imageTemplateList + ); + + AsposeResponse response = await helper.pdfApi.PutImageInStorageToPdfAsync(pdfOutput, imageTemplatesRequest, dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertGIFToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertGIFToPDF(): Failed to convert GIF to PDF."); + else + { + Console.WriteLine("ConvertGIFToPDF(): image file '{0}' successfully converted to '{1}' file.", gifFile, pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertHTMLToPDF.cs b/Uses-Cases/Conversions/ConvertHTMLToPDF.cs new file mode 100644 index 00000000..cf6b7ced --- /dev/null +++ b/Uses-Cases/Conversions/ConvertHTMLToPDF.cs @@ -0,0 +1,31 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertHTMLToPDF + { + public static async Task Convert(ConversionsHelper helper, string htmlFile, string pdfOutput, double pdfWidth, double pdfHeight, string remoteFolder) + { + await helper.UploadFile(htmlFile); + + string srcPath = Path.Combine(remoteFolder, htmlFile); + + AsposeResponse response = await helper.pdfApi.PutHtmlInStorageToPdfAsync( + pdfOutput, srcPath, + htmlFileName: htmlFile, + width: pdfWidth, + height: pdfHeight, + dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertHTMLToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertHTMLToPDF(): Failed to convert HTML to PDF."); + else + { + Console.WriteLine("ConvertHTMLToPDF(): file '{0}' successfully converted to '{1}' file.", htmlFile, pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} \ No newline at end of file diff --git a/Uses-Cases/Conversions/ConvertImagesToPDF.cs b/Uses-Cases/Conversions/ConvertImagesToPDF.cs new file mode 100644 index 00000000..7be3ec8d --- /dev/null +++ b/Uses-Cases/Conversions/ConvertImagesToPDF.cs @@ -0,0 +1,37 @@ +using Aspose.Pdf.Cloud.Sdk.Model; +using System.IO.Compression; + +namespace Conversions +{ + public class ConvertImagesToPDF + { + public static async Task Convert(ConversionsHelper helper, List images, string pdfOutput, string remoteFolder) + { + List imageTemplateList = new List(); + foreach (string image in images) + { + await helper.UploadFile(image); + ImageTemplate template = new ImageTemplate(ImagePath: Path.Combine(remoteFolder, image), ImageSrcType: ImageSrcType.Common); + imageTemplateList.Add(template); + }; + + ImageTemplatesRequest imageTemplatesRequest = new ImageTemplatesRequest( + IsOCR: true, + OCRLangs: "eng", + ImagesList: imageTemplateList + ); + + AsposeResponse response = await helper.pdfApi.PutImageInStorageToPdfAsync(pdfOutput, imageTemplatesRequest, dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertImagesToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertImagesToPDF(): Failed to convert BMP to PDF."); + else + { + Console.WriteLine("ConvertImagesToPDF(): image files successfully converted to '{0}' file.", pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertJPEGToPDF.cs b/Uses-Cases/Conversions/ConvertJPEGToPDF.cs new file mode 100644 index 00000000..4bf15b9f --- /dev/null +++ b/Uses-Cases/Conversions/ConvertJPEGToPDF.cs @@ -0,0 +1,34 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertJPEGToPDF + { + public static async Task Convert(ConversionsHelper helper, string jpegFile, string pdfOutput, string remoteFolder) + { + await helper.UploadFile(jpegFile); + + List imageTemplateList = new List { + new ImageTemplate(ImagePath: Path.Combine(remoteFolder, jpegFile), ImageSrcType: ImageSrcType.Common) + }; + + ImageTemplatesRequest imageTemplatesRequest = new ImageTemplatesRequest( + IsOCR: true, + OCRLangs: "eng", + ImagesList: imageTemplateList + ); + + AsposeResponse response = await helper.pdfApi.PutImageInStorageToPdfAsync(pdfOutput, imageTemplatesRequest, dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertJPEGToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertJPEGToPDF(): Failed to convert JPEG to PDF."); + else + { + Console.WriteLine("ConvertJPEGToPDF(): image file '{0}' successfully converted to '{1}' file.", jpegFile, pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertMDToPDF.cs b/Uses-Cases/Conversions/ConvertMDToPDF.cs new file mode 100644 index 00000000..05d1eef8 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertMDToPDF.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertMarkdownToPDF + { + public static async Task Convert(ConversionsHelper helper, string mdFile, string pdfOutput, string remoteFolder) + { + await helper.UploadFile(mdFile); + + string srcPath = Path.Combine(remoteFolder, mdFile); + + AsposeResponse response = await helper.pdfApi.PutMarkdownInStorageToPdfAsync(pdfOutput, srcPath, dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertMarkdownToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertMarkdownToPDF(): Failed to convert Markdown to PDF."); + else + { + Console.WriteLine("ConvertMarkdownToPDF(): file '{0}' successfully converted to '{1}' file.", mdFile, pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertMHTMLToPDF.cs b/Uses-Cases/Conversions/ConvertMHTMLToPDF.cs new file mode 100644 index 00000000..5722f0d1 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertMHTMLToPDF.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertMHTMLToPDF + { + public static async Task Convert(ConversionsHelper helper, string mhtFile, string pdfOutput, string remoteFolder) + { + await helper.UploadFile(mhtFile); + + string srcPath = Path.Combine(remoteFolder, mhtFile); + + AsposeResponse response = await helper.pdfApi.PutMhtInStorageToPdfAsync(pdfOutput, srcPath, dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertMHTMLToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertMHTMLToPDF(): Failed to convert MHTML to PDF."); + else + { + Console.WriteLine("ConvertMHTMLToPDF(): file '{0}' successfully converted to '{1}' file.", mhtFile, pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPCLToPDF.cs b/Uses-Cases/Conversions/ConvertPCLToPDF.cs new file mode 100644 index 00000000..8ef55457 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPCLToPDF.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPCLToPDF + { + public static async Task Convert(ConversionsHelper helper, string pclFile, string pdfOutput, string remoteFolder) + { + await helper.UploadFile(pclFile); + + string srcPath = Path.Combine(remoteFolder, pclFile); + + AsposeResponse response = await helper.pdfApi.PutPclInStorageToPdfAsync(pdfOutput, srcPath, dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPCLToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPCLToPDF(): Failed to convert PCL to PDF."); + else + { + Console.WriteLine("ConvertPCLToPDF(): file '{0}' successfully converted to '{1}' file.", pclFile, pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPDFToDOC.cs b/Uses-Cases/Conversions/ConvertPDFToDOC.cs new file mode 100644 index 00000000..25c658f4 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToDOC.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToDOC + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputDocName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputDocName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToDocAsync(pdfFile, outPath, format: DocFormat.Doc.ToString(), folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToDOC(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToDOC(): Failed to convert PDF To Doc."); + else + { + Console.WriteLine("ConvertPDFToDOC(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputDocName); + await helper.DownloadFile(outputDocName); + } + } + } +} \ No newline at end of file diff --git a/Uses-Cases/Conversions/ConvertPDFToDOCX.cs b/Uses-Cases/Conversions/ConvertPDFToDOCX.cs new file mode 100644 index 00000000..6350bdc7 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToDOCX.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToDOCX + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputDocxName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputDocxName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToDocAsync(pdfFile, outPath, format: DocFormat.DocX.ToString(), folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToDOCX(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToDOCX(): Failed to convert PDF To Docx."); + else + { + Console.WriteLine("ConvertPDFToDOCX(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputDocxName); + await helper.DownloadFile(outputDocxName); + } + } + } +} \ No newline at end of file diff --git a/Uses-Cases/Conversions/ConvertPDFToEPUB.cs b/Uses-Cases/Conversions/ConvertPDFToEPUB.cs new file mode 100644 index 00000000..4796f95f --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToEPUB.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToEPUB + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputEpubName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputEpubName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToEpubAsync(pdfFile, outPath, folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToEPUB(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToEPUB(): Failed to convert PDF To Epub."); + else + { + Console.WriteLine("ConvertPDFToEPUB(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputEpubName); + await helper.DownloadFile(outputEpubName); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPDFToExcel.cs b/Uses-Cases/Conversions/ConvertPDFToExcel.cs new file mode 100644 index 00000000..cd3a056a --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToExcel.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToExcel + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputExcelName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputExcelName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToXlsAsync(pdfFile, outPath, folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToExcel(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToExcel(): Failed to convert PDF To Excel."); + else + { + Console.WriteLine("ConvertPDFToExcel(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputExcelName); + await helper.DownloadFile(outputExcelName); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPDFToHTML.cs b/Uses-Cases/Conversions/ConvertPDFToHTML.cs new file mode 100644 index 00000000..e9aef38c --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToHTML.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToHTML + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputHtmlZipName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputHtmlZipName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToHtmlAsync(pdfFile, outPath, outputFormat: OutputFormat.Zip.ToString(), folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToHTML(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToHTML(): Failed to convert PDF To HTML."); + else + { + Console.WriteLine("ConvertPDFToHTML(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputHtmlZipName); + await helper.DownloadFile(outputHtmlZipName); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPDFToMobiXML.cs b/Uses-Cases/Conversions/ConvertPDFToMobiXML.cs new file mode 100644 index 00000000..4c11bd48 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToMobiXML.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToMobiXML + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputMobixName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputMobixName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToMobiXmlAsync(pdfFile, outPath, folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToMobiXML(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToMobiXML(): Failed to convert PDF To XSLX."); + else + { + Console.WriteLine("ConvertPDFToMobiXML(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputMobixName); + await helper.DownloadFile(outputMobixName); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPDFToPowerpoint.cs b/Uses-Cases/Conversions/ConvertPDFToPowerpoint.cs new file mode 100644 index 00000000..638c9f40 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToPowerpoint.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToPowerpoint + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputPptxName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputPptxName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToPptxAsync(pdfFile, outPath, folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToPowerpoint(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToPowerpoint(): Failed to convert PDF To PPTX."); + else + { + Console.WriteLine("ConvertPDFToPowerpoint(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputPptxName); + await helper.DownloadFile(outputPptxName); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPDFToSVG.cs b/Uses-Cases/Conversions/ConvertPDFToSVG.cs new file mode 100644 index 00000000..fc74bae3 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToSVG.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToSVG + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputSvgName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputSvgName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToSvgAsync(pdfFile, outPath, folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToSVG(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToSVG(): Failed to convert PDF To SVG."); + else + { + Console.WriteLine("ConvertPDFToSVG(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputSvgName); + await helper.DownloadFile(outputSvgName); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPDFToTEX.cs b/Uses-Cases/Conversions/ConvertPDFToTEX.cs new file mode 100644 index 00000000..f11a19c3 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToTEX.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToTEX + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputTexName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputTexName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToTeXAsync(pdfFile, outPath, folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToTEX(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToTEX(): Failed to convert PDF To TEX."); + else + { + Console.WriteLine("ConvertPDFToTEX(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputTexName); + await helper.DownloadFile(outputTexName); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPDFToTIFF.cs b/Uses-Cases/Conversions/ConvertPDFToTIFF.cs new file mode 100644 index 00000000..f48da802 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToTIFF.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToTIFF + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputTiffName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputTiffName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToTiffAsync(pdfFile, outPath, folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToTIFF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToTIFF(): Failed to convert PDF To TIFF."); + else + { + Console.WriteLine("ConvertPDFToTIFF(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputTiffName); + await helper.DownloadFile(outputTiffName); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPDFToXLSX.cs b/Uses-Cases/Conversions/ConvertPDFToXLSX.cs new file mode 100644 index 00000000..9e38d5e3 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToXLSX.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToXLSX + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputXlsxName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputXlsxName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToXlsxAsync(pdfFile, outPath, folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToXLSX(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToXLSX(): Failed to convert PDF To XSLX."); + else + { + Console.WriteLine("ConvertPDFToXLSX(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputXlsxName); + await helper.DownloadFile(outputXlsxName); + } + } + } +} diff --git a/Uses-Cases/Conversions/ConvertPDFToXML.cs b/Uses-Cases/Conversions/ConvertPDFToXML.cs new file mode 100644 index 00000000..5925ef50 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToXML.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToXML + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputXmlName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputXmlName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToXmlAsync(pdfFile, outPath, folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToXML(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToXML(): Failed to convert PDF To XML."); + else + { + Console.WriteLine("ConvertPDFToXML(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputXmlName); + await helper.DownloadFile(outputXmlName); + } + } + } +} \ No newline at end of file diff --git a/Uses-Cases/Conversions/ConvertPDFToXPS.cs b/Uses-Cases/Conversions/ConvertPDFToXPS.cs new file mode 100644 index 00000000..8b49438e --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPDFToXPS.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPDFToXPS + { + public static async Task Convert(ConversionsHelper helper, string pdfFile, string outputXpsName, string remoteFolder) + { + await helper.UploadFile(pdfFile); + + string outPath = Path.Combine(remoteFolder, outputXpsName); + + AsposeResponse response = await helper.pdfApi.PutPdfInStorageToXpsAsync(pdfFile, outPath, folder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPDFToXPS(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPDFToXPS(): Failed to convert PDF To XPS."); + else + { + Console.WriteLine("ConvertPDFToXPS(): file '{0}' successfully converted to '{1}' file.", pdfFile, outputXpsName); + await helper.DownloadFile(outputXpsName); + } + } + } +} \ No newline at end of file diff --git a/Uses-Cases/Conversions/ConvertPNGToPDF.cs b/Uses-Cases/Conversions/ConvertPNGToPDF.cs new file mode 100644 index 00000000..633e6ee8 --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPNGToPDF.cs @@ -0,0 +1,34 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPNGToPDF + { + public static async Task Convert(ConversionsHelper helper, string pngFile, string pdfOutput, string remoteFolder) + { + await helper.UploadFile(pngFile); + + List imageTemplateList = new List { + new ImageTemplate(ImagePath: Path.Combine(remoteFolder, pngFile), ImageSrcType: ImageSrcType.Common) + }; + + ImageTemplatesRequest imageTemplatesRequest = new ImageTemplatesRequest( + IsOCR: true, + OCRLangs: "eng", + ImagesList: imageTemplateList + ); + + AsposeResponse response = await helper.pdfApi.PutImageInStorageToPdfAsync(pdfOutput, imageTemplatesRequest, dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPNGToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPNGToPDF(): Failed to convert PNG to PDF."); + else + { + Console.WriteLine("ConvertPNGToPDF(): image file '{0}' successfully converted to '{1}' file.", pngFile, pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} \ No newline at end of file diff --git a/Uses-Cases/Conversions/ConvertPSToPDF.cs b/Uses-Cases/Conversions/ConvertPSToPDF.cs new file mode 100644 index 00000000..0101496b --- /dev/null +++ b/Uses-Cases/Conversions/ConvertPSToPDF.cs @@ -0,0 +1,26 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Conversions +{ + public class ConvertPSToPDF + { + public static async Task Convert(ConversionsHelper helper, string psFile, string pdfOutput, string remoteFolder) + { + await helper.UploadFile(psFile); + + string srcPath = Path.Combine(remoteFolder, psFile); + + AsposeResponse response = await helper.pdfApi.PutPsInStorageToPdfAsync(pdfOutput, srcPath, dstFolder: remoteFolder); + + if (response == null) + Console.WriteLine("ConvertPSToPDF(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("ConvertPSToPDF(): Failed to convert PS to PDF."); + else + { + Console.WriteLine("ConvertPSToPDF(): file '{0}' successfully converted to '{1}' file.", psFile, pdfOutput); + await helper.DownloadFile(pdfOutput); + } + } + } +} diff --git a/Uses-Cases/Conversions/Program.cs b/Uses-Cases/Conversions/Program.cs new file mode 100644 index 00000000..fece45a8 --- /dev/null +++ b/Uses-Cases/Conversions/Program.cs @@ -0,0 +1,53 @@ +using Conversions; + +ConversionsHelper helper = new ConversionsHelper(); +ConfigParams config = helper.config; + +await ConvertBMPToPDF.Convert(helper, config.BMP_FILE_NAME, config.PDF_BMP_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertJPEGToPDF.Convert(helper, config.JPEG_FILE_NAME, config.PDF_JPEG_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPNGToPDF.Convert(helper, config.PNG_FILE_NAME, config.PDF_PNG_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertGIFToPDF.Convert(helper, config.GIF_FILE_NAME, config.PDF_GIF_OUTPUT, config.REMOTE_TEMP_FOLDER); + +List images = new List { config.BMP_FILE_NAME, config.JPEG_FILE_NAME, config.PNG_FILE_NAME }; +await ConvertImagesToPDF.Convert(helper, images, config.PDF_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertEPUBToPDF.Convert(helper, config.EPUB_FILE_NAME, config.PDF_EPUB_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertHTMLToPDF.Convert(helper, config.HTML_FILE_NAME, config.PDF_HTML_OUTPUT, config.PDF_HTML_WIDTH, config.PDF_HTML_HEIGHT, config.REMOTE_TEMP_FOLDER); + +await ConvertMHTMLToPDF.Convert(helper, config.MHTML_FILE_NAME, config.PDF_MHTML_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertMarkdownToPDF.Convert(helper, config.MD_FILE_NAME, config.PDF_MD_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPCLToPDF.Convert(helper, config.PCL_FILE_NAME, config.PDF_PCL_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPSToPDF.Convert(helper, config.PS_FILE_NAME, config.PDF_PS_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToDOC.Convert(helper, config.PDF_DOCUMENT, config.DOC_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToDOCX.Convert(helper, config.PDF_DOCUMENT, config.DOCX_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToExcel.Convert(helper, config.PDF_DOCUMENT, config.XLS_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToXLSX.Convert(helper, config.PDF_DOCUMENT, config.XLSX_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToPowerpoint.Convert(helper, config.PDF_DOCUMENT, config.PPTX_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToEPUB.Convert(helper, config.PDF_DOCUMENT, config.EPUB_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToHTML.Convert(helper, config.PDF_DOCUMENT, config.HTML_ZIP_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToMobiXML.Convert(helper, config.PDF_DOCUMENT, config.MXML_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToTEX.Convert(helper, config.PDF_DOCUMENT, config.TEX_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToSVG.Convert(helper, config.PDF_DOCUMENT, config.SVG_ZIP_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToTIFF.Convert(helper, config.PDF_DOCUMENT, config.TIFF_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToXML.Convert(helper, config.PDF_DOCUMENT, config.XML_OUTPUT, config.REMOTE_TEMP_FOLDER); + +await ConvertPDFToXPS.Convert(helper, config.PDF_DOCUMENT, config.XPS_OUTPUT, config.REMOTE_TEMP_FOLDER); \ No newline at end of file diff --git a/Uses-Cases/CreateDocument/ClreatePdfDocumentSimple.cs b/Uses-Cases/CreateDocument/ClreatePdfDocumentSimple.cs new file mode 100644 index 00000000..527583eb --- /dev/null +++ b/Uses-Cases/CreateDocument/ClreatePdfDocumentSimple.cs @@ -0,0 +1,34 @@ +using Aspose.Pdf.Cloud.Sdk.Api; +using Aspose.Pdf.Cloud.Sdk.Model; +using RestSharp; + +namespace CreateDocument +{ + public class ClreatePdfDocumentSimple + { + public ClreatePdfDocumentSimple() + { + string LOCAL_FOLDER = "c:\\Samples"; + string PDF_DOCUMENT = "output_created_simple.pdf"; + string REMOTE_FOLDER = "TempPdfCloud"; + + string AppSID = "*************"; + string AppKey = "*************"; + + PdfApi pdfApi = new PdfApi(AppKey, AppSID); + + DocumentResponse response = pdfApi.PutCreateDocument(PDF_DOCUMENT, folder: REMOTE_FOLDER); + if (response.Code != 200) + Console.WriteLine("ClreatePdfDocumentSimple(): Unexpected error: {0}", response.Messages[0]); + else + { + Console.WriteLine("ClreatePdfDocumentSimple():Document '{0}' successfully created.", PDF_DOCUMENT); + Stream stream = pdfApi.DownloadFile(Path.Combine(REMOTE_FOLDER, PDF_DOCUMENT)); + using var fileStream = File.Create(Path.Combine(LOCAL_FOLDER, PDF_DOCUMENT)); + stream.Position = 0; + stream.CopyTo(fileStream); + Console.WriteLine("ClreatePdfDocumentSimple():Document '{0}' successfully downloaded.", PDF_DOCUMENT); + } + } + } +} diff --git a/Uses-Cases/CreateDocument/CrateDocumentHelper.cs b/Uses-Cases/CreateDocument/CrateDocumentHelper.cs new file mode 100644 index 00000000..94ef2b0b --- /dev/null +++ b/Uses-Cases/CreateDocument/CrateDocumentHelper.cs @@ -0,0 +1,45 @@ +using Aspose.Pdf.Cloud.Sdk.Api; +using Newtonsoft.Json; + +namespace CreateDocument +{ + public class ConfigParams + { + public string CrdentialPath { get; } = ".\\credentials.json"; + public string LOCAL_FOLDER { get; } = "C:\\Samples"; + public string TEMP_FOLDER { get; } = "TempPdfCloud"; + public string LOCAL_RESULT_DOCUMENT_NAME { get; } = "output_sample.pdf"; + public int PAGE_WIDTH { get; } = 590; + public int PAGE_HEIGHT { get; } = 894; + public int PAGES_COUNT { get; } = 5; + } + + public class Credentials + { + public string Id { get; set; } + public string Key { get; set; } + } + + public class CrateDocumentHelper + { + public PdfApi pdfApi { get; private set; } + public ConfigParams config { get; private set; } + + public CrateDocumentHelper() + { + config = new ConfigParams(); + string jsCredText = File.ReadAllText(config.CrdentialPath); + Credentials cred = JsonConvert.DeserializeObject(jsCredText); + pdfApi = new PdfApi(cred.Key, cred.Id); + } + + public async void DownloadFile(string filename) + { + Stream stream = pdfApi.DownloadFile(Path.Combine(config.TEMP_FOLDER, filename)); + using var fileStream = File.Create(Path.Combine(config.LOCAL_FOLDER, config.LOCAL_RESULT_DOCUMENT_NAME)); + stream.Position = 0; + await stream.CopyToAsync(fileStream); + Console.WriteLine("DownloadFile(): File '{0}' successfully downloaded.", filename); + } + } +} diff --git a/Uses-Cases/CreateDocument/CreateDocument.csproj b/Uses-Cases/CreateDocument/CreateDocument.csproj new file mode 100644 index 00000000..683240af --- /dev/null +++ b/Uses-Cases/CreateDocument/CreateDocument.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/Uses-Cases/CreateDocument/CreatePdfDocument.cs b/Uses-Cases/CreateDocument/CreatePdfDocument.cs new file mode 100644 index 00000000..51cf97a7 --- /dev/null +++ b/Uses-Cases/CreateDocument/CreatePdfDocument.cs @@ -0,0 +1,46 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + + +namespace CreateDocument +{ + public class CreatePdfDocument + { + public CreatePdfDocument(CrateDocumentHelper helper) + { + DocumentProperties docProps = new DocumentProperties( + List: new List() { + new DocumentProperty(Name: "prop1", Value: "Value1", BuiltIn: false) + } + ); + + DisplayProperties dispProps = new DisplayProperties() + { + CenterWindow = true, + HideMenuBar = true, + Direction = Direction.L2R, + DisplayDocTitle = true, + HideToolBar = true, + HideWindowUI = true, + NonFullScreenPageMode = PageMode.UseThumbs, + PageLayout = PageLayout.TwoPageLeft, + PageMode = PageMode.UseThumbs + }; + + DefaultPageConfig pageConfig = new DefaultPageConfig(helper.config.PAGE_HEIGHT, helper.config.PAGE_WIDTH); + + DocumentConfig document_config = new DocumentConfig( + DocumentProperties: docProps, + DisplayProperties: dispProps, + DefaultPageConfig: pageConfig, + PagesCount: helper.config.PAGES_COUNT + ); + + DocumentResponse response = helper.pdfApi.PostCreateDocument(helper.config.LOCAL_RESULT_DOCUMENT_NAME, document_config, folder: helper.config.TEMP_FOLDER); + + if (response != null && response.Code == 200) + Console.WriteLine("Document #{0} created.", helper.config.LOCAL_RESULT_DOCUMENT_NAME); + else + Console.WriteLine("Unexpected error!!!"); + } + } +} diff --git a/Uses-Cases/CreateDocument/Program.cs b/Uses-Cases/CreateDocument/Program.cs new file mode 100644 index 00000000..bd294b78 --- /dev/null +++ b/Uses-Cases/CreateDocument/Program.cs @@ -0,0 +1,10 @@ +using CreateDocument; + +CrateDocumentHelper helper = new CrateDocumentHelper (); +CreatePdfDocument pdfCreatror = new CreatePdfDocument(helper); + +helper.DownloadFile(helper.config.LOCAL_RESULT_DOCUMENT_NAME); + +Console.WriteLine(helper.config.LOCAL_RESULT_DOCUMENT_NAME); + +ClreatePdfDocumentSimple simpleDoc = new ClreatePdfDocumentSimple(); \ No newline at end of file diff --git a/Uses-Cases/Merges/MergeDocuments.cs b/Uses-Cases/Merges/MergeDocuments.cs new file mode 100644 index 00000000..4963d11f --- /dev/null +++ b/Uses-Cases/Merges/MergeDocuments.cs @@ -0,0 +1,30 @@ +using Aspose.Pdf.Cloud.Sdk.Model; + +namespace Merges +{ + public class MergeDocuments + { + public static async Task Merge(MergesHelper helper, List files, string outputName, string remoteFolder) + { + Aspose.Pdf.Cloud.Sdk.Model.MergeDocuments documetItems = new(new List()); + + foreach (var file in files) + { + await helper.UploadFile(Path.GetFileName(file)); + documetItems.List.Add(Path.Combine( remoteFolder, file)); + } + + DocumentResponse response = await helper.pdfApi.PutMergeDocumentsAsync(outputName, documetItems, folder: remoteFolder); + + if (response == null) + Console.WriteLine("MergeDocuments(): Unexpected error!"); + else if (response.Code < 200 || response.Code > 299) + Console.WriteLine("MergeDocuments(): Failed to documents."); + else + { + Console.WriteLine("MergeDocuments(): documents successfully merged to '{0}' file.", outputName); + await helper.DownloadFile(outputName); + } + } + } +} diff --git a/Uses-Cases/Merges/Merges.csproj b/Uses-Cases/Merges/Merges.csproj new file mode 100644 index 00000000..683240af --- /dev/null +++ b/Uses-Cases/Merges/Merges.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/Uses-Cases/Merges/MergesHelper.cs b/Uses-Cases/Merges/MergesHelper.cs new file mode 100644 index 00000000..683dadf7 --- /dev/null +++ b/Uses-Cases/Merges/MergesHelper.cs @@ -0,0 +1,61 @@ +using Aspose.Pdf.Cloud.Sdk.Api; +using Aspose.Pdf.Cloud.Sdk.Model; +using Newtonsoft.Json; + +namespace Merges +{ + public class ConfigParams + { + public string CrdentialPath { get; } = ".\\credentials.json"; + public string LOCAL_FOLDER { get; } = "C:\\Samples"; + public string REMOTE_TEMP_FOLDER { get; } = "TempPdfCloud"; + public string PDF_DOCUMENT { get; } = "sample.pdf"; + public string PDF_DOCUMENT_2 { get; } = "sample_2.pdf"; + public string PDF_DOCUMENT_3 { get; } = "sample_3.pdf"; + public string PDF_OUTPUT { get; } = "output_sample.pdf"; + } + + public class Credentials + { + public string Id { get; set; } + public string Key { get; set; } + } + + public class MergesHelper + { + public PdfApi pdfApi { get; private set; } + public ConfigParams config { get; private set; } + + public MergesHelper() + { + config = new ConfigParams(); + string jsCredText = File.ReadAllText(config.CrdentialPath); + Credentials cred = JsonConvert.DeserializeObject(jsCredText); + pdfApi = new PdfApi(cred.Key, cred.Id); + } + + public async Task UploadFile(string fileName) + { + using (var file = File.OpenRead(Path.Combine(config.LOCAL_FOLDER, fileName))) + { + FilesUploadResult response = await pdfApi.UploadFileAsync(Path.Combine(config.REMOTE_TEMP_FOLDER, fileName), file); + if (response == null) + Console.WriteLine("UploadFile(): Unexpected error - no response!"); + else if (response.Errors != null && response.Errors.Count > 0) + foreach (var error in response.Errors) + Console.WriteLine("UploadFile(): {0} -> {1}", [error.Code, error.Message]); + else + Console.WriteLine("UploadFile(): File '{0}' successfully uploaded.", fileName); + } + } + + public async Task DownloadFile(string fileName) + { + Stream stream = pdfApi.DownloadFile(Path.Combine(config.REMOTE_TEMP_FOLDER, fileName)); + using var fileStream = File.Create(Path.Combine(config.LOCAL_FOLDER, fileName)); + stream.Position = 0; + await stream.CopyToAsync(fileStream); + Console.WriteLine("DownloadFile(): File '{0}' successfully downloaded.", fileName); + } + } +} diff --git a/Uses-Cases/Merges/Program.cs b/Uses-Cases/Merges/Program.cs new file mode 100644 index 00000000..8365293c --- /dev/null +++ b/Uses-Cases/Merges/Program.cs @@ -0,0 +1,6 @@ +using Merges; + +MergesHelper helper = new MergesHelper(); +ConfigParams config = helper.config; + +await MergeDocuments.Merge(helper, new List { config.PDF_DOCUMENT, config.PDF_DOCUMENT_2, config.PDF_DOCUMENT_3 }, config.PDF_OUTPUT, config.REMOTE_TEMP_FOLDER); diff --git a/build.bat b/build.bat deleted file mode 100644 index 5455d8e3..00000000 --- a/build.bat +++ /dev/null @@ -1,16 +0,0 @@ -:: Generated by: https://github.com/swagger-api/swagger-codegen.git -:: - -@echo off - -SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319 - -if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.\nuget.exe')" -.\nuget.exe install src\Aspose.Pdf.Cloud.Sdk\packages.config -o packages - -if not exist ".\bin" mkdir bin - -copy packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll -copy packages\RestSharp.106.2.2\lib\net45\RestSharp.dll bin\RestSharp.dll -%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\RestSharp.dll;System.ComponentModel.DataAnnotations.dll /target:library /out:bin\Aspose.Pdf.Cloud.Sdk.dll /recurse:src\Aspose.Pdf.Cloud.Sdk\*.cs /doc:bin\Aspose.Pdf.Cloud.Sdk.xml - diff --git a/docs/PdfApi.md b/docs/PdfApi.md index bfd38897..87ae766e 100644 --- a/docs/PdfApi.md +++ b/docs/PdfApi.md @@ -212,6 +212,7 @@ Method | HTTP request | Description [**PostDocumentImageStamps**](PdfApi.md#postdocumentimagestamps) | **POST** /pdf/\{name}/stamps/image | Add document pages image stamps. [**PostDocumentImageStampsPageSpecified**](PdfApi.md#postdocumentimagestampspagespecified) | **POST** /pdf/\{name}/stamps/image/pagespecified | Add document image stamps to specified pages. [**PostDocumentPageNumberStamps**](PdfApi.md#postdocumentpagenumberstamps) | **POST** /pdf/\{name}/stamps/pagenumber | Add document page number stamps. +[**PostDocumentPagesRotate**](PdfApi.md#postdocumentpagesrotate) | **POST** /pdf/\{name}/rotate | Rotate PDF document. [**PostDocumentTextFooter**](PdfApi.md#postdocumenttextfooter) | **POST** /pdf/\{name}/footer/text | Add document text footer. [**PostDocumentTextHeader**](PdfApi.md#postdocumenttextheader) | **POST** /pdf/\{name}/header/text | Add document text header. [**PostDocumentTextReplace**](PdfApi.md#postdocumenttextreplace) | **POST** /pdf/\{name}/text/replace | Document's replace text method. @@ -6076,6 +6077,35 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **PostDocumentPagesRotate** +> AsposeResponse PostDocumentPagesRotate (string name, string rotationAngle, string pages, string storage = null, string folder = null, string password = null) + +Rotate PDF document. + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **name** | **string**| The document name. | + **rotationAngle** | **string**| Rotation Angle (CKW). Can be 90, 180, 270. | + **pages** | **string**| Comma separated list of pages and page ranges. (Example: 1,3-5,8) | + **storage** | **string**| The document storage. | [optional] + **folder** | **string**| The document folder. | [optional] + **password** | **string**| Base64 encoded password. | [optional] + +### Return type + +[**AsposeResponse**](AsposeResponse.md) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **PostDocumentTextFooter** > AsposeResponse PostDocumentTextFooter (string name, TextFooter textFooter, int? startPageNumber = null, int? endPageNumber = null, string storage = null, string folder = null) diff --git a/docs/SignatureCustomAppearance.md b/docs/SignatureCustomAppearance.md index 89aa6920..0626d594 100644 --- a/docs/SignatureCustomAppearance.md +++ b/docs/SignatureCustomAppearance.md @@ -6,7 +6,8 @@ An abstract class which represents signature custom appearance object. Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **FontFamilyName** | **string** | Gets/sets font family name. It should be existed in the document. Default value: Arial. | [optional] -**FontSize** | **double?** | Gets/sets font size. Default value: 10. | +**FontSize** | **double?** | Gets/sets font size. Default value: 10. | [optional] +**Rotation** | [**Rotation**](Rotation.md) | Gets or sets signature rotation. | **ShowContactInfo** | **bool?** | Gets/sets contact info visibility. Default value: true. | **ShowReason** | **bool?** | Gets/sets reason visibility. Default value: true. | **ShowLocation** | **bool?** | Gets/sets location visibility. Default value: true. | @@ -17,6 +18,10 @@ Name | Type | Description | Notes **DateSignedAtLabel** | **string** | Gets/sets date signed label. Default value: "Date". | [optional] **DateTimeLocalFormat** | **string** | Gets/sets datetime local format. Default value: "yyyy.MM.dd HH:mm:ss zzz". | [optional] **DateTimeFormat** | **string** | Gets/sets datetime format. Default value: "yyyy.MM.dd HH:mm:ss". | [optional] +**BackgroundColor** | [**Color**](Color.md) | Gets/sets background color. | [optional] +**ForegroundColor** | [**Color**](Color.md) | Gets/sets foreground color. | [optional] +**UseDigitalSubjectFormat** | **bool?** | Gets/sets subject format usage. | +**DigitalSubjectFormat** | [**List<SignatureSubjectNameElements>**](SignatureSubjectNameElements.md) | Gets/sets subject format. | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/SignatureSubjectNameElements.md b/docs/SignatureSubjectNameElements.md new file mode 100644 index 00000000..1481549c --- /dev/null +++ b/docs/SignatureSubjectNameElements.md @@ -0,0 +1,18 @@ +# Aspose.Pdf.Cloud.Sdk.Model.SignatureSubjectNameElements +Represents an enumeration of available SubjectNameElements. + +## Enum + + Name | Description +------------ | ------------ +**CN** | Common Name. +**O** | Organization. +**L** | Locality. +**OU** | Organizational Unit. +**S** | State or Province Name. +**C** | Common Name. +**E** | Email. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/src/Aspose.PDF.Cloud.Examples/Aspose.PDF.Cloud.Examples.csproj b/src/Aspose.PDF.Cloud.Examples/Aspose.PDF.Cloud.Examples.csproj index 97a79df9..8f99d7d0 100644 --- a/src/Aspose.PDF.Cloud.Examples/Aspose.PDF.Cloud.Examples.csproj +++ b/src/Aspose.PDF.Cloud.Examples/Aspose.PDF.Cloud.Examples.csproj @@ -2,11 +2,11 @@ Exe - netcoreapp3.0 + net8.0;net452 - + diff --git a/src/Aspose.Pdf.Cloud.Sdk.Test/Aspose.Pdf.Cloud.Sdk.Test.Core.csproj b/src/Aspose.Pdf.Cloud.Sdk.Test/Aspose.Pdf.Cloud.Sdk.Test.Core.csproj deleted file mode 100644 index 6110759f..00000000 --- a/src/Aspose.Pdf.Cloud.Sdk.Test/Aspose.Pdf.Cloud.Sdk.Test.Core.csproj +++ /dev/null @@ -1,73 +0,0 @@ - - - net6.0 - Aspose.Pdf.Cloud.Sdk.Test - Aspose.Pdf.Cloud.Sdk.Test - false - false - false - false - Debug;Release - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Aspose.Pdf.Cloud.Sdk.Test/Aspose.Pdf.Cloud.Sdk.Test.csproj b/src/Aspose.Pdf.Cloud.Sdk.Test/Aspose.Pdf.Cloud.Sdk.Test.csproj index df227046..d8456085 100644 --- a/src/Aspose.Pdf.Cloud.Sdk.Test/Aspose.Pdf.Cloud.Sdk.Test.csproj +++ b/src/Aspose.Pdf.Cloud.Sdk.Test/Aspose.Pdf.Cloud.Sdk.Test.csproj @@ -1,126 +1,24 @@ - - - + - Debug - AnyCPU - {19F1DEBC-DE5E-4517-8062-F000CD499087} + net452;net8.0 Library - Properties - Aspose.Pdf.Cloud.Sdk.Test - Aspose.Pdf.Cloud.Sdk.Test - v4.5.2 - 512 - + Aspose.Pdf.Cloud.Sdk.Test + Aspose.Pdf.Cloud.Sdk.Test + bin\$(Configuration)\$(TargetFramework) - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - - - - - - - - - - - - - $(SolutionDir)\packages\NUnit.2.6.4\lib\nunit.framework.dll - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - ..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll - ..\..\vendor\NUnit.2.6.4\lib\nunit.framework.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {ef4ce7ef-dd3c-4654-8b0a-4bf813184ee4} - Aspose.Pdf.Cloud.Sdk - + - + + + + - + + + + + + \ No newline at end of file diff --git a/src/Aspose.Pdf.Cloud.Sdk.Test/DocumentTests.cs b/src/Aspose.Pdf.Cloud.Sdk.Test/DocumentTests.cs index 87db6455..a684b463 100644 --- a/src/Aspose.Pdf.Cloud.Sdk.Test/DocumentTests.cs +++ b/src/Aspose.Pdf.Cloud.Sdk.Test/DocumentTests.cs @@ -259,5 +259,19 @@ public void PostOrganizeDocumentsTest() ); Assert.That(response.Code, Is.EqualTo(200)); } + + /// + /// Test PostDocumentPagesRotate + /// + [Test] + + public void PostDocumentPagesRotateTest() + { + const string name1 = "4pages.pdf"; + UploadFile(name1, name1); + + var response = PdfApi.PostDocumentPagesRotate(name1, Rotation.On90.ToString(), "2-3", folder: TempFolder); + Assert.That(response.Code, Is.EqualTo(200)); + } } } diff --git a/src/Aspose.Pdf.Cloud.Sdk.Test/ImagesTests.cs b/src/Aspose.Pdf.Cloud.Sdk.Test/ImagesTests.cs index d8a04eee..f609ccc1 100644 --- a/src/Aspose.Pdf.Cloud.Sdk.Test/ImagesTests.cs +++ b/src/Aspose.Pdf.Cloud.Sdk.Test/ImagesTests.cs @@ -114,10 +114,19 @@ public void PutReplaceMultipleImageTest() const string name = "PdfWithImages.pdf"; UploadFile(name, name); const string imageName = "butterfly.jpg"; - UploadFile(imageName, imageName); + UploadFile(imageName, imageName); + + var imagesResponse1 = PdfApi.GetImages(name, pageNumber: 1, folder: TempFolder); + Assert.That(imagesResponse1.Code, Is.EqualTo(200)); + var imageId1 = imagesResponse1.Images.List[0].Id; + + var imagesResponse2 = PdfApi.GetImages(name, pageNumber: 16, folder: TempFolder); + Assert.That(imagesResponse2.Code, Is.EqualTo(200)); + var imageId2 = imagesResponse2.Images.List[0].Id; + var response = PdfApi.PutReplaceMultipleImage( name: name, - imageIds: new List{"GE5TENJVGQZTWMJYGQWDINRUFQ2DCMRMGY4TC", "GE5TIMJSGY3TWMJXG4WDIMBZFQ2DCOJMGQ3DK"}, + imageIds: new List{imageId1, imageId2}, imageFilePath: Path.Combine(TempFolder, imageName), folder: TempFolder); Assert.That(response.Code, Is.EqualTo(200)); diff --git a/src/Aspose.Pdf.Cloud.Sdk.Test/TestBase.cs b/src/Aspose.Pdf.Cloud.Sdk.Test/TestBase.cs index 45e4b0e9..be0d8aef 100644 --- a/src/Aspose.Pdf.Cloud.Sdk.Test/TestBase.cs +++ b/src/Aspose.Pdf.Cloud.Sdk.Test/TestBase.cs @@ -25,6 +25,7 @@ using System; using System.IO; +using System.Net; using Aspose.Pdf.Cloud.Sdk.Api; using Aspose.Pdf.Cloud.Sdk.Client; using Newtonsoft.Json; @@ -35,9 +36,28 @@ namespace Aspose.Pdf.Cloud.Sdk.Test { public abstract class TestsBase { private const string BaseProductUri = @"https://api.aspose.cloud"; - protected const string TestDataFolder = @"../../../../../testData"; private const string ServerCredsFile = @"Settings/servercreds.json"; protected const string TempFolder = "TempPdfCloud"; + + protected string TestDataFolder + { + get + { + string path = Directory.GetCurrentDirectory(); + while(Directory.GetParent(path) != null) + { + string testdataPath = Path.Combine(path, "testData"); + if (Directory.Exists(testdataPath)) + { + return testdataPath; + } + + path = Directory.GetParent(path).FullName; + } + + throw new DirectoryNotFoundException(); + } + } private class Creds { public string AppSID { get; set; } @@ -66,6 +86,7 @@ private Creds _GetCreds() { [SetUp] public virtual void SetUp() { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Console.WriteLine(TestContext.CurrentContext.Test.Name); // To run tests with your own credentials please uncomment following line of code // this._creds = new Creds { AppKey = "your app key", AppSID = "your app sid" }; diff --git a/src/Aspose.Pdf.Cloud.Sdk.Test/packages.config b/src/Aspose.Pdf.Cloud.Sdk.Test/packages.config deleted file mode 100644 index 64e63bf0..00000000 --- a/src/Aspose.Pdf.Cloud.Sdk.Test/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Aspose.Pdf.Cloud.Sdk/Api/PdfApi.cs b/src/Aspose.Pdf.Cloud.Sdk/Api/PdfApi.cs index 39ff5f7f..b4bedf17 100644 --- a/src/Aspose.Pdf.Cloud.Sdk/Api/PdfApi.cs +++ b/src/Aspose.Pdf.Cloud.Sdk/Api/PdfApi.cs @@ -5809,6 +5809,37 @@ public interface IPdfApi : IApiAccessor /// ApiResponse of AsposeResponse ApiResponse PostDocumentPageNumberStampsWithHttpInfo (string name, PageNumberStamp stamp, int? startPageNumber = null, int? endPageNumber = null, string storage = null, string folder = null, string password = null); /// + /// Rotate PDF document. + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The document name. + /// Rotation Angle (CKW). Can be 90, 180, 270. + /// Comma separated list of pages and page ranges. (Example: 1,3-5,8) + /// The document storage. (optional) + /// The document folder. (optional) + /// Base64 encoded password. (optional) + /// AsposeResponse + AsposeResponse PostDocumentPagesRotate (string name, string rotationAngle, string pages, string storage = null, string folder = null, string password = null); + + /// + /// Rotate PDF document. + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The document name. + /// Rotation Angle (CKW). Can be 90, 180, 270. + /// Comma separated list of pages and page ranges. (Example: 1,3-5,8) + /// The document storage. (optional) + /// The document folder. (optional) + /// Base64 encoded password. (optional) + /// ApiResponse of AsposeResponse + ApiResponse PostDocumentPagesRotateWithHttpInfo (string name, string rotationAngle, string pages, string storage = null, string folder = null, string password = null); + /// /// Add document text footer. /// /// @@ -16778,6 +16809,37 @@ public interface IPdfApi : IApiAccessor /// Task of ApiResponse (AsposeResponse) System.Threading.Tasks.Task> PostDocumentPageNumberStampsAsyncWithHttpInfo (string name, PageNumberStamp stamp, int? startPageNumber = null, int? endPageNumber = null, string storage = null, string folder = null, string password = null); /// + /// Rotate PDF document. + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The document name. + /// Rotation Angle (CKW). Can be 90, 180, 270. + /// Comma separated list of pages and page ranges. (Example: 1,3-5,8) + /// The document storage. (optional) + /// The document folder. (optional) + /// Base64 encoded password. (optional) + /// Task of AsposeResponse + System.Threading.Tasks.Task PostDocumentPagesRotateAsync (string name, string rotationAngle, string pages, string storage = null, string folder = null, string password = null); + + /// + /// Rotate PDF document. + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The document name. + /// Rotation Angle (CKW). Can be 90, 180, 270. + /// Comma separated list of pages and page ranges. (Example: 1,3-5,8) + /// The document storage. (optional) + /// The document folder. (optional) + /// Base64 encoded password. (optional) + /// Task of ApiResponse (AsposeResponse) + System.Threading.Tasks.Task> PostDocumentPagesRotateAsyncWithHttpInfo (string name, string rotationAngle, string pages, string storage = null, string folder = null, string password = null); + /// /// Add document text footer. /// /// @@ -54738,6 +54800,180 @@ public async System.Threading.Tasks.Task> PostDocume (AsposeResponse) ApiClient.Deserialize(localVarResponse, typeof(AsposeResponse))); } + /// Rotate PDF document. + /// + /// Thrown when fails to make API call + /// The document name. + /// Rotation Angle (CKW). Can be 90, 180, 270. + /// Comma separated list of pages and page ranges. (Example: 1,3-5,8) + /// The document storage. (optional) + /// The document folder. (optional) + /// Base64 encoded password. (optional) + /// AsposeResponse + public AsposeResponse PostDocumentPagesRotate (string name, string rotationAngle, string pages, string storage = null, string folder = null, string password = null) + { + ApiResponse localVarResponse = PostDocumentPagesRotateWithHttpInfo(name, rotationAngle, pages, storage, folder, password); + return localVarResponse.Data; + } + + /// + /// Rotate PDF document. + /// + /// Thrown when fails to make API call + /// The document name. + /// Rotation Angle (CKW). Can be 90, 180, 270. + /// Comma separated list of pages and page ranges. (Example: 1,3-5,8) + /// The document storage. (optional) + /// The document folder. (optional) + /// Base64 encoded password. (optional) + /// ApiResponse of AsposeResponse + public ApiResponse< AsposeResponse > PostDocumentPagesRotateWithHttpInfo (string name, string rotationAngle, string pages, string storage = null, string folder = null, string password = null) + { + // verify the required parameter 'name' is set + if (name == null) + throw new ApiException(400, "Missing required parameter 'name' when calling PdfApi->PostDocumentPagesRotate"); + // verify the required parameter 'rotationAngle' is set + if (rotationAngle == null) + throw new ApiException(400, "Missing required parameter 'rotationAngle' when calling PdfApi->PostDocumentPagesRotate"); + // verify the required parameter 'pages' is set + if (pages == null) + throw new ApiException(400, "Missing required parameter 'pages' when calling PdfApi->PostDocumentPagesRotate"); + + var localVarPath = "/pdf/{name}/rotate"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json" + }; + String localVarHttpContentType = ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json" + }; + String localVarHttpHeaderAccept = ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (name != null) localVarPathParams.Add("name", ApiClient.ParameterToString(name)); // path parameter + if (rotationAngle != null) localVarQueryParams.Add("rotationAngle", ApiClient.ParameterToString(rotationAngle)); // query parameter + if (pages != null) localVarQueryParams.Add("pages", ApiClient.ParameterToString(pages)); // query parameter + if (storage != null) localVarQueryParams.Add("storage", ApiClient.ParameterToString(storage)); // query parameter + if (folder != null) localVarQueryParams.Add("folder", ApiClient.ParameterToString(folder)); // query parameter + if (password != null) localVarQueryParams.Add("password", ApiClient.ParameterToString(password)); // query parameter + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("PostDocumentPagesRotate", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (AsposeResponse) ApiClient.Deserialize(localVarResponse, typeof(AsposeResponse))); + } + + /// + /// Rotate PDF document. + /// + /// Thrown when fails to make API call + /// The document name. + /// Rotation Angle (CKW). Can be 90, 180, 270. + /// Comma separated list of pages and page ranges. (Example: 1,3-5,8) + /// The document storage. (optional) + /// The document folder. (optional) + /// Base64 encoded password. (optional) + /// Task of AsposeResponse + public async System.Threading.Tasks.Task PostDocumentPagesRotateAsync (string name, string rotationAngle, string pages, string storage = null, string folder = null, string password = null) + { + ApiResponse localVarResponse = await PostDocumentPagesRotateAsyncWithHttpInfo(name, rotationAngle, pages, storage, folder, password); + return localVarResponse.Data; + + } + + /// + /// Rotate PDF document. + /// + /// Thrown when fails to make API call + /// The document name. + /// Rotation Angle (CKW). Can be 90, 180, 270. + /// Comma separated list of pages and page ranges. (Example: 1,3-5,8) + /// The document storage. (optional) + /// The document folder. (optional) + /// Base64 encoded password. (optional) + /// Task of ApiResponse (AsposeResponse) + public async System.Threading.Tasks.Task> PostDocumentPagesRotateAsyncWithHttpInfo (string name, string rotationAngle, string pages, string storage = null, string folder = null, string password = null) + { + // verify the required parameter 'name' is set + if (name == null) + throw new ApiException(400, "Missing required parameter 'name' when calling PdfApi->PostDocumentPagesRotate"); + // verify the required parameter 'rotationAngle' is set + if (rotationAngle == null) + throw new ApiException(400, "Missing required parameter 'rotationAngle' when calling PdfApi->PostDocumentPagesRotate"); + // verify the required parameter 'pages' is set + if (pages == null) + throw new ApiException(400, "Missing required parameter 'pages' when calling PdfApi->PostDocumentPagesRotate"); + + var localVarPath = "/pdf/{name}/rotate"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json" + }; + String localVarHttpContentType = ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json" + }; + String localVarHttpHeaderAccept = ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (name != null) localVarPathParams.Add("name", ApiClient.ParameterToString(name)); // path parameter + if (rotationAngle != null) localVarQueryParams.Add("rotationAngle", ApiClient.ParameterToString(rotationAngle)); // query parameter + if (pages != null) localVarQueryParams.Add("pages", ApiClient.ParameterToString(pages)); // query parameter + if (storage != null) localVarQueryParams.Add("storage", ApiClient.ParameterToString(storage)); // query parameter + if (folder != null) localVarQueryParams.Add("folder", ApiClient.ParameterToString(folder)); // query parameter + if (password != null) localVarQueryParams.Add("password", ApiClient.ParameterToString(password)); // query parameter + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) await ApiClient.CallApiAsync(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("PostDocumentPagesRotate", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (AsposeResponse) ApiClient.Deserialize(localVarResponse, typeof(AsposeResponse))); + } + /// Add document text footer. /// /// Thrown when fails to make API call diff --git a/src/Aspose.Pdf.Cloud.Sdk/Aspose.Pdf.Cloud.Sdk.Core.csproj b/src/Aspose.Pdf.Cloud.Sdk/Aspose.Pdf.Cloud.Sdk.Core.csproj deleted file mode 100644 index 7b41d834..00000000 --- a/src/Aspose.Pdf.Cloud.Sdk/Aspose.Pdf.Cloud.Sdk.Core.csproj +++ /dev/null @@ -1,328 +0,0 @@ - - - - - netstandard2.0 - Aspose.Pdf.Cloud.Sdk - Aspose.Pdf.Cloud.Sdk - false - false - false - false - Debug;Release - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Aspose.Pdf.Cloud.Sdk/Aspose.Pdf.Cloud.Sdk.csproj b/src/Aspose.Pdf.Cloud.Sdk/Aspose.Pdf.Cloud.Sdk.csproj index 6ba93309..136d4aae 100644 --- a/src/Aspose.Pdf.Cloud.Sdk/Aspose.Pdf.Cloud.Sdk.csproj +++ b/src/Aspose.Pdf.Cloud.Sdk/Aspose.Pdf.Cloud.Sdk.csproj @@ -1,371 +1,22 @@ - - - + - Debug - AnyCPU - {7AAE99B5-38CC-49C2-918C-B06E5E275C79} Library - Properties - Aspose.Pdf.Cloud.Sdk - Aspose.Pdf.Cloud.Sdk - v4.5.2 - 512 - + net452;netstandard2.0 + false + True + false + true - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - bin\Release\$(AssemblyName).xml - - - - ..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - - - ..\..\packages\RestSharp.106.12.0\lib\net452\RestSharp.dll - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - Designer - + + - \ No newline at end of file diff --git a/src/Aspose.Pdf.Cloud.Sdk/Aspose.Pdf.Cloud.Sdk.sln b/src/Aspose.Pdf.Cloud.Sdk/Aspose.Pdf.Cloud.Sdk.sln deleted file mode 100644 index 3e3602e7..00000000 --- a/src/Aspose.Pdf.Cloud.Sdk/Aspose.Pdf.Cloud.Sdk.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.002.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspose.Pdf.Cloud.Sdk.Core", "Aspose.Pdf.Cloud.Sdk.Core.csproj", "{F91B78AA-98F8-4988-A5BF-E48D43DAE7C5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspose.Pdf.Cloud.Sdk", "Aspose.Pdf.Cloud.Sdk.csproj", "{5578603F-D47F-4876-95D6-2108E48C13F0}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F91B78AA-98F8-4988-A5BF-E48D43DAE7C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F91B78AA-98F8-4988-A5BF-E48D43DAE7C5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F91B78AA-98F8-4988-A5BF-E48D43DAE7C5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F91B78AA-98F8-4988-A5BF-E48D43DAE7C5}.Release|Any CPU.Build.0 = Release|Any CPU - {5578603F-D47F-4876-95D6-2108E48C13F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5578603F-D47F-4876-95D6-2108E48C13F0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5578603F-D47F-4876-95D6-2108E48C13F0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5578603F-D47F-4876-95D6-2108E48C13F0}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {3C4327D3-C6E2-4087-8B8B-D3E58E513A2C} - EndGlobalSection -EndGlobal diff --git a/src/Aspose.Pdf.Cloud.Sdk/Client/ApiClient.cs b/src/Aspose.Pdf.Cloud.Sdk/Client/ApiClient.cs index 86c7d2ab..523e9784 100644 --- a/src/Aspose.Pdf.Cloud.Sdk/Client/ApiClient.cs +++ b/src/Aspose.Pdf.Cloud.Sdk/Client/ApiClient.cs @@ -241,7 +241,7 @@ private RestRequest PrepareRequest( // add custom header request.AddHeader(AsposeClientHeaderName, ".net sdk"); - request.AddHeader(AsposeClientVersionHeaderName, "25.5.0"); + request.AddHeader(AsposeClientVersionHeaderName, "25.7.0"); // add header parameter, if any foreach(var param in headerParams) diff --git a/src/Aspose.Pdf.Cloud.Sdk/Client/Configuration.cs b/src/Aspose.Pdf.Cloud.Sdk/Client/Configuration.cs index 46c5fb65..7fd852a8 100644 --- a/src/Aspose.Pdf.Cloud.Sdk/Client/Configuration.cs +++ b/src/Aspose.Pdf.Cloud.Sdk/Client/Configuration.cs @@ -225,7 +225,7 @@ public static string ToDebugReport() .GetReferencedAssemblies() .Where(x => x.Name == "System.Core").First().Version.ToString() + "\n"; report += " Version of the API: 3.0\n"; - report += " SDK Package Version: 25.5.0\n"; + report += " SDK Package Version: 25.7.0\n"; return report; } diff --git a/src/Aspose.Pdf.Cloud.Sdk/Model/SignatureCustomAppearance.cs b/src/Aspose.Pdf.Cloud.Sdk/Model/SignatureCustomAppearance.cs index c12de5b0..22a3aeef 100644 --- a/src/Aspose.Pdf.Cloud.Sdk/Model/SignatureCustomAppearance.cs +++ b/src/Aspose.Pdf.Cloud.Sdk/Model/SignatureCustomAppearance.cs @@ -55,7 +55,8 @@ protected SignatureCustomAppearance() { } /// Initializes a new instance of the class. /// /// Gets/sets font family name. It should be existed in the document. Default value: Arial. - /// Gets/sets font size. Default value: 10. (required) + /// Gets/sets font size. Default value: 10. + /// Gets or sets signature rotation. (required) /// Gets/sets contact info visibility. Default value: true. (required) /// Gets/sets reason visibility. Default value: true. (required) /// Gets/sets location visibility. Default value: true. (required) @@ -66,16 +67,20 @@ protected SignatureCustomAppearance() { } /// Gets/sets date signed label. Default value: \"Date\". /// Gets/sets datetime local format. Default value: \"yyyy.MM.dd HH:mm:ss zzz\". /// Gets/sets datetime format. Default value: \"yyyy.MM.dd HH:mm:ss\". - public SignatureCustomAppearance(string FontFamilyName = default(string), double? FontSize = default(double?), bool? ShowContactInfo = default(bool?), bool? ShowReason = default(bool?), bool? ShowLocation = default(bool?), string ContactInfoLabel = default(string), string ReasonLabel = default(string), string LocationLabel = default(string), string DigitalSignedLabel = default(string), string DateSignedAtLabel = default(string), string DateTimeLocalFormat = default(string), string DateTimeFormat = default(string)) + /// Gets/sets background color. + /// Gets/sets foreground color. + /// Gets/sets subject format usage. (required) + /// Gets/sets subject format. + public SignatureCustomAppearance(string FontFamilyName = default(string), double? FontSize = default(double?), Rotation Rotation = default(Rotation), bool? ShowContactInfo = default(bool?), bool? ShowReason = default(bool?), bool? ShowLocation = default(bool?), string ContactInfoLabel = default(string), string ReasonLabel = default(string), string LocationLabel = default(string), string DigitalSignedLabel = default(string), string DateSignedAtLabel = default(string), string DateTimeLocalFormat = default(string), string DateTimeFormat = default(string), Color BackgroundColor = default(Color), Color ForegroundColor = default(Color), bool? UseDigitalSubjectFormat = default(bool?), List DigitalSubjectFormat = default(List)) { - // to ensure "FontSize" is required (not null) - if (FontSize == null) + // to ensure "Rotation" is required (not null) + if (Rotation == null) { - throw new InvalidDataException("FontSize is a required property for SignatureCustomAppearance and cannot be null"); + throw new InvalidDataException("Rotation is a required property for SignatureCustomAppearance and cannot be null"); } else { - this.FontSize = FontSize; + this.Rotation = Rotation; } // to ensure "ShowContactInfo" is required (not null) if (ShowContactInfo == null) @@ -104,7 +109,17 @@ protected SignatureCustomAppearance() { } { this.ShowLocation = ShowLocation; } + // to ensure "UseDigitalSubjectFormat" is required (not null) + if (UseDigitalSubjectFormat == null) + { + throw new InvalidDataException("UseDigitalSubjectFormat is a required property for SignatureCustomAppearance and cannot be null"); + } + else + { + this.UseDigitalSubjectFormat = UseDigitalSubjectFormat; + } this.FontFamilyName = FontFamilyName; + this.FontSize = FontSize; this.ContactInfoLabel = ContactInfoLabel; this.ReasonLabel = ReasonLabel; this.LocationLabel = LocationLabel; @@ -112,6 +127,9 @@ protected SignatureCustomAppearance() { } this.DateSignedAtLabel = DateSignedAtLabel; this.DateTimeLocalFormat = DateTimeLocalFormat; this.DateTimeFormat = DateTimeFormat; + this.BackgroundColor = BackgroundColor; + this.ForegroundColor = ForegroundColor; + this.DigitalSubjectFormat = DigitalSubjectFormat; } /// @@ -128,6 +146,13 @@ protected SignatureCustomAppearance() { } [DataMember(Name="FontSize", EmitDefaultValue=false)] public double? FontSize { get; set; } + /// + /// Gets or sets signature rotation. + /// + /// Gets or sets signature rotation. + [DataMember(Name="Rotation", EmitDefaultValue=true)] + public Rotation Rotation { get; set; } + /// /// Gets/sets contact info visibility. Default value: true. /// @@ -198,6 +223,34 @@ protected SignatureCustomAppearance() { } [DataMember(Name="DateTimeFormat", EmitDefaultValue=false)] public string DateTimeFormat { get; set; } + /// + /// Gets/sets background color. + /// + /// Gets/sets background color. + [DataMember(Name="BackgroundColor", EmitDefaultValue=false)] + public Color BackgroundColor { get; set; } + + /// + /// Gets/sets foreground color. + /// + /// Gets/sets foreground color. + [DataMember(Name="ForegroundColor", EmitDefaultValue=false)] + public Color ForegroundColor { get; set; } + + /// + /// Gets/sets subject format usage. + /// + /// Gets/sets subject format usage. + [DataMember(Name="UseDigitalSubjectFormat", EmitDefaultValue=false)] + public bool? UseDigitalSubjectFormat { get; set; } + + /// + /// Gets/sets subject format. + /// + /// Gets/sets subject format. + [DataMember(Name="DigitalSubjectFormat", EmitDefaultValue=false)] + public List DigitalSubjectFormat { get; set; } + /// /// Returns the string presentation of the object /// @@ -208,6 +261,7 @@ public override string ToString() sb.Append("class SignatureCustomAppearance {\n"); sb.Append(" FontFamilyName: ").Append(FontFamilyName).Append("\n"); sb.Append(" FontSize: ").Append(FontSize).Append("\n"); + sb.Append(" Rotation: ").Append(Rotation).Append("\n"); sb.Append(" ShowContactInfo: ").Append(ShowContactInfo).Append("\n"); sb.Append(" ShowReason: ").Append(ShowReason).Append("\n"); sb.Append(" ShowLocation: ").Append(ShowLocation).Append("\n"); @@ -218,6 +272,10 @@ public override string ToString() sb.Append(" DateSignedAtLabel: ").Append(DateSignedAtLabel).Append("\n"); sb.Append(" DateTimeLocalFormat: ").Append(DateTimeLocalFormat).Append("\n"); sb.Append(" DateTimeFormat: ").Append(DateTimeFormat).Append("\n"); + sb.Append(" BackgroundColor: ").Append(BackgroundColor).Append("\n"); + sb.Append(" ForegroundColor: ").Append(ForegroundColor).Append("\n"); + sb.Append(" UseDigitalSubjectFormat: ").Append(UseDigitalSubjectFormat).Append("\n"); + sb.Append(" DigitalSubjectFormat: ").Append(DigitalSubjectFormat).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -264,6 +322,11 @@ public bool Equals(SignatureCustomAppearance other) this.FontSize != null && this.FontSize.Equals(other.FontSize) ) && + ( + this.Rotation == other.Rotation || + this.Rotation != null && + this.Rotation.Equals(other.Rotation) + ) && ( this.ShowContactInfo == other.ShowContactInfo || this.ShowContactInfo != null && @@ -313,6 +376,26 @@ public bool Equals(SignatureCustomAppearance other) this.DateTimeFormat == other.DateTimeFormat || this.DateTimeFormat != null && this.DateTimeFormat.Equals(other.DateTimeFormat) + ) && + ( + this.BackgroundColor == other.BackgroundColor || + this.BackgroundColor != null && + this.BackgroundColor.Equals(other.BackgroundColor) + ) && + ( + this.ForegroundColor == other.ForegroundColor || + this.ForegroundColor != null && + this.ForegroundColor.Equals(other.ForegroundColor) + ) && + ( + this.UseDigitalSubjectFormat == other.UseDigitalSubjectFormat || + this.UseDigitalSubjectFormat != null && + this.UseDigitalSubjectFormat.Equals(other.UseDigitalSubjectFormat) + ) && + ( + this.DigitalSubjectFormat == other.DigitalSubjectFormat || + this.DigitalSubjectFormat != null && + this.DigitalSubjectFormat.SequenceEqual(other.DigitalSubjectFormat) ); } @@ -331,6 +414,8 @@ public override int GetHashCode() hash = hash * 59 + this.FontFamilyName.GetHashCode(); if (this.FontSize != null) hash = hash * 59 + this.FontSize.GetHashCode(); + if (this.Rotation != null) + hash = hash * 59 + this.Rotation.GetHashCode(); if (this.ShowContactInfo != null) hash = hash * 59 + this.ShowContactInfo.GetHashCode(); if (this.ShowReason != null) @@ -351,6 +436,14 @@ public override int GetHashCode() hash = hash * 59 + this.DateTimeLocalFormat.GetHashCode(); if (this.DateTimeFormat != null) hash = hash * 59 + this.DateTimeFormat.GetHashCode(); + if (this.BackgroundColor != null) + hash = hash * 59 + this.BackgroundColor.GetHashCode(); + if (this.ForegroundColor != null) + hash = hash * 59 + this.ForegroundColor.GetHashCode(); + if (this.UseDigitalSubjectFormat != null) + hash = hash * 59 + this.UseDigitalSubjectFormat.GetHashCode(); + if (this.DigitalSubjectFormat != null) + hash = hash * 59 + this.DigitalSubjectFormat.GetHashCode(); return hash; } } diff --git a/src/Aspose.Pdf.Cloud.Sdk/Model/SignatureSubjectNameElements.cs b/src/Aspose.Pdf.Cloud.Sdk/Model/SignatureSubjectNameElements.cs new file mode 100644 index 00000000..78c0890e --- /dev/null +++ b/src/Aspose.Pdf.Cloud.Sdk/Model/SignatureSubjectNameElements.cs @@ -0,0 +1,94 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2025 Aspose.PDF Cloud +// +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// -------------------------------------------------------------------------------------------------------------------- + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.Net; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = Aspose.Pdf.Cloud.Sdk.Client.SwaggerDateConverter; + +namespace Aspose.Pdf.Cloud.Sdk.Model +{ + /// + /// Represents an enumeration of available SubjectNameElements. + /// + /// Represents an enumeration of available SubjectNameElements. + [JsonConverter(typeof(StringEnumConverter))] + public enum SignatureSubjectNameElements + { + + /// + /// Enum CN for "CN" + /// + [EnumMember(Value = "CN")] + CN, + + /// + /// Enum O for "O" + /// + [EnumMember(Value = "O")] + O, + + /// + /// Enum L for "L" + /// + [EnumMember(Value = "L")] + L, + + /// + /// Enum OU for "OU" + /// + [EnumMember(Value = "OU")] + OU, + + /// + /// Enum S for "S" + /// + [EnumMember(Value = "S")] + S, + + /// + /// Enum C for "C" + /// + [EnumMember(Value = "C")] + C, + + /// + /// Enum E for "E" + /// + [EnumMember(Value = "E")] + E + } + +} diff --git a/src/Aspose.Pdf.Cloud.Sdk/Properties/AssemblyInfo.cs b/src/Aspose.Pdf.Cloud.Sdk/Properties/AssemblyInfo.cs index a1721696..e253c57c 100644 --- a/src/Aspose.Pdf.Cloud.Sdk/Properties/AssemblyInfo.cs +++ b/src/Aspose.Pdf.Cloud.Sdk/Properties/AssemblyInfo.cs @@ -28,5 +28,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("25.5.0")] -[assembly: AssemblyFileVersion("25.5.0")] +[assembly: AssemblyVersion("25.7.0")] +[assembly: AssemblyFileVersion("25.7.0")]