C
C#2y ago
MrFedetッ

❔ replace report viewer net core WinForms

Hello people, I need to make a ticket and print it, how can I do it? Report viewer in net core version gives many compatibility problems
2 Replies
HowNiceOfYou
HowNiceOfYou2y ago
You can use a library like iTextSharp or Aspose.PDF for .NET to create and print tickets. These libraries allow you to programmatically create PDF documents, which you can then print. Here's an example one second.
using System;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace TicketExample
{
class Program
{
static void Main(string[] args)
{
// Create a new PDF document
Document document = new Document();

// Set the document to landscape orientation
document.SetPageSize(PageSize.A4.Rotate());

// Create a new PDF writer that writes to a file
PdfWriter writer = PdfWriter.GetInstance(document, new System.IO.FileStream("Ticket.pdf", System.IO.FileMode.Create));

// Open the document for writing
document.Open();

// Add some text to the document
document.Add(new Paragraph("Ticket"));
document.Add(new Paragraph("Event: Concert"));
document.Add(new Paragraph("Date: February 10, 2023"));
document.Add(new Paragraph("Location: Madison Square Garden, New York"));
document.Add(new Paragraph("Ticket Number: 123456"));

// Close the document
document.Close();

// Print the document
System.Diagnostics.Process.Start("Ticket.pdf");
}
}
}
using System;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace TicketExample
{
class Program
{
static void Main(string[] args)
{
// Create a new PDF document
Document document = new Document();

// Set the document to landscape orientation
document.SetPageSize(PageSize.A4.Rotate());

// Create a new PDF writer that writes to a file
PdfWriter writer = PdfWriter.GetInstance(document, new System.IO.FileStream("Ticket.pdf", System.IO.FileMode.Create));

// Open the document for writing
document.Open();

// Add some text to the document
document.Add(new Paragraph("Ticket"));
document.Add(new Paragraph("Event: Concert"));
document.Add(new Paragraph("Date: February 10, 2023"));
document.Add(new Paragraph("Location: Madison Square Garden, New York"));
document.Add(new Paragraph("Ticket Number: 123456"));

// Close the document
document.Close();

// Print the document
System.Diagnostics.Process.Start("Ticket.pdf");
}
}
}
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server