Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from thiagosoeiro/master
Browse files Browse the repository at this point in the history
- fix duplicate assembly no net standard (https://bartwullems.blogspo…
  • Loading branch information
Tagliatti authored Jul 16, 2018
2 parents 5c6a271 + fb788e4 commit a0db858
Show file tree
Hide file tree
Showing 5 changed files with 831 additions and 848 deletions.
2 changes: 1 addition & 1 deletion BoletoNetCore.Testes/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ internal static void TestarHomologacao(IBanco banco, TipoArquivo tipoArquivo, st
html.Append(boletoParaImpressao.MontaHtml());
html.Append("</div>");
}
var pdf = new HtmlToPdfConverter().GeneratePdf(html.ToString());
var pdf = new HtmlToPdfConverter().GeneratePdf(html.ToString()); //Licença comercial necessária para versão NET Core
using (var fs = new FileStream(nomeArquivoPDF, FileMode.Create))
fs.Write(pdf, 0, pdf.Length);
if (!File.Exists(nomeArquivoPDF))
Expand Down
23 changes: 15 additions & 8 deletions BoletoNetCore/BoletoImpressao/BoletoBancario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -623,16 +623,23 @@ public string MontaHtml(string fileName, string logoCedente)
var fnBarra = fileName + @"BoletoNetBarra.gif";
if (!File.Exists(fnBarra))
{
var imgConverter = new ImageConverter();
var imgBuffer = (byte[])imgConverter.ConvertTo(Html.barra, typeof(byte[]));
var ms = new MemoryStream(imgBuffer);

using (Stream stream = File.Create(fnBarra))
var streamBarra = Assembly.GetExecutingAssembly().GetManifestResourceStream("BoletoNetCore.Imagens.barra.gif");
using (Stream file = File.Create(fnBarra))
{
CopiarStream(ms, stream);
ms.Flush();
ms.Dispose();
CopiarStream(streamBarra, file);
}
/*Trecho de código abaixo não funciona em .NET Core devido a incompatibilidades de conversão/serialização.
Vide: https://github.com/dotnet/coreclr/blob/0fbd855e38bc3ec269479b5f6bf561dcfd67cbb6/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs
*/
//var imgConverter = new ImageConverter();
//var imgBuffer = (byte[])imgConverter.ConvertTo(Html.barra, typeof(byte[]));
//var ms = new MemoryStream(imgBuffer);
//using (Stream stream = File.Create(fnBarra))
//{
// CopiarStream(ms, stream);
// ms.Flush();
// ms.Dispose();
//}
}

var fnCodigoBarras = Path.GetTempFileName();
Expand Down
16 changes: 16 additions & 0 deletions BoletoNetCore/BoletoNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,20 @@
<PackageReference Include="CoreCompat.System.Drawing.v2" Version="5.2.0-preview1-r131" />
<PackageReference Include="NReco.PdfGenerator.LT" Version="1.1.15" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Compile Update="Html.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Html.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Html.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Html.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
Loading

0 comments on commit a0db858

Please sign in to comment.