Beispiel #1
0
        static void Main()
        {
            const string sourceFileName = "sample.doc"; //TODO: Put the source filename here
            const string resultFileName = "result.pdf"; //TODO: Put the result filename here

            // Setup Conversion configuration
            var conversionConfig = new ConversionConfig
            {
                CachePath   = "cache",
                StoragePath = "."
            };

            conversionConfig.SetUseCache(true);

            var inputDataHandler  = new AmazonInputDataHandler();
            var cacheDataHandler  = new AmazonCacheDataHandler(conversionConfig);
            var conversionHandler = new ConversionHandler(conversionConfig, inputDataHandler, cacheDataHandler);

            var resultStream = conversionHandler.Convert <Stream>(sourceFileName, new PdfSaveOptions());

            WriteStreamToFile(resultStream, resultFileName);
            resultStream.Dispose();

            Console.WriteLine("The conversion finished. Press <<ENTER>> to exit.");
            Console.ReadLine();
        }
Beispiel #2
0
        // Advanced example
        public static void ToSlidesAdvance()
        {
            // Setup Conversion configuration
            var conversionConfig = new ConversionConfig {
                StoragePath = storagePath, CachePath = cachePath
            };

            conversionConfig.SetUseCache(true);

            //instantiating the conversion handler
            var conversionHandler = new ConversionHandler(conversionConfig);

            //Set password to unprotect protected document during loading
            LoadOptions loadOptions = new LoadOptions {
                Password = "******"
            };

            // convert file to Ppt, starting from page 2 and convert 2 pages,
            // use DPI 300, image width 1024, image height 768
            SaveOptions saveOptions = new SlidesSaveOptions
            {
                ConvertFileType   = SlidesSaveOptions.SlidesFileType.Ppt,
                PageNumber        = 2,
                NumPagesToConvert = 2,
            };

            var convertedDocumentStream = conversionHandler.Convert <Stream>(inputGUIDFile, loadOptions, saveOptions);
        }
Beispiel #3
0
        // Advanced example
        public static void ToCellsAdvance()
        {
            // Setup Conversion configuration
            var conversionConfig = new ConversionConfig {
                StoragePath = storagePath, CachePath = cachePath
            };

            conversionConfig.SetUseCache(true);

            //instantiating the conversion handler
            var conversionHandler = new ConversionHandler(conversionConfig);

            //Set password to unprotect protected document during loading
            LoadOptions loadOptions = new LoadOptions {
                Password = "******"
            };

            // convert file to Xls, starting from page 2 and convert 2 pages
            SaveOptions saveOptions = new CellsSaveOptions
            {
                ConvertFileType   = CellsSaveOptions.CellsFileType.Xls,
                PageNumber        = 2,
                NumPagesToConvert = 2
            };

            var convertedDocumentStream = conversionHandler.Convert <Stream>(inputGUIDFile, loadOptions, saveOptions);
        }
Beispiel #4
0
        private void CreateConversion(ConversionConfig config)
        {
            ThreadPool.QueueUserWorkItem(obj =>
            {
                Conversion conv;
                try
                {
                    conv = _conversionClient.CreateConversion(config);
                }
                catch (Exception e)
                {
                    log.Error("Failed to create new conversion", e);

                    Program.Invoke(this, () =>
                    {
                        statusLabel.Image = Images.StaticImages._000_error_h32bit_16;
                        statusLabel.Text  = Messages.CONVERSION_CREATE_FAILURE;
                        statusLinkLabel.Reset();
                    });
                    return;
                }

                FetchConversionDetails(conv);
            });
        }
        static void Main(string[] args)
        {
            var storagePath = Path.Combine(RootFolder, "TestFiles");

            // Set license
            License license = new License();

            license.SetLicense("");

            // Setup Conversion configuration
            var conversionConfig = new ConversionConfig
            {
                StoragePath = storagePath,
                OutputPath  = ResultPath,
                UseCache    = false
            };

            var inputDataHandler  = new GoogleInputHandler(conversionConfig);
            var conversionHandler = new ConversionHandler(conversionConfig, inputDataHandler);

            var resultStream = conversionHandler.Convert <Stream>("document.gdoc", new WordsSaveOptions());

            WriteStreamToFile(resultStream, "result.docx");
            resultStream.Dispose();

            Console.WriteLine("The conversion finished. Press <<ENTER>> to exit.");
            Console.ReadLine();
        }
