Я использую PdfSharp для создания PDF-документа.мой контент HTML.он генерирует PDF хорошо, но содержимое внутри PDF не является правильным.Содержание имеет много изображений и HTML-тегов.поэтому страницы pdf не получают правильного дизайна. Мой код для pdf: -
string fullpath = "", fileName = "";
try
{
_ILocationService.Book(model);
PdfSharp.Pdf.PdfDocument document = new PdfSharp.Pdf.PdfDocument();
string noSpace = Regex.Replace(model.BookName, " ", "");
string removeSpecialCharacter = RemoveDigits(noSpace).Replace(":", "");
fileName = Regex.Replace(removeSpecialCharacter, @"[^0-9a-zA-Z]+", "") + ".pdf";
fullpath = Path.Combine(Server.MapPath("~/OtherDocuments"), fileName);
string html = "";
html += model.BookPage;
html += string.Join("<p style='page-break-inside: avoid;'></p>", model.CollectionBookList.Select(x => x.BookPage).ToArray());
//byte[] pdfBytes = (new NReco.PdfGenerator.HtmlToPdfConverter()).GeneratePdf(html).;
////System.IO.File.WriteAllBytes(fullpath, pdf.BinaryData);
//System.IO.File.WriteAllBytes(fullpath, pdfBytes);
PdfSharp.Pdf.PdfDocument pdf = TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.A4);
pdf.Save(fullpath);
, а мой html в переменной "html" -
<p><img alt="" src="https://images-na.ssl-images-amazon.com/images/I/51Yv54zzwTL._SX326_BO1,204,203,200_.jpg" style="height:100%; width:100%" /></p>
<p> </p>
<p><img alt="Image result for images global green" src="http://www.chooseprint.org/images/TwoSides/GoingPaperlessNotGreener.png" style="height:372px; width:254px" /></p>
<p style='page-break-inside: avoid;'></p><p><img alt="" src="https://images.pexels.com/photos/40142/new-york-skyline-manhattan-hudson-40142.jpeg?auto=compress&cs=tinysrgb&h=650&w=940" style="height:100%; width:100%" /></p>
<p style='page-break-inside: avoid;'></p><p><img alt="" src="https://images.pexels.com/photos/374710/pexels-photo-374710.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260%201x,%20https://images.pexels.com/photos/374710/pexels-photo-374710.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260%202x" style="float:left; height:132px; width:200px" /> </p>
<h2>What is Lorem Ipsum?</h2>
<p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with </p>
<p> </p>
<p style='page-break-inside: avoid;'></p><p><img alt="" src="https://www.hdwallpaper.nu/wp-content/uploads/2017/03/building-7.jpg" style="height:100%; width:100%" /></p>
<h2> </h2>
<p style='page-break-inside: avoid;'></p><p><img alt="" src="https://images.pexels.com/photos/358382/pexels-photo-358382.jpeg?auto=compress&cs=tinysrgb&h=650&w=940" style="height:100%; width:100%" /></p>
<p style='page-break-inside: avoid;'></p><p><img alt="" src="http://localhost:8032//UploadFile/BookImagesLibrary/1/thumb-1920-583852.jpg" style="height:100%; width:100%" /></p>
, пожалуйста, помогите мне разобраться с этой проблемой.изображение pdf сгенерированной книги pds сгенерированный файл