Example #1
0
 private void TestText(string text)
 {
     PdfConverter converter = new PdfConverter();
     byte[] pdf = converter.ConvertText(text, new ConversionOptions());
     Assert.IsNotNull(pdf);
     Assert.IsTrue(pdf.Length > 0);
 }
Example #2
0
 public void TestValidUrl()
 {
     PdfConverter converter = new PdfConverter();
     byte[] pdf = converter.ConvertUrl("http://www.google.com", new HtmlConversionOptions());
     Assert.IsNotNull(pdf);
     Assert.IsTrue(pdf.Length > 0);
 }
Example #3
0
 public void TestZipExceptionOnUnsupportedFileType()
 {
     string tempFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test_files\\zip\\archive_with_unsupported_file.zip");
     byte[] testFile = File.ReadAllBytes(tempFilePath);
     PdfConverter converter = new PdfConverter();
     byte[] pdf = converter.ConvertZipFile(testFile, new ConversionOptions() { SilentFailOnUnsupportedType = false });
 }
Example #4
0
 private void TestHtml(string html)
 {
     PdfConverter converter = new PdfConverter();
     byte[] pdf = converter.ConvertHtml(html, new HtmlConversionOptions() { Orientation = PageOrientation.Landscape });
     Assert.IsNotNull(pdf);
     Assert.IsTrue(pdf.Length > 0);
 }
 private void TestImage(string testFilePath)
 {
     byte[] testFile = File.ReadAllBytes(testFilePath);
     PdfConverter converter = new PdfConverter();
     byte[] pdf = converter.ConvertImage(testFile, Path.GetFileName(testFilePath), new ImageConversionOptions());
     Assert.IsNotNull(pdf);
     Assert.IsTrue(pdf.Length > 0);
 }
 public void TestSilentFailNoPageOnUnsupportedImage()
 {
     string testFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test_files\\unsupported\\image.tga");
     byte[] testFile = File.ReadAllBytes(testFilePath);
     PdfConverter converter = new PdfConverter();
     byte[] pdf = converter.ConvertImage(testFile, Path.GetFileName(testFilePath), new ImageConversionOptions() { SilentFailOnUnsupportedType = true, UsePlaceholderPageOnUnsupportedType = false });
     Assert.IsNull(pdf);
 }
        public void TestMultipleImages()
        {
            string image1Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test_files\\images\\image.png");
            string image2Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test_files\\images\\image.jpg");
            byte[] image1 = File.ReadAllBytes(image1Path);
            byte[] image2 = File.ReadAllBytes(image2Path);
            PdfConverter converter = new PdfConverter();
            byte[] pdf = converter.ConvertImages(new Dictionary<string, byte[]>() {
                {  Path.GetFileName(image1Path), image1 },
                {  Path.GetFileName(image2Path), image2 }
            }, new ImageConversionOptions());

            Assert.IsNotNull(pdf);
            Assert.IsTrue(pdf.Length > 0);
        }
Example #8
0
        public void TestZip()
        {
            string tempFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test_files\\zip\\archive.zip");
            byte[] testFile = File.ReadAllBytes(tempFilePath);
            PdfConverter converter = new PdfConverter();
            byte[] pdf = converter.ConvertZipFile(testFile, new ConversionOptions());
            Assert.IsNotNull(pdf);

            Document doc = new Document();
            PdfReader reader = new PdfReader(pdf);
            int pages = reader.NumberOfPages;
            doc.Close();

            Assert.IsTrue(pages == 5);
        }
Example #9
0
        public void TestZipUnsupportedFileType()
        {
            string tempFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test_files\\zip\\archive_with_unsupported_file.zip");
            byte[] testFile = File.ReadAllBytes(tempFilePath);
            PdfConverter converter = new PdfConverter();
            byte[] pdf = converter.ConvertZipFile(testFile, new ConversionOptions() { SilentFailOnUnsupportedType = true, UsePlaceholderPageOnUnsupportedType = true });
            Assert.IsNotNull(pdf);
            Assert.IsTrue(pdf.Length > 0);

            Document doc = new Document();
            PdfReader reader = new PdfReader(pdf);
            int pages = reader.NumberOfPages;
            doc.Close();

            Assert.IsTrue(pages == 6);
        }
        public void TestMultipleDocuments()
        {
            byte[] testFile1 = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test_files\\documents\\document.docx"));
            byte[] testFile2 = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test_files\\documents\\document.docx"));
            Dictionary<string, byte[]> files = new Dictionary<string, byte[]>();
            files.Add("document1.docx", testFile1);
            files.Add("document2.docx", testFile2);
            PdfConverter converter = new PdfConverter();
            byte[] pdf = converter.ConvertFiles(files, new ConversionOptions());

            Assert.IsNotNull(pdf);
            Document doc = new Document();
            PdfReader reader = new PdfReader(pdf);
            int pages = reader.NumberOfPages;
            byte[] page1 = reader.GetPageContent(1);
            byte[] page2 = reader.GetPageContent(2);
            doc.Close();

            Assert.IsTrue(pages == 2);
            Assert.AreEqual(page1.Length, page1.Length);
        }
Example #11
0
 public PedamorfService()
 {
     m_converter = new PdfConverter();
     m_logger = LogManager.GetCurrentClassLogger();
 }
 public void TestNull()
 {
     PdfConverter converter = new PdfConverter();
     byte[] response = converter.ConvertFile(null, "nullfile.doc", new ConversionOptions());
 }
 public void TestIsFileTypeSupported()
 {
     PdfConverter converter = new PdfConverter();
     Assert.IsTrue(converter.IsFileTypeSupported("supportedFileType.bmp"));
 }
 public void TestIsFileTypeNotSupported()
 {
     PdfConverter converter = new PdfConverter();
     Assert.IsFalse(converter.IsFileTypeSupported("unsupportedFileType.exe"));
 }
 public void TestNull()
 {
     PdfConverter converter = new PdfConverter();
     byte[] response = converter.ConvertHtml(null, new HtmlConversionOptions());
 }
 public void TestEmpty()
 {
     PdfConverter converter = new PdfConverter();
     byte[] response = converter.ConvertHtml(string.Empty, new HtmlConversionOptions());
 }
Example #17
0
 public void TestInvalidUrl()
 {
     PdfConverter converter = new PdfConverter();
     byte[] pdf = converter.ConvertUrl("https://www.sdfksdlfklsdf.com", new HtmlConversionOptions());
 }
Example #18
0
 public void TestRelativedUrl()
 {
     PdfConverter converter = new PdfConverter();
     byte[] pdf = converter.ConvertUrl("/webapp/index.php", new HtmlConversionOptions());
 }