0
namespace iText.Samples.Sandbox.Tables
{
    public class SimpleTable
    {
        public static readonly string DEST = "results/sandbox/tables/simple_table.pdf";

        public static void Main(String[] args)
        {
             FileInfo file = new FileInfo(DEST);
             file.Directory.Create();

             new SimpleTable().ManipulatePdf(DEST);
        }

        private void ManipulatePdf(String dest)
        {
             PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
             Document doc = new Document(pdfDoc);

             Table table = new Table(UnitValue.CreatePercentArray(8)).UseAllAvailableWidth();

             for (int i = 0; i < 16; i++)
             {
                 table.AddCell("hi");
             }

             doc.Add(table);

             doc.Close();
        }
    }
}

It my seem easy for most, but I have tried and tried and am just stumped. It is not just a console app, and it is not just a class. I am missing something simple I am sure but I am not trying to do a command line app either where I pass arguments to this app. Please help.

Tried all I could.

I have done plenty of forms apps and a few console apps, but I know I am missing something very simple.

I have looked and don't see my answer.

Stefan Wuebbe
  • 2,109
  • 5
  • 17
  • 28
Garym
  • 1
  • How do I do this without using Main as the entry point, but instead using the form name and InitializeComponent(); – Garym Jan 07 '23 at 17:45
  • The error I get is "can't have multiple entry points" – Garym Jan 07 '23 at 17:50
  • I also get 'PdfWriter' does not contain a constructor that takes 1 arguments. Is it just not fully qualifing PdfWriter? If so how? – Garym Jan 07 '23 at 18:05

1 Answers1

0

Copy the whole class into your project.

Change the Main method name to something else.

You could remove the parameter of the Main method.

Call SimpleTable.methodName() in the ButtonClick method.

That should do it.

knoxgon
  • 1,070
  • 2
  • 15
  • 31
Johan P
  • 89
  • 13