Beispiel #6
0
        // Result as Stream
        public static void ToCellsAsStream()
        {
            // Setup Conversion configuration
            var conversionConfig = new ConversionConfig {
                StoragePath = storagePath, CachePath = cachePath
            };

            //instantiating the conversion handler
            var conversionHandler = new ConversionHandler(conversionConfig);

            var convertedDocumentStream = conversionHandler.Convert <Stream>(inputGUIDFile, new CellsSaveOptions());
        }
Beispiel #7
0
        //public static string inputGUIDFile = "Slidessample.Pdf";

        // Result as file path
        public static void ToSlidesAsPath()
        {
            // Setup Conversion configuration
            var conversionConfig = new ConversionConfig {
                StoragePath = storagePath, CachePath = cachePath
            };

            //instantiating the conversion handler
            var conversionHandler = new ConversionHandler(conversionConfig);

            var convertedDocumentPath = conversionHandler.Convert <string>(inputGUIDFile, new SlidesSaveOptions());
        }
Beispiel #8
0
        public BoneLookup([NotNull] ConversionConfig conversionConfig)
        {
            switch (conversionConfig.SkeletonFormat)
            {
            case SkeletonFormat.Mmd:
                _bonePathMap = _bonePathMapMmd;
                break;

            case SkeletonFormat.Mltd:
                _bonePathMap = _bonePathMapMltd;
                break;

            default:
                throw new NotSupportedException("You must choose a skeleton format.");
            }

            var dict = new Dictionary <string, string>();

            foreach (var kv in _bonePathMap)
            {
                string boneName;

                if (kv.Key.Contains(BoneNamePart_BodyScale))
                {
                    boneName = kv.Key.Replace(BoneNamePart_BodyScale, string.Empty);
                }
                else
                {
                    boneName = kv.Key;
                }

                dict.Add(boneName, kv.Value);
            }

            dict.AssertAllValuesUnique();

            _boneNameMap = dict;

            {
                var d = new Dictionary <string, string>();

                foreach (var kv in dict)
                {
                    d.Add(kv.Value, kv.Key);
                }

                _boneNameMapInversion = d;
            }

            _conversionConfig = conversionConfig;
            _scalingConfig    = new ScalingConfig(conversionConfig);
        }
        //public static string inputGUIDFile = "PDFsample.pdf";

        // Result as file path
        public static void ToImageAsPath()
        {
            // Setup Conversion configuration
            var conversionConfig = new ConversionConfig {
                StoragePath = storagePath, CachePath = cachePath
            };

            //instantiating the conversion handler
            var conversionHandler = new ConversionHandler(conversionConfig);

            var convertedDocumentPath = conversionHandler.Convert <IList <string> >(inputGUIDFile, new ImageSaveOptions {
                ConvertFileType = ImageSaveOptions.ImageFileType.Jpg
            });
        }
