示例#1
0
        public void Pdf_document_content()
        {
            const string expectedDocumentContent = "Expected document content";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var result = Pdf.From(html).Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
        }
示例#2
0
        public void Text_encoding()
        {
            const string expectedDocumentContent = "Äöåõ";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var result = Pdf.From(html).EncodedWith("utf-8").Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
        }
示例#3
0
 public PdfStreamReader(PdfDocumentReader document, Stream stream, int position)
 {
     _document       = document;
     _stream         = stream;
     _position       = position;
     _buffer         = new byte[16];
     _bufferPosition = 0;
     _bufferLength   = 0;
 }
示例#4
0
        public void Margins()
        {
            const string expectedDocumentContent = "Expected document content";

            var html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var result = Pdf.From(html).WithMargins(1.25.Centimeters()).Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
        }
示例#5
0
        public void Is_directory_agnostic()
        {
            const string expectedDocumentContent = "Expected document content";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            Directory.SetCurrentDirectory(@"c:\");
            var result = Pdf.From(html).Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
        }
示例#6
0
        public void Page_size()
        {
            const string expectedDocumentContent = "Expected document content";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var result = Pdf.From(html).OfSize(PaperSize.A4).Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
            Assert.AreEqual(596, PdfDocumentReader.WidthOfFirstPage(result));
            Assert.AreEqual(_297mmInPostScriptPoints, PdfDocumentReader.HeightOfFirstPage(result));
        }
示例#7
0
        public void Document_title()
        {
            const string expectedTitle           = "Expected title";
            const string expectedDocumentContent = "Expected document content";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var result = Pdf.From(html).WithTitle(expectedTitle).Content();

            Assert.AreEqual(expectedTitle, PdfDocumentReader.Title(result));
            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
        }
示例#8
0
        public void Convert_multiple_documents_sequently()
        {
            const string expectedDocumentContent = "Expected document content";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var first  = Pdf.From(html).Content();
            var second = Pdf.From(html).Content();
            var third  = Pdf.From(html).Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(first));
            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(second));
            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(third));
        }
示例#9
0
        public void Convert_massive_number_of_documents()
        {
            const string expectedDocumentContent = "Expected document content";
            const int    documentCount           = 100;
            var          html  = string.Format(HtmlDocumentFormat, expectedDocumentContent);
            var          tasks = new List <Task <byte[]> >();

            for (var i = 0; i < documentCount; i++)
            {
                tasks.Add(Task.Run(() => Pdf.From(html).Content()));
            }

            Task.WaitAll(tasks.OfType <Task>().ToArray());

            foreach (var task in tasks)
            {
                TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(task.Result));
            }
        }
示例#10
0
        /// <summary>
        /// </summary>
        /// <returns>A FCS.Lite.DocumentText object</returns>
        public FCS.Lite.Base.DocumentText AdvancedRead()
        {
            if (m_docText == null)
            {
                FCS.Lite.Base.DocumentReader docReader;

                switch (m_fileData.FileType)
                {
                    case FileType.WordDocument:
                        docReader = new WordDocumentReader(m_fileData.BinaryFileData);
                        break;
                    case FileType.PowerPoint:
                        docReader = new PptDocumentReader(m_fileData.BinaryFileData);
                        break;
                    case FileType.ExcelSheet:
                        docReader = new ExcelDocumentReader(m_fileData.BinaryFileData);
                        break;
                    case FileType.WordDocumentX:
                    case FileType.WordDocumentMacroX:
                    case FileType.WordDocumentTemplateX:
                    case FileType.WordDocumentMacroTemplateX:
                        docReader = new DocxDocumentReader(m_fileData.BinaryFileData);
                        break;
                    case FileType.PowerPointX:
                    case FileType.PowerPointMacroX:
                    case FileType.PowerPointTemplateX:
                    case FileType.PowerPointMacroTemplateX:
					case FileType.PowerPointShowX:
					case FileType.PowerPointMacroShowX:
                        docReader = new PptxDocumentReader(m_fileData.BinaryFileData);
                        break;
                    case FileType.ExcelSheetX:
                    case FileType.ExcelSheetMacroX:
                    case FileType.ExcelSheetTemplateX:
					case FileType.ExcelSheetMacroTemplateX:
						docReader = new XlsxDocumentReader(m_fileData.BinaryFileData);
						break;
					case FileType.PDFDocument:
						docReader = new PdfDocumentReader(m_fileData.BinaryFileData);
						break;
					default:
                        return m_docText;
                }

                using (docReader)
                {
                    m_docText = docReader.Read();
                }
            }
            return m_docText;
        }