Skip to content

Commit e6b23f6

Browse files
authored
Merge pull request #132 from aspose-pdf-cloud/develop
update to 25.8
2 parents 430ca20 + be836d3 commit e6b23f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1640
-19
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ XLS, XLSX, PPTX, DOC, DOCX, MobiXML, JPEG, EMF, PNG, BMP, GIF, TIFF, Text
2929
## Read PDF Formats
3030
MHT, PCL, PS, XSLFO, MD
3131

32-
## Enhancements in Version 25.7
33-
- Add possibility to hide subject field in signature appearance.
32+
## Enhancements in Version 25.8
33+
- Implement document page resize functionality using the Pdf.Cloud API library.
3434
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.
3535

36-
## Bugs fixed in Version 25.7
37-
- PostDeleteStamps removing stamps from PDF page is incorrect.
36+
## Bugs fixed in Version 25.8
37+
- Implement delete watermark from PDF document using the Pdf.Cloud API library.
3838

3939
## Unit Tests
4040
Aspose PDF SDK includes a suite of unit tests. These Unit Tests also serves as examples of how to use the Aspose PDF SDK.

Uses-Cases/Bookmarks/Bookmarks.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="..\..\src\Aspose.Pdf.Cloud.Sdk\Aspose.Pdf.Cloud.Sdk.csproj" />
12+
</ItemGroup>
13+
14+
</Project>

