Exemplo n.º 1
0
 public void CreateTest()
 {
     try
     {
         Pdf target = new Pdf(_tf.Copy("T1.xhtml"), _tf.Copy("T1.css"));
         string outName = _tf.Output("T1.pdf");
         File.Delete(_tf.Output("T1.pdf"));
         target.Create(outName);
         bool fileOutputCreated = false;
         bool fileExpectedCreated = false;
         if(File.Exists(_tf.Output("T1.pdf")))
         {
             fileOutputCreated = true;
         }
         if(File.Exists(_tf.Expected("T1.pdf")))
         {
             fileExpectedCreated = true;
         }
         Assert.IsTrue(fileOutputCreated);
         Assert.IsTrue(fileExpectedCreated);
     }
     catch (Pdf.MISSINGPRINCE) // If Prince not installed, ignore test
     {
     }
 }
Exemplo n.º 2
0
 public void CssTest()
 {
     Pdf target = new Pdf(_tf.Copy("T1.xhtml"), _tf.Copy("T1.css"));
     string expected = _tf.Output("T1.css");
     string actual = target.Css;
     Assert.AreEqual(expected, actual);
 }
Exemplo n.º 3
0
        public string CreatePreview()
        {
            Debug.Assert(ParentForm != null);
            if (inProcess)
            {
                return(string.Empty);
            }
            inProcess = true;
            var cr = ParentForm.Cursor;

            ParentForm.Cursor = Cursors.WaitCursor;
            Debug.Assert(!string.IsNullOrEmpty(Param.Value[Param.CurrentInput]), "The given key was not present in the dictionary.");
            var xhtml = Param.Value[Param.CurrentInput];

            if (string.IsNullOrEmpty(xhtml) || !File.Exists(xhtml))
            {
                return(string.Empty);
            }
            string PreviewCSSPath = Param.StylePath(Sheet);
            var    mergedCss      = new MergeCss();
            string cssCombine     = mergedCss.Make(PreviewCSSPath, "Temp1.css");

            var returnXhtml = CreatePreviewFile(xhtml, cssCombine, "preview", true);
            var pdf         = new Pdf(returnXhtml, cssCombine);
            var outName     = Common.PathCombine(Param.Value[Param.OutputPath], Path.GetFileNameWithoutExtension(xhtml) + ".pdf");

            try
            {
                pdf.Create(outName);
            }
            catch (Pdf.MISSINGPRINCE)
            {
                LocDB.Message("errInstallPrinceXML", "PrinceXML must be downloaded and installed from www.PrinceXML.com", null, LocDB.MessageTypes.Error,
                              LocDB.MessageDefault.First);
                ParentForm.Cursor = cr;
                inProcess         = false;
                return(string.Empty);
            }
            ParentForm.Cursor = cr;
            inProcess         = false;
            return(outName);
        }
Exemplo n.º 4
0
        public string CreatePreview()
        {
            Debug.Assert(ParentForm != null);
            if (inProcess) 
            {
                return string.Empty;
            }
            inProcess = true;
            var cr = ParentForm.Cursor;
            ParentForm.Cursor = Cursors.WaitCursor;
            Debug.Assert(!string.IsNullOrEmpty(Param.Value[Param.CurrentInput]), "The given key was not present in the dictionary.");
            var xhtml = Param.Value[Param.CurrentInput];

            if (string.IsNullOrEmpty(xhtml) || !File.Exists(xhtml)) return string.Empty;
            string PreviewCSSPath = Param.StylePath(Sheet);
            var mergedCss = new MergeCss();
            string cssCombine = mergedCss.Make(PreviewCSSPath, "Temp1.css");

            var returnXhtml = CreatePreviewFile(xhtml, cssCombine, "preview", true);
            var pdf = new Pdf(returnXhtml, cssCombine);
            var outName = Common.PathCombine(Param.Value[Param.OutputPath], Path.GetFileNameWithoutExtension(xhtml) + ".pdf");
            try
            {
                pdf.Create(outName);
            }
            catch (Pdf.MISSINGPRINCE)
            {
                LocDB.Message("errInstallPrinceXML", "PrinceXML must be downloaded and installed from www.PrinceXML.com", null, LocDB.MessageTypes.Error,
                              LocDB.MessageDefault.First);
                ParentForm.Cursor = cr;
                inProcess = false;
                return string.Empty;
            }
            ParentForm.Cursor = cr;
            inProcess = false;
            return outName;
        }
Exemplo n.º 5
0
 public void PdfConstructorTest()
 {
     string xhtmlFile = string.Empty;
     string cssFile = string.Empty;
     Pdf target = new Pdf(xhtmlFile, cssFile);
     Assert.AreEqual(typeof(Pdf), target.GetType());
 }
Exemplo n.º 6
0
 public void PdfConstructorTest1()
 {
     Pdf target = new Pdf();
     Assert.AreEqual(typeof(Pdf), target.GetType());
 }