Beispiel #10
0
 int GetSqlCommandTimeOut()
 {
     try
     {
         string configValue = ConversionConfig.GetValue("SqlCommand:CommandTimeOut");
         var    timeout     = 0;
         if (int.TryParse(configValue, out timeout))
         {
             return(timeout > 0 ? timeout : SqlCommandDefaultTimeOut);
         }
         return(SqlCommandDefaultTimeOut);
     }
     catch (Exception)
     {
         return(SqlCommandDefaultTimeOut);
     }
 }
        protected void lnkbtn_Convert_OnClick(object sender, EventArgs e)
        {
            /*
             * CONVERT ALL THE FILES TO PDF FORMAT & STORE IN OUTPUT_DIRECTORY
             */
            foreach (ListItem files in lst_SourceFiles.Items)
            {
                //SET UPLOAD FOLDER
                filePath = Server.MapPath("~/Uploads/");

                //SET CACHE FOLDER WHERE THE CONVERSION TEMPORARY FILES ARE RUNNING
                cachePath = Server.MapPath("~/Cache/");

                //SET OUTPUT FOLDER WHERE THE ACTUAL FILES WILL BE PLACED AFTER CONVERSION
                outputPath = Server.MapPath("~/OutputDir/");

                //ORIGINAL FILE NAME WITH EXTENSION e.g SAMPLEFILE1.DOC
                string file = files.Text;

                //CONVERSION CONFIGURATION FOR DEFAULT
                ConversionConfig _conConfg = new ConversionConfig
                {
                    StoragePath = filePath,
                    CachePath   = cachePath,
                    OutputPath  = outputPath
                };

                ConversionHandler conversionHandler = new ConversionHandler(_conConfg);

                //CONVERSION TO PDF VIA FILE PATH
                var convertedPDF = conversionHandler.Convert <string>(file, new PdfSaveOptions
                {
                    ConvertFileType = PdfSaveOptions.PdfFileType.Pdf,
                    OutputType      = OutputType.String
                });
            }

            //GETS ALL THE CONVERTED FILES FROM OUTPUT FOLDER
            string[] myOutputFiles = Directory.GetFiles(outputPath);
            foreach (var items in myOutputFiles)
            {
                lst_DestinationFiles.Items.Add(new ListItem(Path.GetFileName(items), items));
            }

            lbl_destinationFiles.Text = @"All " + myOutputFiles.Length + " have been successfully synced!";
        }
Beispiel #12
0
        private static ConversionConfig PrepareConversionConfig([NotNull] MainWorkerInputParams ip)
        {
            var cc = new ConversionConfig();

            cc.MotionFormat                        = ip.MotionSource;
            cc.ScaleToPmxSize                      = ip.ScalePmx;
            cc.ApplyPmxCharacterHeight             = ip.ConsiderIdolHeight;
            cc.TranslateBoneNamesToMmd             = ip.TranslateBoneNames;
            cc.AppendIKBones                       = ip.AppendLegIkBones;
            cc.FixMmdCenterBones                   = ip.FixCenterBones;
            cc.FixTdaBindingPose                   = ip.ConvertBindingPose;
            cc.AppendEyeBones                      = ip.AppendEyeBones;
            cc.HideUnityGeneratedBones             = ip.HideUnityGeneratedBones;
            cc.SkeletonFormat                      = ip.MotionSource == MotionFormat.Mltd ? SkeletonFormat.Mltd : SkeletonFormat.Mmd;
            cc.TranslateFacialExpressionNamesToMmd = ip.TranslateFacialExpressionNames;
            cc.ImportPhysics                       = ip.ImportPhysics;
            cc.AddHairHighlights                   = ip.AddHairHighlights;
            cc.AddEyesHighlights                   = ip.AddEyesHighlights;

            cc.Transform60FpsTo30Fps = ip.TransformTo30Fps;
            cc.ScaleToVmdSize        = ip.ScaleVmd;

            {
                var mappingsJson = File.ReadAllText(ip.FacialExpressionMappingFilePath, Encoding.UTF8);
                var mappingsObj  = JsonConvert.DeserializeObject <FacialConfig>(mappingsJson);

                var dict = new Dictionary <int, IReadOnlyDictionary <string, float> >();

                foreach (var expr in mappingsObj.Expressions)
                {
                    var d2 = new Dictionary <string, float>();

                    foreach (var kv in expr.Data)
                    {
                        d2[kv.Key] = kv.Value;
                    }

                    dict[expr.Key] = d2;
                }

                cc.FacialExpressionMappings = dict;
            }

            return(cc);
        }
        static void Main()
        {
            var storagePath = Path.Combine(RootFolder, "TestFiles");
            var cachePath   = Path.Combine(RootFolder, "Cache");

            // Set license
            License license = new License();

            license.SetLicense("");

            // Setup Conversion configuration
            var conversionConfig = new ConversionConfig
            {
                StoragePath = storagePath,
                OutputPath  = ResultPath,
                CachePath   = cachePath,
                UseCache    = false
            };

            _conversionHandler = new ConversionHandler(conversionConfig);

            // Convert Pdf To Html
            ConvertPdfToHtml();

            // Convert Doc to Pdf
            ConvertDocToPdf();

            // Convert Doc From Stream to PDf
            ConvertDocFromStreamToPdf();

            // Convert Doc to Jpg
            ConvertDocToJpg();

            // Convert Doc to Jpg with custom options
            ConvertDocToPngWithCustomOptions();

            // Convert Doc to Bmp through Pdf
            ConvertDocToBmpThroughPdf();

            //Convert Doc to PDF and return the path of the converted file
            ConvertDocToPdfReturnPath();

            Console.WriteLine("Conversion complete. Press any key to exit");
            Console.ReadKey();
        }
