public void RecognizeIsbnWithUnderscores() { var sut = new PDFUtils(); var isbn = "isbn 123_4_5678_9012_3"; Assert.Equal("1234567890123", sut.FindIsbn(isbn)); }
public void FindIsbn() { var sut = new PDFUtils(); var input = "abcd ---- _#$1ff 1234 isbn 1234567890 ffff ?!434 @@@@@ xxxx"; Assert.Equal("1234567890", sut.FindIsbn(input)); }
public void RecognizeIsbnSeparatedByColonOnly() { var sut = new PDFUtils(); var isbn = "isbn:1234567890"; Assert.Equal("1234567890", sut.FindIsbn(isbn)); }
public void RecognizeIsbnWithDashes() { var sut = new PDFUtils(); var isbn = "isbn 123-4-5678-9012-3"; Assert.Equal("1234567890123", sut.FindIsbn(isbn)); }
public void RecognizeIsbnUppercase() { var sut = new PDFUtils(); var isbn = "ISBN 1234567890123"; Assert.Equal("1234567890123", sut.FindIsbn(isbn)); }
public void RecognizeExplicitIsbn() { var sut = new PDFUtils(); var isbn = "isbn-10 1234567890"; Assert.Equal("1234567890", sut.FindIsbn(isbn)); }
public void RecognizeIsbnSeparatedByWhitespaceDashWhitespace() { var sut = new PDFUtils(); var isbn = "isbn - 1234567890"; Assert.Equal("1234567890", sut.FindIsbn(isbn)); }
public void RecognizeIsbnSeparatedByGarbage() { var sut = new PDFUtils(); var isbn = "isbn-13 (abcd): 1234567890123"; Assert.Equal("1234567890123", sut.FindIsbn(isbn)); }
private void generarPDFVentas_Click(object sender, EventArgs e) { try { List <Venta> ventas = new List <Entities.Venta>(); int elements = rnd.Next(1, 50); for (int i = 0; i < elements; i++) { ventas.Add(createVenta()); } PDFUtils pdfUtils = new PDFUtils(); String filePath = pdfUtils.crearPDFVentas(ventas); if (!String.IsNullOrEmpty(filePath)) { System.Diagnostics.Process.Start(@filePath); } } catch (DirectoryNotFoundException exception) { MessageBox.Show("No es posible hallar el directorio determinado, por favor revise la configuración", "Alerta"); } catch (IOException exception) { MessageBox.Show("No es posible crear el archivo, ya existe un archivo con el mismo nombre", "Alerta"); } catch (Exception exception) { MessageBox.Show("No es posible generar el archivo. Póngase en contacto con el administrador", "Alerta"); } }
private void inscriptionButton_Click(object sender, EventArgs e) { try { ClienteActividad clienteActividad = new ClienteActividad(); Cliente cliente = new Cliente(); cliente.Dni = "666"; cliente.Apellido = "Ponce"; cliente.Nombre = "Natalia Alejandra"; cliente.Domicilio = "Mateo Churich 1"; cliente.Celular = "15algunosnumerosmas"; cliente.Ciudad = "Garín"; cliente.Email = "*****@*****.**"; cliente.Estado = 1; cliente.Telefono = "niidea"; cliente.Pasaporte = "ppaassaappoorrttee (alaalegria)"; clienteActividad.Cliente = cliente; Actividad actividad = new Actividad(); actividad.Descripcion = "Querer y querer mucho"; actividad.Dias = "Todos los días"; actividad.Horarios = "de 00:00:00 a 23:59:59"; actividad.Nombre = "Tendrá nombre esto????"; actividad.Dificultad = "Facil"; List <Actividad> actividades = new List <Actividad>(); actividades.Add(actividad); clienteActividad.Actividades = actividades; PDFUtils pdfUtils = new PDFUtils(); String filePath = pdfUtils.crearPDFInscripcion(clienteActividad); if (!String.IsNullOrEmpty(filePath)) { System.Diagnostics.Process.Start(@filePath); } } catch (DirectoryNotFoundException exception) { MessageBox.Show("No es posible hallar el directorio determinado, por favor revise la configuración", "Alerta"); } catch (IOException exception) { MessageBox.Show("No es posible crear el archivo, ya existe un archivo con el mismo nombre", "Alerta"); } catch (Exception exception) { MessageBox.Show("No es posible generar el archivo. Póngase en contacto con el administrador", "Alerta"); } }
private void pepButton2_Click(object sender, EventArgs e) { StockDB.StockMethod.UpdateOrderState(Order.OrderNumber, "Completed ✓", DataBase); DataTable dtbl = PDFUtils.MakeTable(ListComponents); Kitbox.PDF.PDFUtils.ExportDataTableToPDF(dtbl, @"bill.pdf", "Facture : " + Customer["Surname"], Customer["IdClient"], float.Parse(PDFUtils.TotalCost(ListComponents)), "Finished"); System.Diagnostics.Process.Start(@"bill.pdf"); Parent.ClearWindow(); Parent.Search(); }
public string ConvertToPDF(string fileName, string outDir, bool createDir = false) { Preconditions.CheckArgument(fileName); Preconditions.CheckArgument(outDir); try { if (createDir) { if (!FileUtils.CheckDirectory(outDir)) { throw new DirectoryNotFoundException(String.Format("Output directory not found/be created. [path={0}]", outDir)); } } Uri uri = new Uri(fileName); string pname = null; if (uri.Scheme == Uri.UriSchemeFile) { pname = uri.LocalPath; FileInfo inFile = new FileInfo(pname); if (!inFile.Exists) { throw new FileNotFoundException("Input Excel file not found.", fileName); } pname = Path.GetFileNameWithoutExtension(inFile.FullName); } else if (uri.Scheme == Uri.UriSchemeHttps || uri.Scheme == Uri.UriSchemeHttp) { pname = uri.Host + "/" + uri.PathAndQuery; Regex rgx = new Regex("[^a-zA-Z0-9 -]"); pname = rgx.Replace(pname, "_"); } string outpath = String.Format("{0}/{1}.PDF", outDir, pname); LogUtils.Debug(String.Format("Generating PDF output. [path={0}]", outpath)); string html = client.DownloadString(fileName); if (!String.IsNullOrEmpty(html)) { PdfDocument doc = PdfGenerator.GeneratePdf(html, PDFUtils.Parse(PageSize)); doc.Save(outpath); } return(outpath); } catch (Exception ex) { LogUtils.Error(ex); throw ex; } }
private void button1_Click(object sender, EventArgs e) { try { PDFUtils pdfUtils = new PDFUtils(); Voucher voucher = new Voucher(); voucher.Numero = "112233445566"; voucher.Estado = "Pagado"; voucher.Cantindad = 2; Producto producto = new Producto(); producto.Nombre = "UnProductoooooo"; voucher.Producto = producto; Cliente cliente = new Cliente(); cliente.Dni = "666"; cliente.Apellido = "Ponce"; cliente.Nombre = "Natalia Alejandra"; cliente.Domicilio = "Mateo Churich 1234"; voucher.Cliente = cliente; String filePath = pdfUtils.crearPDFVoucher(voucher); if (!String.IsNullOrEmpty(filePath)) { System.Diagnostics.Process.Start(@filePath); } } catch (DirectoryNotFoundException exception) { MessageBox.Show("No es posible hallar el directorio determinado, por favor revise la configuración", "Alerta"); } catch (IOException exception) { MessageBox.Show("No es posible crear el archivo, ya existe un archivo con el mismo nombre", "Alerta"); } catch (Exception exception) { MessageBox.Show("No es posible generar el archivo. Póngase en contacto con el administrador", "Alerta"); } }
public FileContentResult GetPDFReport(RequestViewModel model) { Document doc = new Document(PageSize.A4.Rotate(), 10f, 10f, 140f, 55f); doc.AddTitle("Reporte de solicitudes"); doc.AddCreator("SPU"); MemoryStream stream = new MemoryStream(); DataSet ds = new DataSet(); EmpresaViewModel empresa = new EmpresaViewModel(); try { PdfWriter pdfWriter = PdfWriter.GetInstance(doc, stream); pdfWriter.CloseStream = false; empresa.razon_social = "SISTEMAS EN PUNTO"; empresa.nombre_comercial = "Administración de solicitudes"; pdfWriter.PageEvent = new PDFEvents(empresa, null, "Reporte de solicitudes"); doc.Open(); string[] headers = new string[] { "#", "USUARIO", "SOLICITUD", "FECHA", "STATUS", "PREGUNTA 1", "PREGUNTA 2", "PREGUNTA 3", "PREGUNTA 4", "PREGUNTA 5" }; int[] tableWidths = new int[] { 60, 60, 60, 60, 70, 80, 80, 80, 80, 80 }; IList <string[]> rowsData = new List <string[]>(); var userId = Convert.ToInt32(User.Identity.Name.Split('|')[1]); var data = RequestObject.GetListCopy(userId, model); foreach (var item in data.Data.OfType <RequestViewModel>().ToList()) { var questions = item.QuestionsVM.ToList(); rowsData.Add(new string[] { item.RequestId.ToString(), item.UserName, item.ConceptName.ToString(), item.CreatedAt, item.StatusName, questions != null ? questions.ElementAtOrDefault(0) != null ? questions.ElementAtOrDefault(0).Text : string.Empty : string.Empty, questions != null ? questions.ElementAtOrDefault(1) != null ? questions.ElementAtOrDefault(1).Text : string.Empty : string.Empty, questions != null ? questions.ElementAtOrDefault(2) != null ? questions.ElementAtOrDefault(2).Text : string.Empty : string.Empty, questions != null ? questions.ElementAtOrDefault(3) != null ? questions.ElementAtOrDefault(3).Text : string.Empty : string.Empty, questions != null ? questions.ElementAtOrDefault(4) != null ? questions.ElementAtOrDefault(4).Text : string.Empty : string.Empty }); } PdfPTable mainTable = PDFUtils.BuildTableBody(headers, rowsData, tableWidths); doc.Add(mainTable); doc.Close(); stream.Flush(); stream.Position = 0; } catch (Exception ex) { throw; } return(File(stream.GetBuffer(), "application/pdf", "file.pdf")); }
public async Task <byte[]> PrintPDF(string url, IEnumerable <CookieParam> cookies, ViewPortOptions viewport, PdfOptions options, RevisionInfo revision) { LaunchOptions launchOptions = new LaunchOptions() { ExecutablePath = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", Args = BrowserArgs, Headless = true, DefaultViewport = viewport, Timeout = 0 }; browser = await Puppeteer.LaunchAsync(launchOptions); try { var page = await browser.NewPageAsync(); try { WaitUntilNavigation[] waitUntilNavigations = { WaitUntilNavigation.Networkidle0 }; NavigationOptions navigationOptions = new NavigationOptions() { Timeout = 0, WaitUntil = waitUntilNavigations }; string originalUserAgent = await browser.GetUserAgentAsync(); await page.SetUserAgentAsync($"{originalUserAgent} {USER_AGENT_SUFFIX}"); if (cookies.Any()) { await page.SetCookieAsync(cookies.ToArray()); } await page.GoToAsync(url, navigationOptions); await InjectCustomStylesAsync(page, ref options); bool hasPageNumbers = await page.EvaluateFunctionAsync <bool>("(window.UltimatePDF? window.UltimatePDF.hasPageNumbers : function() { return false; })"); if (hasPageNumbers) { /* * When the layout has page numbers, we first retrieve a * first blank pdf to calculate the number of pages. * Then, knowing how many pages, we can layout the headers and footers, * and retrieve the final pdf. */ byte[] blankContents = await page.PdfDataAsync(options); using (var blankPdf = new PDFUtils(blankContents)) { await page.EvaluateFunctionAsync("window.UltimatePDF.layoutPages", blankPdf.Pages); return(await page.PdfDataAsync(options)); } } else { return(await page.PdfDataAsync(options)); } } finally { await Cleanup(page); } } finally { Cleanup(browser); } }