Hello,
Hi Ravindra,
Hi,
Hi Ravindra,
Hi,
Hi Ravindra,
Thanks for sharing more file. I have tried to convert your shared HTML into PDF by following code snippet, using Aspose.Pdf for .NET 17.5 and observed that in the output file, formatting of content was incorrect. For your reference, I have attached an output generated by below code.
FileStream htmlContentStream = new FileStream(dataDir + “index.html”, FileMode.Open);
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions(dataDir);
htmlLoadOptions.PageInfo.IsLandscape = true;
Document pdfDoc = new Document(htmlContentStream, htmlLoadOptions);
pdfDoc.Save(dataDir + "HTML2PDF_out.pdf");
I have logged an issue as PDFNET-42823 in our issue tracking system, for the sake of correction. We will further look into this and keep you updated with the status of its resolution. Please be patient and spare us little time.
ravindra.pathak:
Is this a pdf file, if yes, then how did you include the folder path inside the index.html file ?
It was not PDF file but a screenshot of how content was displayed when I opened your HTML into web browser.
Furthermore, in a case if your HTML contains images, you can use CustomLoaderOfExternalResources property to load/render those images inside PDF during conversion process. For more information you may visit “HTML to PDF - Resource Loading Callback” article in API documentation.
We are sorry for the inconvenience.
Best Regards,
Hi,
Hello,
Hi,
Hi Ravindra,
Hello,
PFA the sample project, it is a Webapi project, please use post man to call the url for e.g. “http://localhost:60877/api/pdfgenerator”
and use the POST method in postman, the pdf file is generated in the “Template” folder.
Please write back in case of any queries.
I have removed the package folder due to large size, the packages.config file is included for you to download from nuget.
Thanks.
Regards,
Ravindra R Pathak
Hi Ravindra,
Hi Ravindra,
How can I generate a pdf format file from the HTML file of the coding of the website [hp customer service](https://hpsupports.co/hp-customer-support/)
??? I want to have the script in pdf format.
Thanks for your inquiry.
You can please download source of a web page using WebRequest
Class and add source text inside PDF using TextFragment
. Please check following code snippet and attached PDF document for your reference:
var url = "https://hpsupports.co/hp-customer-support/";
System.Net.WebRequest request = System.Net.WebRequest.Create(url);
// If required by the server, set the credentials.
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Time out in miliseconds before the request times out
// Request.Timeout = 100;
// Get the response.
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
Document pdfDocument = new Document();
TextFragment textFragment = new TextFragment(responseFromServer);
pdfDocument.Pages.Add();
pdfDocument.Pages[1].Paragraphs.Add(textFragment);
// Save output as PDF format
pdfDocument.Save(dataDir + "WebpageToPdf.pdf");
WebpageToPdf.pdf (83.2 KB)
In case of any further assistance, please feel free to let us know.