Beispiel #1
0
        public void DoTask()
        {
            try
            {
                var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

                //create split task
                var task = api.CreateTask <SplitTask>();

                //file variable contains server file name
                var file = task.AddFile("path/to/file/document.pdf");

                //proces added files
                //time var will contains information about time spent in process
                var time = task.Process(new SplitParams(new SplitModeFixedRanges(3)));
                task.DownloadFile("path");
            }
            catch (HttpRequestException ex)
            {
                var message = ex.Message;
                if (ex.InnerException != null)
                {
                    var innerException = ex.InnerException.Message;
                }
            }
            catch (Exception ex)
            {
                var message = ex.Message;
                if (ex.InnerException != null)
                {
                    var innerException = ex.InnerException.Message;
                }
            }
        }
Beispiel #2
0
        public void DoTask()
        {
            var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

            //create watermark task
            var task = api.CreateTask <WaterMarkTask>();

            //file variable contains server file name
            var file = task.AddFile("path/to/file/document.pdf");


            //parameters that will be posted
            var parameters = new WaterMarkParams(
                new WatermarkModeText("watermark text"))
            {
                Pages                        = "1-5,7",
                VerticalPosition             = WaterMarkVerticalPositions.Top,
                HorizontalPosition           = WaterMarkHorizontalPositions.Right,
                VerticalPositionAdjustment   = 100,
                HorizontalPositionAdjustment = 100,
                FontFamily                   = "Arial",
                FontStyle                    = FontStyles.Italic,
                FontSize                     = 12,
                FontColor                    = "#ff0000",
                Transparency                 = 50,
                Layer                        = Layer.Below,
                OutputFileName               = "watermarked"
            };

            //proces added files
            //time var will contains information about time spent in process
            var time = task.Process(parameters);

            task.DownloadFile("path");
        }
Beispiel #3
0
        public void Compress(string filePath, string destinationDirectoryPath)
        {
            if (api == null || string.IsNullOrEmpty(filePath) || string.IsNullOrEmpty(destinationDirectoryPath))
            {
                return;
            }

            try
            {
                // create compress task
                var task = api.CreateTask <CompressTask>();

                if (task == null)
                {
                    return;
                }

                // file variable contains server file name
                task.AddFile(filePath);

                // proces added files
                task.Process();

                // download files to specific folder
                task.DownloadFile(destinationDirectoryPath);
            }
            catch (Exception exception)
            {
                throw new Exception($@"/!\ Error while compressing : {filePath} ({exception.Message})");
            }
        }
Beispiel #4
0
        public void DoTask()
        {
            var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

            //create protect task
            var task = api.CreateTask <ProtectTask>();

            //file variable contains server file name
            var file = task.AddFile("path/to/file/document.pdf");

            //proces added files
            //time var will contains information about time spent in process
            var time = task.Process(new ProtectParams("test"));

            task.DownloadFile("path");
        }
Beispiel #5
0
        public void DoTask()
        {
            var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

            //create rotate task
            var task = api.CreateTask <RotateTask>();

            //file variable contains server file name
            var file = task.AddFile("path/to/file/document.pdf", task.TaskId, Rotate.Degrees0);

            //proces added files
            //time var will contains information about time spent in process
            var time = task.Process();

            task.DownloadFile("path");
        }
        public void DoTask()
        {
            var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

            //create validate task
            var task = api.CreateTask <ValidatePdfATask>();

            //file variable contains server file name
            var file = task.AddFile("path/to/file/document.pdf");

            //proces added files
            //time var will contains information about time spent in process
            var time = task.Process(new ValidatePdfAParams(ConformanceValues.PdfA1A));

            task.DownloadFile("path");
        }
Beispiel #7
0
        public void DoTask()
        {
            var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

            var task = api.CreateTask <RepairTask>();

            //file var contains information about server file name
            var file = task.AddFile("pat/to/file.pdf");

            // process files
            // time var will have info about time spent in process
            var time = task.Process();

            //download files to specific directory
            task.DownloadFile("/directory/to/save/files");
        }
Beispiel #8
0
        public void DoTask()
        {
            var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

            //create unlock task
            var task = api.CreateTask <UnlockTask>();

            //file variable contains server file name
            // set the password witch the document is locked
            var file = task.AddFile("path/to/file/document.pdf", task.TaskId, "test");

            //proces added files
            //time var will contains information about time spent in process
            var time = task.Process();

            task.DownloadFile("path");
        }
        public void DoTask()
        {
            var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

            //create compress task
            var task = api.CreateTask <CompressTask>();

            //file variable contains server file name
            var file = task.AddFile("path/to/file/document.pdf");

            //proces added files
            //time var will contains information about time spent in process
            var time = task.Process();


            //download files to specific folder
            task.DownloadFile("/destination/folder/path");
        }
Beispiel #10
0
        public void DoTask()
        {
            var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

            //create specific task
            var task = api.CreateTask <RepairTask>();

            //fileResponse will contains property with server file name
            var fileResponse = task.AddFile("/path/to/file.pdf");

            //specify repeaired paramters like output filename
            var time = task.Process(new RepairParams {
                OutputFileName = "repaired_filename"
            });

            //download file and save to specific directory
            task.DownloadFile("/directory/to/store/file");
        }
Beispiel #11
0
        public void DoTask()
        {
            var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

            var task = api.CreateTask <CompressTask>();

            //add file, and specify rotation
            var file = task.AddFile("/path/to/document.pdf", task.TaskId, Rotate.Degrees90);

            //set compress parameters and process files
            var time = task.Process(new CompressParams
            {
                CompressionLevel = CompressionLevels.Extreme,
                OutputFileName   = "extreme_compression"
            });

            //download output file(s) to specific directory
            task.DownloadFile("path/to/download");
        }
Beispiel #12
0
        public void DoTask()
        {
            var api = new LovePdfApi("PUBLIC_KEY", "SECRET_KEY");

            //create split task
            var task = api.CreateTask <SplitTask>();

            //file variable contains server file name
            var file = task.AddFile("path/to/file/document.pdf");

            //proces added files
            //time var will contains information about time spent in process
            var time = task.Process
                           (new SplitParams(new SplitModeRanges("2-4,6-8"))
            {
                OutputFileName = "split"
            });

            task.DownloadFile("path");
        }
Beispiel #13
0
        public void TestCompress(LovePdfApi api, ICollection <string> files)
        {
            var taskCompress = api.CreateTask <CompressTask>();

            foreach (var file in files)
            {
                taskCompress.AddFile(file);
            }

            taskCompress.Process();

            var resultFile = $"{Settings.BASE_PATH}{Path.DirectorySeparatorChar}{Settings.GOOD_PDF_FILE}";

            if (File.Exists(resultFile))
            {
                File.Delete(resultFile);
            }

            taskCompress.DownloadFile(Settings.BASE_PATH);

            Assert.IsTrue(File.Exists(resultFile));
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            var api = new LovePdfApi(@"project_public_3fedaeb8b6ff0e34a849c049422f4725_ZQHs-56404af1d4525a22201eeacc0b8e4ed0", @"secret_key_e6e42ebc47aaa75f7161b307a3464297__tMrk149492f181e7a12e0eae08527cfa166a");

            //create compress task
            var task = api.CreateTask <CompressTask>();


            //file variable contains server file name
            var file = task.AddFile(@"should-work.pdf");

            var taskParams = new CompressParams()
            {
                OutputFileName = @"test"
            };

            //proces added files
            //time var will contains information about time spent in process
            var time = task.Process(taskParams);

            //download files to specific folder
            task.DownloadFile();
        }