I am trying to change the font in a PDF file while using VB.net and itextsharp. I think I am allmost there but I am failing at declaring the right things. The code I got looks ok but I get an error.
Dim FontColour As VariantType = New BaseColor(35, 31, 32)
Dim Calibri8 As VariantType = FontFactory.GetFont("Calibri", 8, FontColour)
The errors I get are the following.
Severity Code Description Project File Line Suppression State Error BC30311 Value of type 'BaseColor' cannot be converted to 'VariantType'. J C:\Users\Jeffrey\Documents\Visual Studio 2013\Projects\J\J\UniFormulieren\Offerte\OfferteUniverseel.vb 61 Active
Severity Code Description Project File Line Suppression State Error BC30311 Value of type 'Font' cannot be converted to 'VariantType'. J C:\Users\Jeffrey\Documents\Visual Studio 2013\Projects\J\J\UniFormulieren\Offerte\OfferteUniverseel.vb 62 Active
I also tried using another method as below.
Dim bftimes As BaseFont = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, False)
Dim times As New Font(bftimes, 10)
This way I could introduce "Times new roman" but not Calibri. The code above would only let met add Times new roman, Courier and Helvetica.
I am using Microsoft Visual studio 2017 with VB.NET and iTextSharp. My C# is not that great, but it helped me get this far in VB.net :)
Edit:
The first solution is something I tried using this answer from Nalan M. https://stackoverflow.com/a/29641544/9056174
Edit2:
SOLUTION
Thank you for your help ! I was so hammering on that varianttype that I was blind for another option.
Made the follow adjustments and indeed it worked like a charm!
Dim FontColour As BaseColor = New BaseColor(35, 31, 32)
Dim Calibri8 As Font = FontFactory.GetFont("Calibri", 8, FontColour)
Thank you guys for your help. ( Still don't get why I didn't thought of it myself, using the C# to VB.net converter sometimes makes you crazy)