Uses-Cases/Bookmarks/BookmarksAdd.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Aspose.Pdf.Cloud.Sdk.Model;
2+
3+
namespace Bookmarks
4+
{
5+
public class BookmarksAdd
6+
{
7+
public static async Task Append(BookmarksHelper helper, string documentName, string outputName, string parentBookmarkPath, string title, string remoteFolder)
8+
{
9+
await helper.UploadFile(documentName);
10+
11+
Bookmark bookmark = new Bookmark(
12+
Action: "GoTo",
13+
Bold: true,
14+
Italic: false,
15+
Title: title,
16+
PageDisplay: "XYZ",
17+
PageDisplayBottom: 10,
18+
PageDisplayLeft: 10,
19+
PageDisplayRight: 10,
20+
PageDisplayTop: 10,
21+
PageDisplayZoom: 2,
22+
PageNumber: 1,
23+
Color: new Color(A: 0x00, R: 0x00, G: 0xFF, B: 0x00)
24+
);
25+
List<Bookmark> newBookmarks = new List<Bookmark>() { bookmark };
26+
27+
BookmarksResponse response = await helper.pdfApi.PostBookmarkAsync(documentName, parentBookmarkPath, newBookmarks, folder: remoteFolder);
28+
29+
if (response == null)
30+
Console.WriteLine("BookmarksAdd(): Unexpected error!");
31+
else if (response.Code < 200 || response.Code > 299)
32+
Console.WriteLine("BookmarksAdd(): Failed to append bookmark to the document.");
33+
else
34+
{
35+
Console.WriteLine("BookmarksAdd(): bookmark '{0}' successfully appended to the document '{1}.", title, documentName);
36+
await helper.DownloadFile(documentName, outputName, "add_bookmark_");
37+
}
38+
}
39+
}
40+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Aspose.Pdf.Cloud.Sdk.Model;
2+
3+
namespace Bookmarks
4+
{
5+
public class BookmarksExtract
6+
{
7+
public static async Task ShowInfo(BookmarksHelper helper, string documentName, string remoteFolder)
8+
{
9+
await helper.UploadFile(documentName);
10+
11+
BookmarksResponse response = await helper.pdfApi.GetDocumentBookmarksAsync(documentName, folder: remoteFolder);
12+
13+
if (response == null)
14+
Console.WriteLine("BookmarksExtract(): Unexpected error!");
15+
else if (response.Code < 200 || response.Code > 299)
16+
Console.WriteLine("BookmarksExtract(): Failed to receive bookmarks from the document.");
17+
else if (response.Bookmarks == null || response.Bookmarks.List == null || response.Bookmarks.List.Count == 0)
18+
Console.WriteLine("BookmarksExtract(): bookmarks not found in the document.");
19+
else
20+
{
21+
Console.WriteLine("BookmarksExtract(): all bookmarks successfully received from the document '{0}.", documentName);
22+
foreach (Bookmark bookmark in response.Bookmarks.List) {
23+
Console.WriteLine("BookmarksExtract(): ID = {0}", bookmark.Links[0].Href);
24+
Console.WriteLine(bookmark.ToString());
25+
}
26+
}
27+
}
28+
}
29+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Aspose.Pdf.Cloud.Sdk.Model;
2+
3+
namespace Bookmarks
4+
{
5+
public class BookmarksExtractByPath
6+
{
7+
public static async Task ShowInfo(BookmarksHelper helper, string documentName, string bookmarkPath, string remoteFolder)
8+
{
9+
await helper.UploadFile(documentName);
10+
11+
BookmarkResponse response = await helper.pdfApi.GetBookmarkAsync(documentName,bookmarkPath, folder: remoteFolder);
12+
13+
if (response == null)
14+
Console.WriteLine("BookmarksExtractByPath(): Unexpected error!");
15+
else if (response.Code < 200 || response.Code > 299)
16+
Console.WriteLine("BookmarksExtractByPath(): Failed to receive bookmark from the document.");
17+
else if (response.Bookmark == null)
18+
Console.WriteLine("BookmarksExtractByPath(): bookmark '{0}' not found in the document '{1}'.", bookmarkPath, documentName);
19+
else
20+
{
21+
Console.WriteLine("BookmarksExtractByPath(): bookmark '{0}' successfully received from the document '{1}.", bookmarkPath, documentName);
22+
Console.WriteLine(response.Bookmark.ToString());
23+
}
24+
}
25+
}
26+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using Aspose.Pdf.Cloud.Sdk.Api;
2+
using Aspose.Pdf.Cloud.Sdk.Model;
3+
using Newtonsoft.Json;
4+
5+
namespace Bookmarks
6+
{
7+
public class ConfigParams
8+
{
9+
public string CrdentialPath { get; } = "c:\\Projects\\ASPOSE\\Pdf.Cloud\\Credentials\\credentials.json";
10+
public string LOCAL_FOLDER { get; } = "C:\\Samples";
11+
public string REMOTE_TEMP_FOLDER { get; } = "TempPdfCloud";
12+
public string PDF_DOCUMENT { get; } = "sample.pdf";
13+
public string PDF_OUTPUT { get; } = "output_sample.pdf";
14+
15+
public string BOOKMARK_TITLE { get; } = "NEW Bookmark Title XYZ";
16+
public string BOOKMARK_PATH { get; } = "/1";
17+
}
18+
19+
public class Credentials
20+
{
21+
public string Id { get; set; }
22+
public string Key { get; set; }
23+
}
24+
25+
public class BookmarksHelper
26+
{
27+
public PdfApi pdfApi { get; private set; }
28+
public ConfigParams config { get; private set; }
29+
30+
public BookmarksHelper()
31+
{
32+
config = new ConfigParams();
33+
string jsCredText = File.ReadAllText(config.CrdentialPath);
34+
Credentials cred = JsonConvert.DeserializeObject<Credentials>(jsCredText);
35+
pdfApi = new PdfApi(cred.Key, cred.Id);
36+
}
37+
38+
public async Task UploadFile(string fileName)
39+
{
40+
using (var file = File.OpenRead(Path.Combine(config.LOCAL_FOLDER, fileName)))
41+
{
42+
FilesUploadResult response = await pdfApi.UploadFileAsync(Path.Combine(config.REMOTE_TEMP_FOLDER, fileName), file);
43+
if (response == null)
44+
Console.WriteLine("UploadFile(): Unexpected error - no response!");
45+
else if (response.Errors != null && response.Errors.Count > 0)
46+
foreach (var error in response.Errors)
47+
Console.WriteLine("UploadFile(): {0} -> {1}", [error.Code, error.Message]);
48+
else
49+
Console.WriteLine("UploadFile(): File '{0}' successfully uploaded.", fileName);
50+
}
51+
}
52+
53+
public async Task DownloadFile(string fileName, string outputName, string outputPrefix)
54+
{
55+
Stream stream = pdfApi.DownloadFile(Path.Combine(config.REMOTE_TEMP_FOLDER, fileName));
56+
using var fileStream = File.Create(Path.Combine(config.LOCAL_FOLDER, outputPrefix + outputName));
57+
stream.Position = 0;
58+
await stream.CopyToAsync(fileStream);
59+
Console.WriteLine("DownloadFile(): File '{0}' successfully downloaded.", outputPrefix + outputName);
60+
}
61+
}
62+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Aspose.Pdf.Cloud.Sdk.Model;
2+
3+
namespace Bookmarks
4+
{
5+
public class BookmarksRemove
6+
{
7+
public static async Task Delete(BookmarksHelper helper, string documentName, string outputName, string bookmarkPath, string remoteFolder)
8+
{
9+
await helper.UploadFile(documentName);
10+
11+
AsposeResponse response = await helper.pdfApi.DeleteBookmarkAsync(documentName, bookmarkPath, folder: remoteFolder);
12+
13+
if (response == null)
14+
Console.WriteLine("BookmarksRemove(): Unexpected error!");
15+
else if (response.Code < 200 || response.Code > 299)
16+
Console.WriteLine("BookmarksRemove(): Failed to remove bookmark from the document.");
17+
else
18+
{
19+
Console.WriteLine("BookmarksRemove(): bookmark '{0}' successfully removed from the document '{1}.", bookmarkPath, documentName);
20+
await helper.DownloadFile(documentName, outputName, "del_bookmark_");
21+
}
22+
}
23+
}
24+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Aspose.Pdf.Cloud.Sdk.Model;
2+
3+
namespace Bookmarks
4+
{
5+
public class BookmarksReplace
6+
{
7+
public static async Task Modify(BookmarksHelper helper, string documentName, string outputName, string bookmarkPath, string title, string remoteFolder)
8+
{
9+
await helper.UploadFile(documentName);
10+
11+
Bookmark bookmark = new Bookmark(
12+
Action: "GoTo",
13+
Bold: true,
14+
Italic: false,
15+
Title: title,
16+
PageDisplay: "XYZ",
17+
PageDisplayBottom: 10,
18+
PageDisplayLeft: 10,
19+
PageDisplayRight: 10,
20+
PageDisplayTop: 10,
21+
PageDisplayZoom: 2,
22+
PageNumber: 1,
23+
Color: new Color(A: 0x00, R: 0x00, G: 0xFF, B: 0x00)
24+
);
25+
26+
BookmarkResponse response = await helper.pdfApi.PutBookmarkAsync(documentName, bookmarkPath, bookmark, folder: remoteFolder);
27+
28+
if (response == null)
29+
Console.WriteLine("BookmarksReplace(): Unexpected error!");
30+
else if (response.Code < 200 || response.Code > 299)
31+
Console.WriteLine("BookmarksReplace(): Failed to modify bookmark in the document.");
32+
else
33+
{
34+
Console.WriteLine("BookmarksReplace(): bookmark '{0}' successfully modified in the document '{1}.", title, documentName);
35+
await helper.DownloadFile(documentName, outputName, "replace_bookmark_");
36+
}
37+
}
38+
}
39+
}

Uses-Cases/Bookmarks/Program.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Bookmarks;
2+
BookmarksHelper helper = new BookmarksHelper();
3+
ConfigParams config = helper.config;
4+
5+
await BookmarksExtract.ShowInfo(helper, config.PDF_DOCUMENT, config.REMOTE_TEMP_FOLDER);
6+
7+
await BookmarksExtractByPath.ShowInfo(helper, config.PDF_DOCUMENT, config.BOOKMARK_PATH, config.REMOTE_TEMP_FOLDER);
8+
9+
await BookmarksAdd.Append(helper, config.PDF_DOCUMENT, config.PDF_OUTPUT, config.BOOKMARK_PATH, config.BOOKMARK_TITLE, config.REMOTE_TEMP_FOLDER);
10+
11+
await BookmarksRemove.Delete(helper, config.PDF_DOCUMENT, config.PDF_OUTPUT, config.BOOKMARK_PATH, config.REMOTE_TEMP_FOLDER);
12+
13+
await BookmarksReplace.Modify(helper, config.PDF_DOCUMENT, config.PDF_OUTPUT, config.BOOKMARK_PATH, config.BOOKMARK_TITLE, config.REMOTE_TEMP_FOLDER);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Aspose.Pdf.Cloud.Sdk.Model;
2+
using System.IO;
3+
4+
namespace HeadersFooters
5+
{
6+
public class HeadersFootersAddTextFooter
7+
{
8+
public static async Task Append(HeadersFootersHelper helper, string documentName, string outputName, string footerText, int startPage, int endPage, string remoteFolder)
9+
{
10+
await helper.UploadFile(documentName);
11+
12+
TextFooter footer = new TextFooter(
13+
Background: true,
14+
LeftMargin: 1,
15+
RightMargin: 2,
16+
HorizontalAlignment: HorizontalAlignment.Center,
17+
Opacity: 1,
18+
Rotate: Rotation.None,
19+
RotateAngle: 15,
20+
XIndent: 0,
21+
YIndent: 0,
22+
Zoom: 1,
23+
Value: footerText
24+
);
25+
26+
var response = await helper.pdfApi.PostDocumentTextFooterAsync(documentName, footer, startPage, endPage, folder: remoteFolder);
27+
28+
if (response == null)
29+
Console.WriteLine("HeadersFootersAddTextFooter(): Unexpected error!");
30+
else if (response.Code < 200 || response.Code > 299)
31+
Console.WriteLine("HeadersFootersAddTextFooter(): Failed to append text footer to the page of document.");
32+
else
33+
{
34+
Console.WriteLine("HeadersFootersAddTextFooter(): text '{0}' appended as footer to the document '{1}.", footerText, documentName);
35+
await helper.DownloadFile(documentName, outputName, "add_text_footer_");
36+
}
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)