I'm trying to use PDFSharp but I can't find predefinedFont.csHelvetica

1.1k views Asked by At

This is the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using sharpPDF;

namespace Lightnings_Extractor
{
    class PDF
    {
        pdfDocument myDoc = new pdfDocument("Lightnings-Graphs", "Daniel");

        public PDF()
        {
            pdfPage myPage = myDoc.addPage();
            myPage.addText("Hello World!", 200, 450, predefinedFont.csHelvetica, 20);
            myDoc.createPDF(@"d:\mypdf.pdf");
            myPage = null;
            myDoc = null;
        }

    }
}

predefinedFont does not exist.

So I tried to write:

sharpPDF.Fonts.pdfAbstractFont font;

But then when I tried to create font, there is no csHelvetica

What am I missing here ?

3

There are 3 answers

0
user2227610 On

Try replacing predefinedFont.csHelvetica with myDoc.getFontReference("Helvetica")

0
Daniel Lip On

I used sharpPDF in mistake. I have downloaded now PDFsharp.

Thanks.

0
Jogi Joseph George On

Replace the following line by

      myPage.addText("Hello World!", 200, 450, predefinedFont.csHelvetica, 20);

by

      myPage.addText("Hello World!", 200, 450, myDoc.getFontReference(predefinedFont.csHelvetica), 20);

It works for me.