Ir ao conteúdo
  • Cadastre-se

Nilson Claiton Morgenstern

Membro Júnior
  • Posts

    1
  • Cadastrado em

  • Última visita

Reputação

0
  1. Boa noite Estou imprimindo cupom não fiscal usando o objeto Printing.PrintDocument, uso um papel personalizado para o mesmo. Quando o tamanho do papel passa do 10000 ele corta o cupom para o tamanho A4, sendo que meu cupom tem um tamanho de 16.723 de tamanho. Veja código abaixo. 'Declaração das variaveis Public WithEvents ImprimeCardapiocodigoNCM As New Printing.PrintDocument 'declaro uma variavel do tipo PrintPreviewDialog para mostrar a minha impressão Public VisualizaCardapiocodigoNCM As New PrintPreviewDialog 'função que prepara para mostrar minha impressão Function MostraImpressaoCardapio(Optional ByVal ImprimeDireto As Boolean = False) As Boolean Dim TamanhoPersonal As Printing.PaperSize Dim Ancho As Short Dim Alto As Short Dim Ata1 As Long = RetDadosNumero("Select Count(*) From ""ProdutoCardapioCodigoNCM_qry""") Dim Ata2 As Long = RetDadosNumero("Select Count(*) From ""ProdutoCategoriaEmGrupo_qry""") Ata1 = (Ata1) * 4 'faz esta operação por que a linha n aimpressão esta em duas linhas Ata1 += (Ata2 * 3) ' Dim Ata2 As Long = ContaLinha() Ancho = Short.Parse(280) 'Alto = Short.Parse((Ata1 + 18) * 15) Alto = (Ata1 + 18) * 15 TamanhoPersonal = New Printing.PaperSize("personal", Ancho, Alto) Try With VisualizaCardapiocodigoNCM ImprimeCardapiocodigoNCM.DefaultPageSettings.PaperSize = TamanhoPersonal ImprimeCardapiocodigoNCM.PrinterSettings.PrinterName = "Microsoft Print to PDF" 'Impressora(0, 0)(2).ToString.Trim 'variavel que confere para ver se imprime diretamente é = a treu ou mostra relatorio = false If ImprimeDireto = True Then ImprimeCardapiocodigoNCM.Print() Else .Document = ImprimeCardapiocodigoNCM .Text = "Visualização de Impressão Cardapio Codigo NCM para Aliquita da Tabela de Olho no Imposto" .WindowState = FormWindowState.Maximized .PrintPreviewControl.Zoom = 1 .FormBorderStyle = FormBorderStyle.Fixed3D .ShowDialog() End If End With Return True Catch ex As Exception msg("Ocorreu um erro no sistema" _ & vbCrLf & "Descrição do erro: " & Err.Description, MsgBoxStyle.Critical) End Try End Function 'função que criar o cupom Private Sub ImprimeCardapiocodigoNCM_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles ImprimeCardapiocodigoNCM.PrintPage Dim LinhaPos As Long = 1 Dim MyPen As Pen = New Pen(Color.Black, 3) Dim MyFont As Font = New Font("Courier New", 8, FontStyle.Bold) e.Graphics.DrawString(FormataStringDF("|", 39, 1, "-") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString("|" & FormataStringDF("Cardapio com Codigo NCM Para NFe ", 38, 2, "*") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString("|" & FormataStringDF("Usado Para Pegar a Aliquita da tabela ", 38, 2, "*") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString("|" & FormataStringDF("DE OLHO NO IMPOSTO", 38, 2, "*") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 '------------------------- Dados da empresa ---------------------------------------------- e.Graphics.DrawString(FormataStringDF("|", 39, 1, "-") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString("|" & FormataStringDF(FormataStringDF(DadosEmpresa("Fantazia"), 38, 2), 38, 1) & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString("|" & FormataStringDF(DadosEmpresa("CNPJ"), 38, 2) & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 'e.Graphics.DrawString("|" & FormataStringDF(FormataStringDF(DadosEmpresa("Telefone"), 19, 1) & FormataStringDF(DadosEmpresa("Fax"), 19, 3) & "|", 40, 2), MyFont, Brushes.Black, 0, LinhaPos) 'LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("|", 39, 1, "-") & "|", MyFont, Brushes.Black, 0, LinhaPos) '------------------------- Fim dos dados da empresa --------------------------------------- LinhaPos += 15 '-------------------------------------- Dados da do Caixa ---------------------------------------------- e.Graphics.DrawString(FormataStringDF("|Operador", 19, 1) & "|" & FormataStringDF("Impresso Em", 19, 3) & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("|" & Usuario, 19, 1) & "|" & FormataStringDF(Date.Now.ToString("dd/MM/yyyy HH:mm"), 19, 3) & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("|", 39, 1, "_") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("|" & FormataStringDF("Produtos no Cardapio", 39, 2), 39, 1, "_") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("|", 39, 1, "_") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 MyFont = New Font("Courier New", 8, FontStyle.Regular) Dim Categoria As String = "" Using Conexao As New NpgsqlConnection(StringConexao) Dim Cm As New NpgsqlCommand("Select * From ""ProdutoCardapioCodigoNCM_qry"" Order By ""Categoria"",""Produto"" Asc", Conexao) Conexao.Open() Dim rs As NpgsqlDataReader = Cm.ExecuteReader While rs.Read If rs.Item(8).ToString.Trim <> Categoria Then e.Graphics.DrawString(FormataStringDF("|", 39, 1, "=") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("|" & FormataStringDF(rs.Item(8).ToString.Trim, 39, 2), 39, 1, "_") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 Categoria = rs.Item(8).ToString.Trim e.Graphics.DrawString(FormataStringDF("|", 39, 1, "=") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 End If e.Graphics.DrawString(FormataStringDF("|Cod Barras: " & IIf(IsDBNull(rs.Item(6)), "", rs.Item(6).ToString.Trim), 34, 1, " ") & FormataStringDF("|", 6, 3, " "), MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("|" & IIf(IsDBNull(rs.Item(1)), "", rs.Item(1).ToString.Trim), 34, 1, " ") & FormataStringDF("|", 6, 3, " "), MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("|Codigo NCM: " & IIf(IsDBNull(rs.Item(16)), "", rs.Item(16).ToString.Trim), 34, 1, " ") & FormataStringDF("|", 6, 3, " "), MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("|", 39, 1, "_") & "|", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 End While End Using e.Graphics.DrawString(FormataStringDF("", 39, 1, "=") & "", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("Desenvolvido", 38, 2, ":") & "", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("NCM Developer", 38, 2, " ") & "", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("www.ncmd.com.br [email protected]", 38, 2, " ") & "", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 e.Graphics.DrawString(FormataStringDF("", 39, 1, "=") & "", MyFont, Brushes.Black, 0, LinhaPos) LinhaPos += 15 ' e.HasMorePages = False End Sub veja imagem abaixo do cupom

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!