-
Notifications
You must be signed in to change notification settings - Fork 511
Adicionado aplicações testes e pacotes nuget QuestPdf e PdfClown #1581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3ab596a
Adicionado documentação NFe Danfe.Html no README
MauricioSuporte 5aa58c5
Merge branch 'Branch_22637' of https://github.com/ZeusAutomacao/DFe.N…
MauricioSuporte c70dd9c
Adicionado empacotamento dos pacotes nuget NFe.Danfe.QuestPdf e NFe.D…
MauricioSuporte 90ead16
Adicionado aplicação teste QuestPdf
c26f927
Removido linha em branco
ddd823b
Ajustado texto da aplicação de teste PdfClown
a19fed2
Adicionado aplicação de teste PdfClown
51c7dea
Adicionado opção de inserir a logo na aplicação de teste QuestPdf
35d8fe0
Removido pacote System.Drawing.Common de AppTeste.QuestPdf
e34649e
Adicionado logo opcional na aplicação de teste PdfClown
dc37693
Separa o cod da aplicação de testes QuestPdf em partes menores
117b550
Ajustado typo
ddd817a
Atualiza read.me
b28a838
Atualizado passo de criar release informando novos pacotes nuget
2e33b13
Ajustes comentarios pr
MauricioSuporte 2890834
Ajustes propostos no PR
MauricioSuporte 85a1fef
Adicionado licenças
MauricioSuporte b868c25
Remove cod exemplo do readme.md
c26aece
Merge
c87e6fb
Ajustadio read.me para informar que QuestPFG gera NFCe
44ffe9d
Adicionado informações dos pacotes nugget no readme
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Application x:Class="NFe.Danfe.AppTeste.PdfClown.App" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| StartupUri="MainWindow.xaml"> | ||
| <Application.Resources> | ||
|
|
||
| </Application.Resources> | ||
| </Application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /********************************************************************************/ | ||
| /* Projeto: Biblioteca ZeusNFe */ | ||
| /* Biblioteca C# para emissão de Nota Fiscal Eletrônica - NFe e Nota Fiscal de */ | ||
| /* Consumidor Eletrônica - NFC-e (http://www.nfe.fazenda.gov.br) */ | ||
| /* */ | ||
| /* Direitos Autorais Reservados (c) 2014 Adenilton Batista da Silva */ | ||
| /* Zeusdev Tecnologia LTDA ME */ | ||
| /* */ | ||
| /* Você pode obter a última versão desse arquivo no GitHub */ | ||
| /* localizado em https://github.com/adeniltonbs/Zeus.Net.NFe.NFCe */ | ||
| /* */ | ||
| /* */ | ||
| /* Esta biblioteca é software livre; você pode redistribuí-la e/ou modificá-la */ | ||
| /* sob os termos da Licença Pública Geral Menor do GNU conforme publicada pela */ | ||
| /* Free Software Foundation; tanto a versão 2.1 da Licença, ou (a seu critério) */ | ||
| /* qualquer versão posterior. */ | ||
| /* */ | ||
| /* Esta biblioteca é distribuída na expectativa de que seja útil, porém, SEM */ | ||
| /* NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU */ | ||
| /* ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral Menor*/ | ||
| /* do GNU para mais detalhes. (Arquivo LICENÇA.TXT ou LICENSE.TXT) */ | ||
| /* */ | ||
| /* Você deve ter recebido uma cópia da Licença Pública Geral Menor do GNU junto*/ | ||
| /* com esta biblioteca; se não, escreva para a Free Software Foundation, Inc., */ | ||
| /* no endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. */ | ||
| /* Você também pode obter uma copia da licença em: */ | ||
| /* http://www.opensource.org/licenses/lgpl-license.php */ | ||
| /* */ | ||
| /* Zeusdev Tecnologia LTDA ME - [email protected] */ | ||
| /* http://www.zeusautomacao.com.br/ */ | ||
| /* Rua Comendador Francisco josé da Cunha, 111 - Itabaiana - SE - 49500-000 */ | ||
| /********************************************************************************/ | ||
|
|
||
| namespace NFe.Danfe.AppTeste.PdfClown; | ||
|
|
||
| /// <summary> | ||
| /// Interaction logic for App.xaml | ||
| /// </summary> | ||
| public partial class App | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Windows; | ||
|
|
||
| [assembly:ThemeInfo( | ||
| ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
| //(used if a resource is not found in the page, | ||
| // or application resource dictionaries) | ||
| ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
| //(used if a resource is not found in the page, | ||
| // app, or any theme specific resource dictionaries) | ||
| )] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <Window x:Class="NFe.Danfe.AppTeste.PdfClown.MainWindow" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| Title="Gerador de DANFE NF-e" Height="400" Width="400"> | ||
| <Grid Margin="10"> | ||
| <Grid.RowDefinitions> | ||
| <RowDefinition Height="*" /> | ||
| <RowDefinition Height="Auto" /> | ||
| <RowDefinition Height="*" /> | ||
| </Grid.RowDefinitions> | ||
|
|
||
| <StackPanel Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"> | ||
| <GroupBox Header="Logomarca" Margin="0,0,0,15"> | ||
| <StackPanel Orientation="Horizontal"> | ||
| <Border BorderThickness="1" BorderBrush="Gray" Width="100" Height="100" Margin="5"> | ||
| <Image x:Name="LogoEmitente" Stretch="Uniform"/> | ||
| </Border> | ||
| <StackPanel Margin="10,0,0,0" VerticalAlignment="Center"> | ||
| <Button Content="Carregar Logo" Width="120" Click="BtnCarregarLogo_Click" Margin="0,0,0,5"/> | ||
| <Button Content="Remover Logo" Width="120" Click="BtnRemoverLogo_Click"/> | ||
| </StackPanel> | ||
| </StackPanel> | ||
| </GroupBox> | ||
|
|
||
| <Button Width="250" | ||
| Padding="10" | ||
| Click="Btn_GerarDanfe_Click"> | ||
| <TextBlock TextWrapping="Wrap" | ||
| TextAlignment="Center" | ||
| Text="Selecionar XML e gerar DANFE NF-e"/> | ||
| </Button> | ||
| </StackPanel> | ||
| </Grid> | ||
| </Window> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| /********************************************************************************/ | ||
| /* Projeto: Biblioteca ZeusNFe */ | ||
| /* Biblioteca C# para emissão de Nota Fiscal Eletrônica - NFe e Nota Fiscal de */ | ||
| /* Consumidor Eletrônica - NFC-e (http://www.nfe.fazenda.gov.br) */ | ||
| /* */ | ||
| /* Direitos Autorais Reservados (c) 2014 Adenilton Batista da Silva */ | ||
| /* Zeusdev Tecnologia LTDA ME */ | ||
| /* */ | ||
| /* Você pode obter a última versão desse arquivo no GitHub */ | ||
| /* localizado em https://github.com/adeniltonbs/Zeus.Net.NFe.NFCe */ | ||
| /* */ | ||
| /* */ | ||
| /* Esta biblioteca é software livre; você pode redistribuí-la e/ou modificá-la */ | ||
| /* sob os termos da Licença Pública Geral Menor do GNU conforme publicada pela */ | ||
| /* Free Software Foundation; tanto a versão 2.1 da Licença, ou (a seu critério) */ | ||
| /* qualquer versão posterior. */ | ||
| /* */ | ||
| /* Esta biblioteca é distribuída na expectativa de que seja útil, porém, SEM */ | ||
| /* NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU */ | ||
| /* ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral Menor*/ | ||
| /* do GNU para mais detalhes. (Arquivo LICENÇA.TXT ou LICENSE.TXT) */ | ||
| /* */ | ||
| /* Você deve ter recebido uma cópia da Licença Pública Geral Menor do GNU junto*/ | ||
| /* com esta biblioteca; se não, escreva para a Free Software Foundation, Inc., */ | ||
| /* no endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. */ | ||
| /* Você também pode obter uma copia da licença em: */ | ||
| /* http://www.opensource.org/licenses/lgpl-license.php */ | ||
| /* */ | ||
| /* Zeusdev Tecnologia LTDA ME - [email protected] */ | ||
| /* http://www.zeusautomacao.com.br/ */ | ||
| /* Rua Comendador Francisco josé da Cunha, 111 - Itabaiana - SE - 49500-000 */ | ||
| /********************************************************************************/ | ||
|
|
||
| using Microsoft.Win32; | ||
| using NFe.Danfe.PdfClown; | ||
| using NFe.Danfe.PdfClown.Modelo; | ||
| using System.Diagnostics; | ||
| using System.IO; | ||
| using System.Windows; | ||
| using System.Windows.Controls; | ||
| using System.Windows.Media.Imaging; | ||
|
|
||
| namespace NFe.Danfe.AppTeste.PdfClown | ||
| { | ||
| public partial class MainWindow : Window | ||
| { | ||
| private byte[]? _logoMarcaBytes; | ||
|
|
||
| public MainWindow() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| private void BtnCarregarLogo_Click(object sender, RoutedEventArgs e) | ||
| { | ||
| var caminhoImagem = SelecionarImagem(); | ||
| if (string.IsNullOrEmpty(caminhoImagem)) | ||
| return; | ||
|
|
||
| try | ||
| { | ||
| var bitmap = CarregarImagem(caminhoImagem); | ||
| LogoEmitente.Source = bitmap; | ||
| _logoMarcaBytes = ConverterParaJpegBytes(bitmap); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| MessageBox.Show($"Erro ao carregar logomarca: {ex.Message}", "Erro", MessageBoxButton.OK, MessageBoxImage.Error); | ||
| } | ||
| } | ||
|
|
||
| private void BtnRemoverLogo_Click(object sender, RoutedEventArgs e) | ||
| { | ||
| _logoMarcaBytes = null; | ||
| LogoEmitente.Source = null; | ||
| } | ||
|
|
||
| private void Button_GerarDanfe_Click(object sender, RoutedEventArgs e) | ||
| { | ||
| var caminhoXml = SelecionarXml(); | ||
| if (string.IsNullOrEmpty(caminhoXml)) | ||
| return; | ||
|
|
||
| try | ||
| { | ||
| var xml = File.ReadAllText(caminhoXml); | ||
| var pdfBytes = GerarDanfeZion(xml, _logoMarcaBytes); | ||
| AbrirPdfTemporario(pdfBytes); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| MessageBox.Show($"Erro ao gerar DANFE: {ex.Message}", "Erro", MessageBoxButton.OK, MessageBoxImage.Error); | ||
| } | ||
| } | ||
|
|
||
| private static string? SelecionarImagem() | ||
| { | ||
| var dialog = new OpenFileDialog | ||
| { | ||
| Filter = "Imagens (*.png;*.jpg;*.jpeg)|*.png;*.jpg;*.jpeg", | ||
| Title = "Selecione uma imagem para a logomarca" | ||
| }; | ||
|
|
||
| var result = dialog.ShowDialog() == true ? dialog.FileName : null; | ||
| return result; | ||
| } | ||
|
|
||
| private static string? SelecionarXml() | ||
| { | ||
| var dialog = new OpenFileDialog | ||
| { | ||
| Filter = "Arquivos XML (*.xml)|*.xml", | ||
| Title = "Selecione o XML da NF-e" | ||
| }; | ||
|
|
||
| return dialog.ShowDialog() == true ? dialog.FileName : null; | ||
| } | ||
|
|
||
| private static BitmapImage CarregarImagem(string caminho) | ||
| { | ||
| var bitmap = new BitmapImage(); | ||
| bitmap.BeginInit(); | ||
| bitmap.CacheOption = BitmapCacheOption.OnLoad; | ||
| bitmap.UriSource = new Uri(caminho); | ||
| bitmap.EndInit(); | ||
| return bitmap; | ||
| } | ||
|
|
||
| private static byte[] ConverterParaJpegBytes(BitmapImage bitmap) | ||
| { | ||
| var imageControl = new Image | ||
| { | ||
| Source = bitmap, | ||
| Width = bitmap.PixelWidth, | ||
| Height = bitmap.PixelHeight | ||
| }; | ||
|
|
||
| imageControl.Measure(new Size(bitmap.PixelWidth, bitmap.PixelHeight)); | ||
| imageControl.Arrange(new Rect(new Size(bitmap.PixelWidth, bitmap.PixelHeight))); | ||
|
|
||
| var render = new RenderTargetBitmap(bitmap.PixelWidth, bitmap.PixelHeight, 96, 96, System.Windows.Media.PixelFormats.Pbgra32); | ||
| render.Render(imageControl); | ||
|
|
||
| var encoder = new JpegBitmapEncoder { QualityLevel = 100 }; | ||
| encoder.Frames.Add(BitmapFrame.Create(render)); | ||
|
|
||
| using var stream = new MemoryStream(); | ||
| encoder.Save(stream); | ||
| return stream.ToArray(); | ||
| } | ||
|
|
||
| private static byte[] GerarDanfeZion(string xmlNfeProc, byte[]? logoMarca) | ||
| { | ||
| xmlNfeProc = xmlNfeProc.Replace("\u00a0", " "); | ||
| var model = DanfeViewModelCreator.CriarDeStringXml(xmlNfeProc); | ||
|
|
||
| using var pdfStream = new MemoryStream(); | ||
| using var danfe = new DanfeDoc(model); | ||
|
|
||
| if (logoMarca != null) | ||
| { | ||
| using var logo = new MemoryStream(logoMarca); | ||
| danfe.AdicionarLogoImagem(logo); | ||
| } | ||
|
|
||
| danfe.Gerar(); | ||
| return danfe.ObterPdfBytes(pdfStream); | ||
| } | ||
|
|
||
| private static void AbrirPdfTemporario(byte[] pdfBytes) | ||
| { | ||
| var caminhoTemporario = Path.Combine(Path.GetTempPath(), "danfe-nfe.pdf"); | ||
| File.WriteAllBytes(caminhoTemporario, pdfBytes); | ||
| Process.Start(new ProcessStartInfo(caminhoTemporario) { UseShellExecute = true }); | ||
| } | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
NFe.Danfe.AppTeste.PdfClown/NFe.Danfe.AppTeste.PdfClown.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>WinExe</OutputType> | ||
| <TargetFramework>net6.0-windows</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <UseWPF>true</UseWPF> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\NFe.Danfe.PdfClown\NFe.Danfe.PdfClown.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Application x:Class="NFe.Danfe.AppTeste.QuestPdf.App" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| StartupUri="MainWindow.xaml"> | ||
| <Application.Resources> | ||
|
|
||
| </Application.Resources> | ||
| </Application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /********************************************************************************/ | ||
| /* Projeto: Biblioteca ZeusNFe */ | ||
| /* Biblioteca C# para emissão de Nota Fiscal Eletrônica - NFe e Nota Fiscal de */ | ||
| /* Consumidor Eletrônica - NFC-e (http://www.nfe.fazenda.gov.br) */ | ||
| /* */ | ||
| /* Direitos Autorais Reservados (c) 2014 Adenilton Batista da Silva */ | ||
| /* Zeusdev Tecnologia LTDA ME */ | ||
| /* */ | ||
| /* Você pode obter a última versão desse arquivo no GitHub */ | ||
| /* localizado em https://github.com/adeniltonbs/Zeus.Net.NFe.NFCe */ | ||
| /* */ | ||
| /* */ | ||
| /* Esta biblioteca é software livre; você pode redistribuí-la e/ou modificá-la */ | ||
| /* sob os termos da Licença Pública Geral Menor do GNU conforme publicada pela */ | ||
| /* Free Software Foundation; tanto a versão 2.1 da Licença, ou (a seu critério) */ | ||
| /* qualquer versão posterior. */ | ||
| /* */ | ||
| /* Esta biblioteca é distribuída na expectativa de que seja útil, porém, SEM */ | ||
| /* NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU */ | ||
| /* ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral Menor*/ | ||
| /* do GNU para mais detalhes. (Arquivo LICENÇA.TXT ou LICENSE.TXT) */ | ||
| /* */ | ||
| /* Você deve ter recebido uma cópia da Licença Pública Geral Menor do GNU junto*/ | ||
| /* com esta biblioteca; se não, escreva para a Free Software Foundation, Inc., */ | ||
| /* no endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. */ | ||
| /* Você também pode obter uma copia da licença em: */ | ||
| /* http://www.opensource.org/licenses/lgpl-license.php */ | ||
| /* */ | ||
| /* Zeusdev Tecnologia LTDA ME - [email protected] */ | ||
| /* http://www.zeusautomacao.com.br/ */ | ||
| /* Rua Comendador Francisco josé da Cunha, 111 - Itabaiana - SE - 49500-000 */ | ||
| /********************************************************************************/ | ||
|
|
||
| using System.Windows; | ||
|
|
||
| namespace NFe.Danfe.AppTeste.QuestPdf; | ||
|
|
||
| /// <summary> | ||
| /// Interaction logic for App.xaml | ||
| /// </summary> | ||
| public partial class App : Application | ||
| { | ||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.