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"); }
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; } } }
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"); }
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"); }
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"); 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"); }
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"); }
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"); }
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"); }
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"); }
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)); }
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(); }
public PdfCompressor(string publicKey, string privateKey) { api = new LovePdfApi(publicKey, privateKey); }
protected void InitApiWithRightCredentials() { Api = new LovePdfApi(Settings.RightPublicKey, Settings.RightSecretKey); }
protected void InitApiWithWrongCredentials() { Api = new LovePdfApi(Settings.WrongPublicKey, Settings.WrongSecretKey); }
/// <summary> /// If you need to apply different tools on the same files, connected task resource will allows /// you to execute a new task on the files resulting from the previous tool. Using this resource /// you don't need to upload your files again. The response will contain the new task id and the /// files (the server_filename as key and filename as value), with server filename and the file /// name, you will need for the process step. Once the new connected task is created you can add, /// remove files, and work like another tool. /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public T Next <T>() where T : LovePdfTask { return(LovePdfApi.ConnectTask <T>(this)); }