예제 #1
0
        public static bool TiffToPdf(String sFile, String targetFile, out String errMsg)
        {
            bool iret = false;

            errMsg = null;
            try
            {
                string filename = Path.GetFileNameWithoutExtension(targetFile);
                docCreator.docCreatorClass DC = new docCreator.docCreatorClass();
                DC.DocumentOutputFormat = OutputExtEnm.PDF.ToString();

                long RVal = DC.ConvertImage(sFile, targetFile);

                if (RVal == 0)
                {
                    iret = true;
                }
                else
                {
                    errMsg = String.Format("Error code [{0}] returned from docCreator.ConvertImage, calld in method: [{1}], Source file [{2}], target file [{3}]", RVal, MethodBase.GetCurrentMethod().Name, sFile ?? String.Empty, targetFile ?? String.Empty);
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
                if (ThrowAllExceptions)
                {
                    throw ex;
                }
            }

            return(iret);
        }
예제 #2
0
        public static bool PdfToTiff(String sFile, String targetFile, int resolution, out String errMsg)
        {
            bool iret = false;

            errMsg = null;

            try
            {
                /*
                 * // TODO: Test:
                 * Example - set the output document paper size to 3x5 centimeters
                 * NVDC.setParameter("DocumentPaperSize", "3cmx5cm")
                 * */

                if (resolution <= 0)
                {
                    resolution = 300;
                }
                string filename = Path.GetFileNameWithoutExtension(targetFile);
                docCreator.docCreatorClass DC = new docCreator.docCreatorClass();
                DC.DocumentOutputFolder = Path.GetDirectoryName(targetFile);
                DC.DocumentOutputName   = filename;
                DC.DocumentOutputFormat = OutputExtEnm.TIF.ToString();
                DC.TIFFType             = "tiffg4";
                DC.DocumentResolution   = resolution;
                DC.MPTIFF = true;
                //DC.Scaling = -1;

                DC.SetInputDocument(sFile, string.Empty);
                long RVal = DC.Create();
                if (RVal == 0)
                {
                    iret = true;
                }
                else
                {
                    errMsg = String.Format("Error code [{0}] returned from docCreator.Create(TIFF), calld in method: [{1}], Source file [{2}], target file [{3}], resolution [{4}]", RVal, MethodBase.GetCurrentMethod().Name, sFile ?? String.Empty, targetFile ?? String.Empty, resolution);
                    ILog.InfoMsg(errMsg);
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
                if (ThrowAllExceptions)
                {
                    throw ex;
                }
            }

            return(iret);
        }