When trying to write a pdf file, I get the exception when creating the Pdfwriter. Inner exception states:
Either itext7.bouncy-castle-adapter or itext7.bouncy-castle-fips-adapter dependency must be added in order to use BouncyCastleFactoryCreator.
Stack Trace: at iText.Kernel.Pdf.SmartModePdfObjectsSerializer..ctor() at iText.Kernel.Pdf.PdfWriter..ctor(Stream os, WriterProperties properties) at AWAData.frmWiringDiagram.WritePdfFile() in D:\GitRepo\PinMap\PinMap\frmWiringDiagram.cs:line 323
None of the examples that I have seen for iText7
does not show any code for BouncyCastleFactoryCreator
.
Here is a piece of code section where the exception occurs with the PdfWriter
in the using statement.
LicenseKey.LoadLicenseFile(new FileInfo("iTextKey.json"));
using (PdfWriter writer = new PdfWriter(pdfFile))
{
using (PdfDocument pdfDocument = new PdfDocument(writer.SetSmartMode(true)))
{
iText.Layout.Document d = new iText.Layout.Document(pdfDocument,
itext.Kernel.Geom.PageSize.LETTER);
Paragraph newline = new Paragraph(new Text("\n"));
d.Add(newline);
for (int i = 0; i < tstHeader.Lines.Count(); i++)
{
if (tstHeader.Lines.GetValue(0).ToString().Length > 0)
{
ndx = i;
}
}
}
}
I am using Visual Studio 2022 in C# to write the code.
Thanks for your time and consideration.