简体   繁体   中英

Error 14 The type or namespace name 'Document' could not be found (are you missing a using directive or an assembly reference?)

Document document = new Document();
            MemoryStream stream = new MemoryStream();
            try
            {
                PdfWriter pdfWriter = PdfWriter.GetInstance(document, stream);
                pdfWriter.CloseStream = false;

                document.Open();
                document.Add(new Paragraph("Hello World"));
            }
            catch (DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            document.Close();

            stream.Flush(); //Always catches me out
            stream.Position = 0; //Not sure if this is required
            return File(stream, "application/pdf");

i got the same error for pdf writer and Paragraph

i am having the same problem then i find the answer

First of all be quiet sure that iTextSharp.dll is added to reference and

then at the starting of the main form. Add this

using iTextSharp.text; 

using iTextSharp.text.pdf;

iTextSharp.text is responsible for Document Object

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question error CS0246: The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?) Why this error ? “The type or namespace name 'c' could not be found (are you missing a using directive or an assembly reference?)” Error 1 The type or namespace name 'FPSTimer' could not be found (are you missing a using directive or an assembly reference?) error CS0246: The type or namespace name 'BannerPosition' could not be found are you missing a using directive or an assembly reference? c# Error 1 The type or namespace name '' could not be found (are you missing a using directive or an assembly reference?) Getting error The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?) Error: The type or namespace name 'SqlCe' could not be found (are you missing a using directive or an assembly reference?) Error 1 The type or namespace name 'ProductServiceClient' could not be found (are you missing a using directive or an assembly reference?) Error CS0246 The type or namespace name 'CreateRandomAnswersForKey' could not be found (are you missing a using directive or an assembly reference?)? error CS0246: The type or namespace name 'Npgsql' could not be found (are you missing a using directive or an assembly reference?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM