Skip to content

Commit 916b35e

Browse files
Merge pull request #20 from SyncfusionExamples/896261
896261: Added github sample for HTML to PDF in azure function.
2 parents fc87c3c + cc36f63 commit 916b35e

File tree

10 files changed

+359
-15
lines changed

10 files changed

+359
-15
lines changed

Azure/HTML-to-PDF-Azure-Function-Windows-CefSharp/HTML-to-PDF-Azure-Functions.sln

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.10.35004.147
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HTML-to-PDF-Azure-Functions", "HTML-to-PDF-Azure-Functions\HTML-to-PDF-Azure-Functions.csproj", "{26FAC187-68EB-4293-85AD-8B64529C7F9D}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HTML-to-PDF-Azure-Functions", "HTML-to-PDF-Azure-Functions\HTML-to-PDF-Azure-Functions.csproj", "{F7041FB7-5791-44D2-98CD-783D4CCDC550}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{26FAC187-68EB-4293-85AD-8B64529C7F9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{26FAC187-68EB-4293-85AD-8B64529C7F9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{26FAC187-68EB-4293-85AD-8B64529C7F9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{26FAC187-68EB-4293-85AD-8B64529C7F9D}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{F7041FB7-5791-44D2-98CD-783D4CCDC550}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{F7041FB7-5791-44D2-98CD-783D4CCDC550}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{F7041FB7-5791-44D2-98CD-783D4CCDC550}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{F7041FB7-5791-44D2-98CD-783D4CCDC550}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {6BD0F272-89B8-47F6-9159-B0835465120D}
23+
SolutionGuid = {E8DABD00-7513-4B03-B5BB-A5212F082EBF}
2424
EndGlobalSection
2525
EndGlobal

Azure/HTML-to-PDF-Azure-Function-Windows-CefSharp/HTML-to-PDF-Azure-Functions/Function1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
using Microsoft.Azure.Functions.Worker;
44
using Microsoft.Extensions.Logging;
55
using Syncfusion.HtmlConverter;
6-
using Syncfusion.Pdf.Graphics;
76
using Syncfusion.Pdf;
7+
using Syncfusion.Pdf.Graphics;
88

99
namespace HTML_to_PDF_Azure_Functions
1010
{

Azure/HTML-to-PDF-Azure-Function-Windows-CefSharp/HTML-to-PDF-Azure-Functions/HTML-to-PDF-Azure-Functions.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
3+
<TargetFramework>net8.0</TargetFramework>
44
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
55
<OutputType>Exe</OutputType>
66
<ImplicitUsings>enable</ImplicitUsings>
@@ -11,11 +11,11 @@
1111
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1212
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
1313
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
14-
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.0" />
14+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.1" />
1515
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.0" />
1616
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
1717
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
18-
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Cef.Net.Windows" Version="26.1.41" />
18+
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Cef.Net.Windows" Version="*" />
1919
</ItemGroup>
2020
<ItemGroup>
2121
<None Update="host.json">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<WebPublishMethod>ZipDeploy</WebPublishMethod>
8+
<PublishProvider>AzureWebSite</PublishProvider>
9+
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
10+
<LastUsedPlatform>Any CPU</LastUsedPlatform>
11+
<SiteUrlToLaunchAfterPublish>https://html-to-pdf-azure-functions20240723105928.azurewebsites.net</SiteUrlToLaunchAfterPublish>
12+
<LaunchSiteAfterPublish>false</LaunchSiteAfterPublish>
13+
<ResourceId>/subscriptions/349260c9-c5a3-4c13-8f1c-7a9f185aa74d/resourcegroups/HTMLtoPDF/providers/Microsoft.Web/sites/HTML-to-PDF-Azure-Functions20240723105928</ResourceId>
14+
<UserName>$HTML-to-PDF-Azure-Functions20240723105928</UserName>
15+
<_SavePWD>true</_SavePWD>
16+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
17+
<PublishUrl>https://html-to-pdf-azure-functions20240723105928.scm.azurewebsites.net/</PublishUrl>
18+
</PropertyGroup>
19+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"resourceGroupName": {
6+
"type": "string",
7+
"defaultValue": "HTMLtoPDF",
8+
"metadata": {
9+
"_parameterType": "resourceGroup",
10+
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
11+
}
12+
},
13+
"resourceGroupLocation": {
14+
"type": "string",
15+
"defaultValue": "eastus",
16+
"metadata": {
17+
"_parameterType": "location",
18+
"description": "Location of the resource group. Resource groups could have different location than resources."
19+
}
20+
},
21+
"resourceLocation": {
22+
"type": "string",
23+
"defaultValue": "[parameters('resourceGroupLocation')]",
24+
"metadata": {
25+
"_parameterType": "location",
26+
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
27+
}
28+
}
29+
},
30+
"resources": [
31+
{
32+
"type": "Microsoft.Resources/resourceGroups",
33+
"name": "[parameters('resourceGroupName')]",
34+
"location": "[parameters('resourceGroupLocation')]",
35+
"apiVersion": "2019-10-01"
36+
},
37+
{
38+
"type": "Microsoft.Resources/deployments",
39+
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('Create-PDF-document', subscription().subscriptionId)))]",
40+
"resourceGroup": "[parameters('resourceGroupName')]",
41+
"apiVersion": "2019-10-01",
42+
"dependsOn": [
43+
"[parameters('resourceGroupName')]"
44+
],
45+
"properties": {
46+
"mode": "Incremental",
47+
"template": {
48+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
49+
"contentVersion": "1.0.0.0",
50+
"resources": [
51+
{
52+
"kind": "web",
53+
"name": "Create-PDF-document",
54+
"type": "microsoft.insights/components",
55+
"location": "[parameters('resourceLocation')]",
56+
"properties": {},
57+
"apiVersion": "2015-05-01"
58+
}
59+
]
60+
}
61+
}
62+
}
63+
],
64+
"metadata": {
65+
"_dependencyType": "appInsights.azure"
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"metadata": {
5+
"_dependencyType": "compute.function.windows.appService"
6+
},
7+
"parameters": {
8+
"resourceGroupName": {
9+
"type": "string",
10+
"defaultValue": "HTMLtoPDF",
11+
"metadata": {
12+
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
13+
}
14+
},
15+
"resourceGroupLocation": {
16+
"type": "string",
17+
"defaultValue": "eastus",
18+
"metadata": {
19+
"description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
20+
}
21+
},
22+
"resourceName": {
23+
"type": "string",
24+
"defaultValue": "HTML-to-PDF-Azure-Functions20240723105928",
25+
"metadata": {
26+
"description": "Name of the main resource to be created by this template."
27+
}
28+
},
29+
"resourceLocation": {
30+
"type": "string",
31+
"defaultValue": "[parameters('resourceGroupLocation')]",
32+
"metadata": {
33+
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
34+
}
35+
}
36+
},
37+
"resources": [
38+
{
39+
"type": "Microsoft.Resources/resourceGroups",
40+
"name": "[parameters('resourceGroupName')]",
41+
"location": "[parameters('resourceGroupLocation')]",
42+
"apiVersion": "2019-10-01"
43+
},
44+
{
45+
"type": "Microsoft.Resources/deployments",
46+
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
47+
"resourceGroup": "[parameters('resourceGroupName')]",
48+
"apiVersion": "2019-10-01",
49+
"dependsOn": [
50+
"[parameters('resourceGroupName')]"
51+
],
52+
"properties": {
53+
"mode": "Incremental",
54+
"expressionEvaluationOptions": {
55+
"scope": "inner"
56+
},
57+
"parameters": {
58+
"resourceGroupName": {
59+
"value": "[parameters('resourceGroupName')]"
60+
},
61+
"resourceGroupLocation": {
62+
"value": "[parameters('resourceGroupLocation')]"
63+
},
64+
"resourceName": {
65+
"value": "[parameters('resourceName')]"
66+
},
67+
"resourceLocation": {
68+
"value": "[parameters('resourceLocation')]"
69+
}
70+
},
71+
"template": {
72+
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
73+
"contentVersion": "1.0.0.0",
74+
"parameters": {
75+
"resourceGroupName": {
76+
"type": "string"
77+
},
78+
"resourceGroupLocation": {
79+
"type": "string"
80+
},
81+
"resourceName": {
82+
"type": "string"
83+
},
84+
"resourceLocation": {
85+
"type": "string"
86+
}
87+
},
88+
"variables": {
89+
"storage_name": "[toLower(concat('storage', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId))))]",
90+
"appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
91+
"storage_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Storage/storageAccounts/', variables('storage_name'))]",
92+
"appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]",
93+
"function_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/sites/', parameters('resourceName'))]"
94+
},
95+
"resources": [
96+
{
97+
"location": "[parameters('resourceLocation')]",
98+
"name": "[parameters('resourceName')]",
99+
"type": "Microsoft.Web/sites",
100+
"apiVersion": "2015-08-01",
101+
"tags": {
102+
"[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
103+
},
104+
"dependsOn": [
105+
"[variables('appServicePlan_ResourceId')]",
106+
"[variables('storage_ResourceId')]"
107+
],
108+
"kind": "functionapp",
109+
"properties": {
110+
"name": "[parameters('resourceName')]",
111+
"kind": "functionapp",
112+
"httpsOnly": true,
113+
"reserved": false,
114+
"serverFarmId": "[variables('appServicePlan_ResourceId')]",
115+
"siteConfig": {
116+
"alwaysOn": true
117+
}
118+
},
119+
"identity": {
120+
"type": "SystemAssigned"
121+
},
122+
"resources": [
123+
{
124+
"name": "appsettings",
125+
"type": "config",
126+
"apiVersion": "2015-08-01",
127+
"dependsOn": [
128+
"[variables('function_ResourceId')]"
129+
],
130+
"properties": {
131+
"AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storage_name'), ';AccountKey=', listKeys(variables('storage_ResourceId'), '2017-10-01').keys[0].value, ';EndpointSuffix=', 'core.windows.net')]",
132+
"FUNCTIONS_EXTENSION_VERSION": "~3",
133+
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
134+
}
135+
}
136+
]
137+
},
138+
{
139+
"location": "[parameters('resourceGroupLocation')]",
140+
"name": "[variables('storage_name')]",
141+
"type": "Microsoft.Storage/storageAccounts",
142+
"apiVersion": "2017-10-01",
143+
"tags": {
144+
"[concat('hidden-related:', concat('/providers/Microsoft.Web/sites/', parameters('resourceName')))]": "empty"
145+
},
146+
"properties": {
147+
"supportsHttpsTrafficOnly": true
148+
},
149+
"sku": {
150+
"name": "Standard_LRS"
151+
},
152+
"kind": "Storage"
153+
},
154+
{
155+
"location": "[parameters('resourceGroupLocation')]",
156+
"name": "[variables('appServicePlan_name')]",
157+
"type": "Microsoft.Web/serverFarms",
158+
"apiVersion": "2015-08-01",
159+
"sku": {
160+
"name": "S1",
161+
"tier": "Standard",
162+
"family": "S",
163+
"size": "S1"
164+
},
165+
"properties": {
166+
"name": "[variables('appServicePlan_name')]"
167+
}
168+
}
169+
]
170+
}
171+
}
172+
}
173+
]
174+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"resourceGroupName": {
6+
"type": "string",
7+
"defaultValue": "HTMLtoPDF",
8+
"metadata": {
9+
"_parameterType": "resourceGroup",
10+
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
11+
}
12+
},
13+
"resourceGroupLocation": {
14+
"type": "string",
15+
"defaultValue": "eastus",
16+
"metadata": {
17+
"_parameterType": "location",
18+
"description": "Location of the resource group. Resource groups could have different location than resources."
19+
}
20+
},
21+
"resourceLocation": {
22+
"type": "string",
23+
"defaultValue": "[parameters('resourceGroupLocation')]",
24+
"metadata": {
25+
"_parameterType": "location",
26+
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
27+
}
28+
}
29+
},
30+
"resources": [
31+
{
32+
"type": "Microsoft.Resources/resourceGroups",
33+
"name": "[parameters('resourceGroupName')]",
34+
"location": "[parameters('resourceGroupLocation')]",
35+
"apiVersion": "2019-10-01"
36+
},
37+
{
38+
"type": "Microsoft.Resources/deployments",
39+
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('htmltopdfaadf', subscription().subscriptionId)))]",
40+
"resourceGroup": "[parameters('resourceGroupName')]",
41+
"apiVersion": "2019-10-01",
42+
"dependsOn": [
43+
"[parameters('resourceGroupName')]"
44+
],
45+
"properties": {
46+
"mode": "Incremental",
47+
"template": {
48+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
49+
"contentVersion": "1.0.0.0",
50+
"resources": [
51+
{
52+
"sku": {
53+
"name": "Standard_LRS",
54+
"tier": "Standard"
55+
},
56+
"kind": "Storage",
57+
"name": "htmltopdfaadf",
58+
"type": "Microsoft.Storage/storageAccounts",
59+
"location": "[parameters('resourceLocation')]",
60+
"apiVersion": "2017-10-01"
61+
}
62+
]
63+
}
64+
}
65+
}
66+
],
67+
"metadata": {
68+
"_dependencyType": "storage.azure"
69+
}
70+
}

0 commit comments

Comments
 (0)