0

I am using iTextSharp (C#) to generate a few PDF-reports.

One of them creates a bill. The bill must contain one line in OCR-B. I cannot embed the font file.

Since im doing the new reports after the old ones, I went to check how it was done in the old bill-report. They inserted a picture.

old bill-report

Seems like a good workaround.

I have been googling on how to render text as image using iTextSharp, without success.

I am open for suggestions.

Master Azazel
  • 612
  • 1
  • 12
  • 32
  • Render text on a bitmap image using some image API or library, then use that bitmap image in iText(Sharp). – mkl May 24 '17 at 11:07
  • do you have a specific library in mind? – Master Azazel May 24 '17 at 11:16
  • No. I merely think it is natural to do it that way. And surely there is some Windows API which allows creating an image with text drawn on it, isn't there? – mkl May 24 '17 at 11:22
  • https://stackoverflow.com/questions/2070365/how-to-generate-an-image-from-text-on-fly-at-runtime im trying to get this approach to work. would be a nice solution with minimal overhead – Master Azazel May 24 '17 at 11:43
  • Yes, indeed, some solution like that was what I had in mind. For improved appearance you might want to draw the image at higher resolution (larger font size). – mkl May 24 '17 at 13:28
  • yeah the text is still a bit blurry.. i will try increasing font/bitmap size, thanks :) – Master Azazel May 24 '17 at 13:35
  • 1
    increasing the font size and executing `codeLineImage.ScaleToFit(300, 20);` did the trick! – Master Azazel May 24 '17 at 13:43

1 Answers1

1

Apparently, there is no iTextSharp way of doing this.

This approach worked for me How to generate an image from text on fly at runtime

That way I didn't have to include any 3rd party libraries.

Master Azazel
  • 612
  • 1
  • 12
  • 32