Beispiel #14
0
        public GoogleInputHandler(ConversionConfig conversionConfig)
        {
            _conversionConfig = conversionConfig;
            var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                new ClientSecrets
            {
                ClientId     = ClientId,
                ClientSecret = ClientSecret
            },
                new[] { DriveService.Scope.DriveReadonly },
                "user",
                CancellationToken.None,
                new FileDataStore("GoogleAuth", true));

            _dataService = new DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential.Result
            });
        }
        protected override void FinishWizard()
        {
            ConversionConfigs = new List <ConversionConfig>();

            foreach (var vm in pageVmSelection.SelectedVms)
            {
                ConversionConfigs.Add(new ConversionConfig
                {
                    SourceVmName    = vm.Name,
                    SourceVmUUID    = vm.UUID,
                    PreserveMAC     = pageNetworkOptions.PreserveMAC,
                    NetworkMappings = ConversionConfig.DictionaryToStruct(pageNetworkOptions.RawMappings),
                    SourceServer    = pageCredentials.VmwareCredInfo,
                    StorageMapping  = new StorageMapping {
                        SRuuid = pageSrSelection.SelectedSR.uuid
                    }
                });
            }

            base.FinishWizard();
        }
Beispiel #16
0
        public BoneLookup([NotNull] ConversionConfig conversionConfig)
        {
            switch (conversionConfig.SkeletonFormat)
            {
            case SkeletonFormat.Mmd:
                _bonePathMap = BonePathMapMmd;
                break;

            case SkeletonFormat.Mltd:
                _bonePathMap = BonePathMapMltd;
                break;

            default:
                throw new NotSupportedException("You must choose a skeleton format.");
            }

            var dict = new Dictionary <string, string>();

            foreach (var kv in _bonePathMap)
            {
                string boneName;

                if (kv.Key.Contains("BODY_SCALE/"))
                {
                    boneName = kv.Key.Replace("BODY_SCALE/", String.Empty);
                }
                else
                {
                    boneName = kv.Key;
                }

                dict.Add(boneName, kv.Value);
            }

            _boneNameMap      = dict;
            _conversionConfig = conversionConfig;
            _scalingConfig    = new ScalingConfig(conversionConfig);
        }
        private static void ConvertPdfToImage(string fileName, ImageSaveOptions.ImageFileType outputFileType)
        {
            String sourcePath = @"C:\";
            String targetPath = @"D:\";

            var conversionConfig = new ConversionConfig {
                StoragePath = sourcePath, OutputPath = targetPath
            };

            var conversionHandler = new ConversionHandler(conversionConfig);

            var saveOptions = new ImageSaveOptions
            {
                ConvertFileType = outputFileType
            };

            var convertedDocumentPath = conversionHandler.Convert(sourcePath + fileName, saveOptions);

            for (int pageNum = 1; pageNum < convertedDocumentPath.PageCount; pageNum++)
            {
                convertedDocumentPath.Save("Output-" + Path.GetFileNameWithoutExtension(fileName) + pageNum.ToString() + "." + outputFileType, pageNum);
            }
        }
        static void Main()
        {
            const string sourceFileName = "sample.doc"; //TODO: Put the source filename here

            // Setup Conversion configuration
            var conversionConfig = new ConversionConfig
            {
                OutputPath  = "result",
                StoragePath = "."
            };

            conversionConfig.UseCache = true;

            var inputDataHandler  = new AmazonInputDataHandler();
            var outputDataHandler = new AmazonOutputDataHandler(conversionConfig);
            var conversionHandler = new ConversionHandler(conversionConfig, inputDataHandler, outputDataHandler);

            var resultPath = conversionHandler.Convert <string>(sourceFileName, new PdfSaveOptions {
                OutputType = OutputType.String
            });

            Console.WriteLine("The conversion finished. The result can be located here: {0}. Press <<ENTER>> to exit.", resultPath);
            Console.ReadLine();
        }
        internal static BaseDao GetCurrent()
        {
            var siteName = ConversionConfig.GetValue("SiteName");

            return(GetDao(siteName));
        }
