Ejemplo n.º 1
0
        public void GetCacheFileName()
        {
            string fileName = TestUtil.GetTestFile("pdfmaps\\Potholes.pdf");
            var    pdfMap   = new PdfMapFile(fileName);

            Assert.AreEqual(Path.Combine(Path.GetTempPath(), @"PurplePen\8704103F7AFB85896AE188BDAA2855A3E4A75CF3.png"), pdfMap.GetCacheFileName(fileName));
        }
        private void CheckPdfDump(string pdfFile, string expectedPng)
        {
            PdfMapFile mapFile = new PdfMapFile(pdfFile);
            string pngFile = Path.Combine(Path.GetDirectoryName(pdfFile), Path.GetFileNameWithoutExtension(pdfFile) + "_page%d_temp.png");
            mapFile.BeginUncachedConversion(pngFile, 200); // Convert 200 DPI.
            while (mapFile.Status == PdfMapFile.ConversionStatus.Working)
                System.Threading.Thread.Sleep(10);
            Assert.AreEqual(PdfMapFile.ConversionStatus.Success, mapFile.Status);

            int pageNum = 1;
            for (; ; ) {
                string pngExpectedPage = expectedPng.Replace("%d", pageNum.ToString());
                pngExpectedPage = TestUtil.GetBitnessSpecificFileName(pngExpectedPage, true);
                bool expectedPageExists = File.Exists(pngExpectedPage);
                string pngActualPage = pngFile.Replace("%d", pageNum.ToString());
                bool actualPageExists = File.Exists(pngActualPage);

                Assert.AreEqual(expectedPageExists, actualPageExists);
                if (expectedPageExists) {
                    using (Bitmap bmNew = (Bitmap)Image.FromFile(pngActualPage)) {
                        TestUtil.CompareBitmapBaseline(bmNew, pngExpectedPage);
                    }
                }
                else {
                    break;
                }

                if (!expectedPng.Contains("%d"))
                    break;

                pageNum++;
            }
        }
Ejemplo n.º 3
0
 public void GetCacheFileName()
 {
     string fileName = TestUtil.GetTestFile("pdfmaps\\Potholes.pdf");
     var pdfMap = new PdfMapFile(fileName);
     Assert.AreEqual(Path.Combine(Path.GetTempPath(), @"PurplePen\8704103F7AFB85896AE188BDAA2855A3E4A75CF3.png"), pdfMap.GetCacheFileName(fileName));
 }
Ejemplo n.º 4
0
 public void FindConverterExe()
 {
     string gsExe = new PdfMapFile("foo.pdf").FindPdfConverterExe();
     Assert.IsNotNull(gsExe);
 }
Ejemplo n.º 5
0
        public void FindConverterExe()
        {
            string gsExe = new PdfMapFile("foo.pdf").FindPdfConverterExe();

            Assert.IsNotNull(gsExe);
        }
Ejemplo n.º 6
0
        private void CheckPdfDump(string pdfFile, string expectedPng)
        {
            PdfMapFile mapFile = new PdfMapFile(pdfFile);
            string pngFile = Path.Combine(Path.GetDirectoryName(pdfFile), Path.GetFileNameWithoutExtension(pdfFile) + "_page%d_temp.png");
            mapFile.BeginUncachedConversion(pngFile, 200); // Convert 200 DPI.
            while (mapFile.Status == PdfMapFile.ConversionStatus.Working)
                System.Threading.Thread.Sleep(10);
            Assert.AreEqual(PdfMapFile.ConversionStatus.Success, mapFile.Status);

            int pageNum = 1;
            for (; ; ) {
                string pngExpectedPage = expectedPng.Replace("%d", pageNum.ToString());
                pngExpectedPage = TestUtil.GetBitnessSpecificFileName(pngExpectedPage, true);
                bool expectedPageExists = File.Exists(pngExpectedPage);
                string pngActualPage = pngFile.Replace("%d", pageNum.ToString());
                bool actualPageExists = File.Exists(pngActualPage);

                Assert.AreEqual(expectedPageExists, actualPageExists);
                if (expectedPageExists) {
                    using (Bitmap bmNew = (Bitmap)Image.FromFile(pngActualPage)) {
                        TestUtil.CompareBitmapBaseline(bmNew, pngExpectedPage);
                    }
                }
                else {
                    break;
                }

                if (!expectedPng.Contains("%d"))
                    break;

                pageNum++;
            }
        }