HTML
JPG
PDF
XML
DOCX
PDF
如何通过Cloud .NET SDK创建PDF
要创建PDF文档,我们将使用 Aspose.PDF Cloud .NET SDK 此Cloud SDK允许您轻松地在C#、ASP.NET或其他.NET语言中构建基于云的PDF创建、编辑和转换应用程序。打开 NuGet 包管理器,搜索 Aspose.PDF Cloud 并安装。您还可以在包管理器控制台中使用以下命令。
包管理器控制台命令
PM> Install-Package Aspose.Pdf-Cloud
使用.NET SDK创建PDF的步骤
Aspose.PDF Cloud开发人员可以轻松加载和创建PDF,只需几行代码。
- 上传PDF。
- 使用getPageInfo()检索页面元数据。
- 将PDF页面提取为图像。
- 使用createPdfDocument()创建新的空白PDF画布。
- 将提取的图像插入新的PDF中。
- 验证成功并下载。
使用.NET Cloud SDK创建PDF
using Aspose.Pdf.Cloud.Sdk.Model;
namespace CreateDocument
{
public class CreatePdfDocument
{
public CreatePdfDocument(CrateDocumentHelper helper)
{
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(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!!!");
}
}
}