Beispiel #20
0
        private void DoWork(object state)
        {
            ConversionConfig PrepareConversionConfig(InputParams ip)
            {
                var cc = new ConversionConfig();

                cc.MotionFormat                        = ip.MotionSource;
                cc.ScaleToPmxSize                      = ip.ScalePmx;
                cc.ApplyPmxCharacterHeight             = ip.ConsiderIdolHeight;
                cc.TranslateBoneNamesToMmd             = ip.TranslateBoneNames;
                cc.AppendIKBones                       = ip.AppendLegIkBones;
                cc.FixMmdCenterBones                   = ip.FixCenterBones;
                cc.FixTdaBindingPose                   = ip.ConvertBindingPose;
                cc.AppendEyeBones                      = ip.AppendEyeBones;
                cc.HideUnityGeneratedBones             = ip.HideUnityGeneratedBones;
                cc.SkeletonFormat                      = ip.MotionSource == MotionFormat.Mltd ? SkeletonFormat.Mltd : SkeletonFormat.Mmd;
                cc.TranslateFacialExpressionNamesToMmd = ip.TranslateFacialExpressionNames;
                cc.ImportPhysics                       = ip.ImportPhysics;

                cc.Transform60FpsTo30Fps = ip.TransformTo30Fps;
                cc.ScaleToVmdSize        = ip.ScaleVmd;

                {
                    var mappingsJson = File.ReadAllText(ip.FacialExpressionMappingFilePath, Encoding.UTF8);
                    var mappingsObj  = JsonConvert.DeserializeObject <FacialConfig>(mappingsJson);

                    var dict = new Dictionary <int, IReadOnlyDictionary <string, float> >();

                    foreach (var expr in mappingsObj.Expressions)
                    {
                        var d2 = new Dictionary <string, float>();

                        foreach (var kv in expr.Data)
                        {
                            d2[kv.Key] = kv.Value;
                        }

                        dict[expr.Key] = d2;
                    }

                    cc.FacialExpressionMappings = dict;
                }

                return(cc);
            }

            Debug.Assert(InvokeRequired, "The worker procedure should be running on the worker thread.");

            Log("Worker started.");

            try {
                var p = (InputParams)state;

                ConversionConfig.Current = PrepareConversionConfig(p);

                if (p.IdolHeight <= 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(p.IdolHeight), "Invalid idol height.");
                }

                ScalingConfig.CharacterHeight = p.IdolHeight;

                do
                {
                    var bodyAvatar = ResourceLoader.LoadBodyAvatar(p.InputBody);
                    if (bodyAvatar == null)
                    {
                        Log("Failed to load body avatar.");
                        break;
                    }

                    var bodyMesh = ResourceLoader.LoadBodyMesh(p.InputBody);
                    if (bodyMesh == null)
                    {
                        Log("Failed to load body mesh.");
                        break;
                    }

                    var headAvatar = ResourceLoader.LoadHeadAvatar(p.InputHead);
                    if (headAvatar == null)
                    {
                        Log("Failed to load head avatar.");
                        break;
                    }

                    var headMesh = ResourceLoader.LoadHeadMesh(p.InputHead);
                    if (headMesh == null)
                    {
                        Log("Failed to load head mesh.");
                        break;
                    }

                    var(bodySway, headSway) = ResourceLoader.LoadSwayControllers(p.InputBody, p.InputHead);
                    if (bodySway == null || headSway == null)
                    {
                        Log("Failed to load sway controllers.");
                        break;
                    }

                    var combinedAvatar = CompositeAvatar.FromAvatars(bodyAvatar, headAvatar);
                    var combinedMesh   = CompositeMesh.FromMeshes(bodyMesh, headMesh);

                    CharacterImasMotionAsset dance;
                    ScenarioObject           scenario;

                    if (p.GenerateCharacterMotion)
                    {
                        (dance, _, _) = ResourceLoader.LoadDance(p.InputDance, p.SongPosition);
                        if (dance == null)
                        {
                            Log("Failed to load dance data.");
                            break;
                        }

                        scenario = ResourceLoader.LoadScenario(p.InputFacialExpression);
                        if (scenario == null)
                        {
                            Log("Failed to load scenario object.");
                            break;
                        }
                    }
                    else
                    {
                        dance    = null;
                        scenario = null;
                    }

                    CharacterImasMotionAsset camera;

                    if (p.GenerateCameraMotion)
                    {
                        camera = ResourceLoader.LoadCamera(p.InputCamera);
                        if (camera == null)
                        {
                            Log("Failed to load camera data.");
                            break;
                        }
                    }
                    else
                    {
                        camera = null;
                    }

                    do
                    {
                        // Now file names are like "ch_pr001_201xxx.unity3d".
                        var avatarName = (new FileInfo(p.InputHead).Name).Substring(3, 12);

                        // ss001_015siz -> 015ss001
                        // Note: PMD allows max 19 characters in texture file names.
                        // In the format below, textures will be named like:
                        // tex\015ss001_01.png
                        // which is at the limit.
                        var texPrefix = avatarName.Substring(6, 3) + avatarName.Substring(0, 5);
                        texPrefix = @"tex\" + texPrefix + "_";

                        Log("Generating model...");

                        var pmxCreator = new PmxCreator();
                        var pmx        = pmxCreator.CreateFrom(combinedAvatar, combinedMesh, bodyMesh.VertexCount, texPrefix, bodySway, headSway);

                        if (p.GenerateModel)
                        {
                            Log("Saving model...");

                            using (var w = new PmxWriter(File.Open(p.OutputModel, FileMode.Create, FileAccess.Write, FileShare.Write))) {
                                w.Write(pmx);
                            }
                        }

                        if (p.GenerateCharacterMotion)
                        {
                            Log("Generating character motion...");

                            var creator = new VmdCreator {
                                ProcessBoneFrames   = true,
                                ProcessCameraFrames = false,
                                ProcessFacialFrames = true,
                                ProcessLightFrames  = false
                            };

                            var danceVmd = creator.CreateFrom(dance, combinedAvatar, pmx, null, scenario, p.SongPosition);

                            Log("Saving character motion...");

                            using (var w = new VmdWriter(File.Open(p.OutputCharacterAnimation, FileMode.Create, FileAccess.Write, FileShare.Write))) {
                                w.Write(danceVmd);
                            }
                        }

                        if (p.GenerateCameraMotion)
                        {
                            Log("Generating camera motion...");

                            if (p.UseMvd)
                            {
                                var creator = new MvdCreator {
                                    ProcessBoneFrames   = false,
                                    ProcessCameraFrames = true,
                                    ProcessFacialFrames = false,
                                    ProcessLightFrames  = false
                                };

                                var motion = creator.CreateFrom(null, null, null, camera, null, p.SongPosition);

                                Log("Writing camera motion...");

                                using (var w = new MvdWriter(File.Open(p.OutputCamera, FileMode.Create, FileAccess.Write, FileShare.Write))) {
                                    w.Write(motion);
                                }
                            }
                            else
                            {
                                var creator = new VmdCreator {
                                    ProcessBoneFrames   = false,
                                    ProcessCameraFrames = true,
                                    ProcessFacialFrames = false,
                                    ProcessLightFrames  = false
                                };

                                var motion = creator.CreateFrom(null, null, null, camera, null, p.SongPosition);

                                Log("Writing camera motion...");

                                using (var w = new VmdWriter(File.Open(p.OutputCamera, FileMode.Create, FileAccess.Write, FileShare.Write))) {
                                    w.Write(motion);
                                }
                            }
                        }
                    } while (false);
                } while (false);
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString(), ApplicationHelper.GetApplicationTitle(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            Log("Done.");

            Invoke(() => EnableMainControls(true));
        }
Beispiel #21
0
        protected void btnConvertAll_Click(object sender, EventArgs e)
        {
            // string lblFilesConverted = string.Empty;
            if (lstSourceFiles.Items.Count > 0)
            {
                lblConvStatus.Text    = "Conversion started. Please wait....";
                lblConvStatus.Visible = true;
                string outputfilename = string.Empty;
                foreach (ListItem lstItem in lstSourceFiles.Items)
                {
                    inputFile      = lstItem.Text;
                    outputfilename = Path.GetFileNameWithoutExtension(inputFile) + ".pdf";
                    ListItem item = lstTargetFiles.Items.FindByValue(outputfilename);
                    if (item == null)
                    {
                        try
                        {
                            //one way
                            conversionConfig = new ConversionConfig {
                                OutputPath = outputPath, StoragePath = storagePath, CachePath = cachePath
                            };
                            conversionHandler     = new ConversionHandler(conversionConfig);
                            convertedDocumentPath =
                                conversionHandler.Convert <string>(inputFile, new PdfSaveOptions {
                                OutputType = OutputType.String
                            });

                            /* // another way
                             * conversionConfig = new ConversionConfig()
                             * {
                             *  OutputPath = outputPath,
                             *  CachePath = cachePath,
                             *  LocalesPath = cachePath,
                             *  StoragePath = storagePath,
                             *  UseCache = false
                             * };
                             *
                             *
                             * ConversionHandler conversionHandler = new ConversionHandler(conversionConfig);
                             * //check whether file suppoted
                             * var availableConversions = conversionHandler.GetSaveOptions(Path.GetExtension(inputFile).Replace(".", ""));
                             * PdfSaveOptions saveOptions = new PdfSaveOptions()
                             * {
                             *  ConvertFileType = PdfSaveOptions.PdfFileType.Pdf,
                             *  PageNumber = 1,
                             *  NumPagesToConvert = 1,
                             *  CustomName = Path.GetFileNameWithoutExtension(inputFile),
                             *  OutputType = OutputType.String
                             * };
                             * var memStream = new MemoryStream(File.ReadAllBytes(storagePath + "" + inputFile));
                             * convertedDocumentPath = conversionHandler.Convert<String>(memStream, saveOptions);
                             */
                            lstTargetFiles.Items.Add(outputfilename);
                        }
                        catch (Exception ex)
                        {
                            lblWrongFormat.Text    = inputFile + " issue - " + ex.Message;
                            lblWrongFormat.Visible = true;
                        }
                    }
                    else
                    {
                        lblConvStatus.Text = inputFile + " file already converted.";
                    }
                }
                lblConvStatus.Text = "Conversion completed.";
            }
        }
Beispiel #22
0
 public AmazonCacheDataHandler(ConversionConfig conversionConfig)
 {
     _conversionConfig = conversionConfig;
     _client           = new AmazonS3Client(RegionEndpoint.EUWest1);
 }