How to create PDF via Cloud .NET SDK
To create PDF documents, we’ll use
Aspose.PDF Cloud .NET SDK
This Cloud SDK allows you to easily build cloud-based PDF creator, editor & converter apps in C#, ASP.NET, or other .NET languages for various cloud platforms. Open
NuGet
package manager, search for
Aspose.PDF Cloud
and install. You may also use the following command from the Package Manager Console: PM> Install-Package Aspose.Pdf-Cloud
Steps to simple create PDF using .NET SDK
Aspose.PDF Cloud developers can easily load & create PDF in just a few lines of code.
- Initialize PdfApi object.
- Create Pdf document with default settings.
- Verify Success and Download.
Create PDF with default parameters using .NET Cloud SDK
public void CreatePdfDocumentSimple()
{
string LOCAL_FOLDER = "testData";
string PDF_DOCUMENT = "output_created_simple.pdf";
string REMOTE_FOLDER = "TempPdfCloud";
// Get your AppSid and AppSecret https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
DocumentResponse response = pdfApi.PutCreateDocument(PDF_DOCUMENT, folder: REMOTE_FOLDER);
if (response.Code != 200)
Console.WriteLine("CreatePdfDocumentSimple(): Unexpected error: {0}", response.Messages[0]);
else
{
Console.WriteLine("CreatePdfDocumentSimple():Document '{0}' successfully created.", PDF_DOCUMENT);
pdfApi.DownloadFile(Path.Combine(REMOTE_FOLDER, PDF_DOCUMENT))
.CopyTo(File.Create(Path.Combine(LOCAL_FOLDER, PDF_DOCUMENT)));
Console.WriteLine("CreatePdfDocumentSimple():Document '{0}' successfully downloaded.", PDF_DOCUMENT);
}
}
Steps to create PDF with configurating using .NET SDK
- Initialize PdfApi object.
- Define document parameters.
- Create Pdf document with settings.
- Verify Success and Download.
Create PDF using .NET Cloud SDK
public CreatePdfDocument()
{
const string LOCAL_FOLDER = @"C:\Samples";
const string PDF_DOCUMENT = "output_created_document.pdf";
const string REMOTE_FOLDER = "TempPdfCloud";
const string RESULT_FILE_NAME = "sample.bmp";
// Get your AppSid and AppSecret https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
DocumentProperties docProps = new DocumentProperties(
List: new List<DocumentProperty>() {
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: 500.0, Width: 200.0);
DocumentConfig document_config = new DocumentConfig(
DocumentProperties: docProps,
DisplayProperties: dispProps,
DefaultPageConfig: pageConfig,
PagesCount: 5
);
DocumentResponse response = pdfApi.PostCreateDocument(RESULT_FILE_NAME, document_config, folder: REMOTE_FOLDER);
Console.WriteLine(response.Status);
using Stream downloadStream = pdfApi.DownloadFile(Path.Combine(REMOTE_FOLDER, RESULT_FILE_NAME));
using FileStream localStream = File.Create(Path.Combine(LOCAL_FOLDER, RESULT_FILE_NAME));
downloadStream.CopyTo(localStream);
}
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Why Aspose.PDF Cloud for .NET?
- Customers List
- Security