Hi Vennila,
Hi Vennila,
The issues you have found earlier (filed as PDFNEWNET-38122;PDFNEWNET-38088) have been fixed in Aspose.Pdf for .NET 11.1.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
HI Nayyer,
Thanks for providing the fixes .I have used the latest Aspose.Pdf for .NET 11.1.0 and I was able to reproduce PDFNEWNET-38122. I am attaching the sample text and html that we are trying to export . Can you please provide a way to handle it.
I am attaching the plan text in the .txt file and html in .rtf file
Thanks,
Hi Vennila,
Aspose.Pdf.Document
doc = new Document(“c:/pdftest/HTML+code+of+memos+with+missing+content+when+exported+to+PDF.html”,
new HtmlLoadOptions());<o:p></o:p>
doc.Save(@“c:/pdftest/HTML+code+of+memos+with+missing+content+when+exported+to+PDF.pdf”);
Hey,
I am attaching the sample project in which I have used the latest aspose DLL. Can you please review and update the possible fix.
Thanks
Hi Vennila,
Hi Vennila,
Hi Vennila,
Document doc = new
Document(“712086±+PDF+not+showing+digits.html”,
new HtmlLoadOptions());<o:p></o:p>
doc.Save("HTMLtoPDf.PDF");
Please feel free to contact us for any further assistance.
Best Regards,
Hi Vennila,
Hi Vennila,
Aspose.Pdf.Generator.Pdf pdfDocument = new Aspose.Pdf.Generator.Pdf();
pdfDocument.HtmlInfo.BadHtmlHandlingStrategy = Aspose.Pdf.Generator.BadHtmlHandlingStrategy.TreatAsPlainText;
pdfDocument.HtmlInfo.ShowUnknownHtmlTagsAsText = true;
pdfDocument.HtmlInfo.CharSet = "UTF-8";
pdfDocument.IsLandscape = true;
pdfDocument.IsPageNumberForDocument = true;
pdfDocument.IsFontNotFoundExceptionThrown = false;
pdfDocument.IsImageNotFoundErrorIgnored = true;
pdfDocument.IsAutoFontAdjusted = true;
pdfDocument.PageNumberFormat = Aspose.Pdf.Generator.PageNumberFormatType.EnglishLower;
pdfDocument.PageSetup.Margin = new Aspose.Pdf.Generator.MarginInfo() { Left = 30, Top = 30, Right = 10, Bottom = 10 };
pdfDocument.Author = "ServicePRO";
pdfDocument.Subject = "Request Details";
pdfDocument.Title = string.Format("{0} - {1}", returnValue.Id, returnValue.Name);
try
{
pdfDocument.BindHTML(requestHtml.ToString(), embeddedImageLocation); // this is the location for images
using (MemoryStream pdfStream = new MemoryStream())
{
pdfDocument.Save(pdfStream);
pdfStream.Flush();
returnValue.Data = pdfStream.ToArray();
if (pdfDocument.PageCount > 0)
returnValue.Tag = pdfDocument.PageCount;
}
}
we have the latest Aspose.PDF.dll and we are trying to export the below attached html page with image src to PDF. It does not work with the code you have provided.
// instantiate Pdf object
Aspose.Pdf.Generator.Pdf pdf = new Pdf();
// specify the Character encoding for for HTML file
pdf.HtmlInfo.CharSet = "UTF-8";
pdf.HtmlInfo.CharsetApplyingLevelOfForce = HtmlInfo.CharsetApplyingForceLevel.UseWhenImpossibleDetectFromContent;
// load the HTML file to Stream object
using (Stream htmlAsStream = System.IO.File.OpenRead(@"C:\\Users\\bram\\Desktop\\Waste\\HTML.html"))
{
// bind the source HTML
pdf.BindHTML(htmlAsStream, "D:"\\Config\\HSTemp");
}
pdf.Save(@"C:\\Waste\\HTMLhtml.pdf");
I have attached the html and image with the output.
we need to use above code like BindHTML() to provide the basepath of image. Please provide with a way to convert any html pages with images to PDF using BindHTML().
Thanks
Hi Vennila,
HtmlLoadOptions options = new HtmlLoadOptions(“E:/data/”);<o:p></o:p>
Document doc = new Document("E:/data/HTML_image.html", options);
doc.Save("E:/data/HtmltoPDFDOM.pdf");
Please feel free to contact us for any further assistance.
Best Regards,
I was using Aspose.Pdf.Generator.Pdf to convert HTML to PDF, as you have mentioned this is no longer supported.
HtmlLoadOptions options = new HtmlLoadOptions("E:/data/");Document doc = new Document("E:/data/HTML_image.html", options);doc.Save("E:/data/HtmltoPDFDOM.pdf");
pdfDocument.HtmlInfo.CharSet = "UTF-8";
Hi Vennila,
When using new DOM, CharacterSet, Font and related properties are automatically handled. However concerning to other requirements, please visit
byte[] byteArray = Encoding.UTF8.GetBytes(requestHtml.ToString));
MemoryStream stream = new MemoryStream(byteArray);
Document doc = new Document(stream, options);
doc.Info.Title = string.Format("{0} - {1}", returnValue.Id, returnValue.Name);
doc.Info.Subject = "Request Details";
doc.Info.Author = "SP";
doc.PageInfo.Margin = new MarginInfo { Left = 30, Top = 30, Right = 10, Bottom = 10 };
PageNumberStamp pageNumberStamp = new PageNumberStamp();
pageNumberStamp.Format = "Page # of " + doc.Pages.Count;
pageNumberStamp.StartingNumber = 1;
doc.Pages[doc.Pages.Count].AddStamp(pageNumberStamp);
try
{
using (MemoryStream pdfStream = new MemoryStream())
{
doc.Save(pdfStream);
pdfStream.Flush();
returnValue.Data = pdfStream.ToArray();
}
}
Thanks
Hi Vennila,
HtmlLoadOptions options = new HtmlLoadOptions();<o:p></o:p>
options.PageInfo.Margin = new Aspose.Pdf.MarginInfo { Left = 40, Right = 40, Top = 30, Bottom = 20 };
options.PageInfo.Width = Aspose.Pdf.PageSize.A4.Width;
options.PageInfo.Height = Aspose.Pdf.PageSize.A4.Height;
// Instantiate Document object
Document doc = new Document("test.html", options);
MemoryStream ms = new MemoryStream();
doc.Save(ms);
doc = new Document(ms);
Aspose.Pdf.HeaderFooter header = new Aspose.Pdf.HeaderFooter();
Aspose.Pdf.HeaderFooter footer = new Aspose.Pdf.HeaderFooter();
FileStream fs = new FileStream(myDir + "logo.png", FileMode.Open, FileAccess.Read);
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();
image1.FixWidth = 50;
image1.FixHeight = 50;
//Add the image into paragraphs collection of the section
header.Paragraphs.Add(image1);
//Set the ImageStream to a MemoryStream object
image1.ImageStream = fs;
//Add footer text
Aspose.Pdf.Text.TextFragment fTxt = new Aspose.Pdf.Text.TextFragment("$p / $P ");
fTxt.TextState.Font = FontRepository.FindFont("Arial");
fTxt.TextState.FontSize = 16;
fTxt.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;
footer.Paragraphs.Add(fTxt);
foreach (Aspose.Pdf.Page page in doc.Pages)
{
page.Header = header;
page.Footer = footer;
}
// Save PDF file
doc.Save("htmltopdf.pdf");
Please feel free to contact us for any further assistance.
Best Regards,