public IPDFConverterOutput UrlToPdf(IPDFConverterInput input) { IPDFConverterOutput resultModel = new PDFConverterOutput { IsSuccess = true }; try { PdfDocument doc = _converter.ConvertUrl(input.Source); string filePath = GetFilePath(input); FileWriteRead(filePath); doc.Save(filePath); doc.Close(); } catch (System.Exception ex) { resultModel.Messages.Add(new PDFResultMessage { Code = "Physical_UrlToPdf", Message = ex.ToString() }); resultModel.IsSuccess = false; } return(resultModel); }
public IPDFConverterOutput UrlToPdf(IPDFConverterInput input) { IPDFConverterOutput resultModel = new PDFConverterOutput { IsSuccess = true }; try { PdfDocument doc = _converter.ConvertUrl(input.Source); string filePath = GetFilePath(input); doc.Save(filePath);//temp olarak kayıt et.. doc.Close(); byte[] fileData = FileWriteRead(filePath); //byte[] fileData = File.ReadAllBytes(filePath); FileDelete(filePath); var cloudAsyncUpload = GetUploadAsync(); cloudAsyncUpload.UploadAsyncFile(new PDFByteUploadInput { FileData = fileData, FileName = input.Name }, path: input.Path); } catch (System.Exception ex) { resultModel.Messages.Add(new PDFResultMessage { Code = "Cloud_HtmlToPdf", Message = ex.ToString() }); resultModel.IsSuccess = false; } return(resultModel); }
public IPDFConverterOutput UrlToPdf(IPDFConverterInput input) { IPDFConverterOutput resultModel = new PDFConverterOutput { IsSuccess = true }; try { var doc = new HtmlToPdfDocument() { GlobalSettings = { PaperSize = PaperKind.A4, Orientation = Orientation.Portrait, } }; if (!string.IsNullOrEmpty(input.Source)) { doc.Objects.Add(new ObjectSettings { Page = input.Source, WebSettings = { DefaultEncoding = "utf-8" }, HeaderSettings = { FontSize = 9, Right = "Page [page] of [toPage]", Line = true }, FooterSettings = { FontSize = 9, Right = "Page [page] of [toPage]" } }); } byte[] fileData = _converter.Convert(doc); var cloudAsyncUpload = GetUploadAsync(); cloudAsyncUpload.UploadAsyncFile(new PDFByteUploadInput { FileData = fileData, FileName = input.Name }, path: input.Path); } catch (System.Exception ex) { resultModel.Messages.Add(new PDFResultMessage { Code = "DinkToPDFConverter_Cloud_UrlToPdf", Message = ex.ToString() }); resultModel.IsSuccess = false; } return(resultModel); }
public IPDFConverterOutput HtmlToPdf(IPDFConverterInput input) { IPDFConverterOutput resultModel = new PDFConverterOutput { IsSuccess = true }; try { var doc = new HtmlToPdfDocument() { GlobalSettings = { PaperSize = PaperKind.A4, Orientation = Orientation.Landscape, }, }; if (!string.IsNullOrEmpty(input.Source)) { doc.Objects.Add(new ObjectSettings { HtmlContent = input.Source, PagesCount = true, WebSettings = { DefaultEncoding = "utf-8" }, HeaderSettings = { FontSize = 9, Right = "Page [page] of [toPage]", Line = true }, FooterSettings = { FontSize = 9, Right = "Page [page] of [toPage]" } }); } byte[] pdf = _converter.Convert(doc); string filePath = GetFilePath(input); FileWrite(filePath, pdf); } catch (System.Exception ex) { resultModel.Messages.Add(new PDFResultMessage { Code = "DinkToPDF_Physical_HtmlToPdf", Message = ex.ToString() }); resultModel.IsSuccess = false; } return(resultModel); }