Generate PDF with specific source

Asked

Viewed 728 times

2

I have a report that already works. I need to change the source to "Garamond" (already installed). The references found speak about other more flexible properties, with for example changing the source "by family" Tuto 1, or by removing a watermark (which can also be text) code project tutorial.

An example of the context is that the Times New Roman is called nominally, since the class enumerator Font already has the same related:

Font timesBold = new Font(Font.FontFamily.TIMES_ROMAN, fontSize_small, Font.BOLD, BaseColor.BLACK);
Font timesNormal = new Font(Font.FontFamily.TIMES_ROMAN, fontSize_small, Font.NORMAL, BaseColor.BLACK);

I need to get a way to generate the pdf by passing, for example, the source name (Garamond , Curlz, etc.) A good reason to use the Garamond font would be to save on paint, since it has "more spaced" pixels and so, spend less paint.

1 answer

2

Solution:

// Se a fonte não está registrada
if (!FontFactory.IsRegistered("Garamond"))
{
     // Registro a fonte
     FontFactory.RegisterFamily("Garamond", "Garamond", @"C:\Windows\Fonts");
     // Registro o diretório(não tinha funcionado até tentar isso...)
     FontFactory.RegisterDirectories();                
}                

// Faço a atribuição normalmente
Font garamondBold = FontFactory.GetFont("Garamond", 12, 1); 
Font garamondNormal = FontFactory.GetFont("Garamond");

Sample:

inserir a descrição da imagem aqui

Thanks a lot

Browser other questions tagged

You are not signed in. Login or sign up in order to post.