簡體   English   中英

錯誤14找不到類型或命名空間名稱“Document”(您是否缺少using指令或程序集引用?)

[英]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");

我對pdf writer和Paragraph有同樣的錯誤

我遇到了同樣的問題然后我找到了答案

首先要確保將iTextSharp.dll添加到引用和

然后在主要表格的開頭。 加上這個

using iTextSharp.text; 

using iTextSharp.text.pdf;

iTextSharp.text負責文檔對象

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM