create PDFExporter project.

This commit is contained in:
chris.watts90@outlook.com 2017-07-05 23:00:17 +01:00
parent 96e067153b
commit 7a6b5e6bf8
5 changed files with 169 additions and 0 deletions

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1752B8A2-C07A-490C-A768-E27B075D3125}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PDFExporter</RootNamespace>
<AssemblyName>PDFExporter</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Syncfusion.Compression.Base, Version=14.1451.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.HtmlToPdfConverter451.14.1.0.46\lib\net451\Syncfusion.Compression.Base.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Syncfusion.HtmlConverter.Base, Version=14.1451.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.HtmlToPdfConverter451.14.1.0.46\lib\net451\Syncfusion.HtmlConverter.Base.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Syncfusion.Pdf.Base, Version=14.1451.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.HtmlToPdfConverter451.14.1.0.46\lib\net451\Syncfusion.Pdf.Base.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="PdfExporter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Interfaces\Interfaces.csproj">
<Project>{5c6dcc59-19f3-46ad-a479-926610f36257}</Project>
<Name>Interfaces</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,45 @@
using System.IO;
using System.Threading;
using Interfaces;
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;
namespace PDFExporter
{
public class PdfExporter:IFileExporter
{
private Stream str = new MemoryStream();
public Stream Export(string fileContent, string baseUrl)
{
var t = new Thread(()=>DoExport(fileContent, baseUrl));
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
return str;
}
public ExportProviderDetails GetDetails()
{
return new ExportProviderDetails
{
Type = "PDF"
};
}
void DoExport(string fileContent, string baseUrl)
{
var pdfExporter = new HtmlToPdfConverter();
var settings = new IEConverterSettings();
settings.AdditionalDelay = 2000;
pdfExporter.ConverterSettings = settings;
PdfDocument doc = pdfExporter.Convert(fileContent, baseUrl);
MemoryStream ms = new MemoryStream();
doc.Save(ms);
doc.Close(true);
ms.CopyTo(str);
ms.Flush();
ms.Close();
ms.Dispose();
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PDFExporter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PDFExporter")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1752b8a2-c07a-490c-a768-e27b075d3125")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Syncfusion.HtmlToPdfConverter451" version="14.1.0.46" targetFramework="net452" />
</packages>

View File

@ -21,6 +21,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Logger", "Logger", "{36BDEE
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IrDaemonNotifier", "IrDaemonNotifier\IrDaemonNotifier.csproj", "{916994F6-1711-4AEB-8DE6-4AB6FCB3F080}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FileExporters", "FileExporters", "{01615648-0CA9-41C5-8E28-8B8A6B84A215}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFExporter", "PDFExporter\PDFExporter.csproj", "{1752B8A2-C07A-490C-A768-E27B075D3125}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -55,6 +59,10 @@ Global
{916994F6-1711-4AEB-8DE6-4AB6FCB3F080}.Debug|Any CPU.Build.0 = Debug|Any CPU
{916994F6-1711-4AEB-8DE6-4AB6FCB3F080}.Release|Any CPU.ActiveCfg = Release|Any CPU
{916994F6-1711-4AEB-8DE6-4AB6FCB3F080}.Release|Any CPU.Build.0 = Release|Any CPU
{1752B8A2-C07A-490C-A768-E27B075D3125}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1752B8A2-C07A-490C-A768-E27B075D3125}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1752B8A2-C07A-490C-A768-E27B075D3125}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1752B8A2-C07A-490C-A768-E27B075D3125}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -63,5 +71,6 @@ Global
{9A93A12F-7591-406A-A4F3-41AA8299C4B4} = {36BDEE78-985C-4AF5-A39B-3BE89FAEB281}
{734097B0-A764-40AD-957A-43FE4F085B65} = {CDAC76D5-5EC6-4357-A27C-0095BF98FDDF}
{916994F6-1711-4AEB-8DE6-4AB6FCB3F080} = {CDAC76D5-5EC6-4357-A27C-0095BF98FDDF}
{1752B8A2-C07A-490C-A768-E27B075D3125} = {01615648-0CA9-41C5-8E28-8B8A6B84A215}
EndGlobalSection
EndGlobal