public void GenerateResume(string pathToFile) { var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true }; Data.Json.Resume resume = null; try { resume = JsonParser.GetModelFromJson <Data.Json.Resume>(options, pathToFile); } catch (JsonException jsonException) { _logger.LogError(jsonException, "Could not parse the JSON"); } catch (ArgumentException argumentException) { _logger.LogError(argumentException, "JSON does not match the required schema."); } if (resume != null) { _logger.LogInformation("Mapped resume to an object."); CreatePdfDocument(resume); _logger.LogInformation("Created PDF."); } }
public void Create(Data.Json.Resume resume) { var(pdf, document) = CreateDocument(); document.SetMargins(0, 0, 0, 0); document.SetFont(PdfFontFactory.CreateFont(StandardFonts.HELVETICA)).SetFontSize(9); var pageTable = new Table(2); pageTable.SetWidth(UnitValue.CreatePercentValue(100)); var sideBarCell = new Cell().SetBackgroundColor(new DeviceRgb(242, 242, 242)).SetBorder(Border.NO_BORDER).SetWidth(UnitValue.CreatePercentValue(30)); var contentCell = new Cell().SetBorder(Border.NO_BORDER).SetWidth(UnitValue.CreatePercentValue(70)); sideBarCell.Add(CreateProfilePicture(pdf)); sideBarCell.Add(CreateBasics(resume.Basics)); sideBarCell.Add(CreateLanguages(resume.Languages)); sideBarCell.Add(CreateInterests(resume.Interests)); contentCell.Add(CreateSummary(resume.Basics.Summary)); contentCell.Add(CreateWork(resume.Work)); contentCell.Add(CreateEducation(resume.Education)); contentCell.Add(CreateSkills(resume.Skills)); pageTable.AddCell(sideBarCell); pageTable.AddCell(contentCell); pageTable.AddCell(new Cell(1, 2).Add(CreateMessage())); document.Add(pageTable); document.Close(); }
private void CreatePdfDocument(Data.Json.Resume resume) { _resumeGenerator.Create(resume); }