我正在使用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 generated file