Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Aug 05, 2020 1:22 pm

Hi,
I am trying to convert pdf file from HTML, but the scroll bar is displaying in the pdf file and the actual content is missing. In Html, there is a scrollbar for the inside body section.

Thanks and Regards
Santosh

santoshballa
 
Posts: 6
Joined: Wed Aug 05, 2020 12:59 pm

Thu Aug 06, 2020 10:30 am

Hello,

Thanks for your inquiry.
To help us investigate your issue more accurately and quickly, please provide your input file, your output file, and the screenshot of your HTML file displayed in the browser. Your can upload them here or send them to us via email. Thanks in advance.

Sincerely
Elena
E-iceblue support team
Last edited by Elena.Zhang on Fri Aug 07, 2020 3:45 am, edited 1 time in total.
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Thu Aug 06, 2020 12:43 pm

HtmlConverter.Convert(url, filepath,
//enable javascripts
true,
//load timeout
100 * 1000,
//page size
new SizeF(1000, 1000),
//page margins
new Spire.Pdf.Graphics.PdfMargins(0, 0, 0, 0));


This is the code we are using and tried with other methods also HtmlConverter.Convert(url, stream,true,size,pdfmargins);
but styles are missing(css are adding to pdf).Please find following attachments and provide some solution.Please Find the url in text file attached.

Thanks

santoshballa
 
Posts: 6
Joined: Wed Aug 05, 2020 12:59 pm

Fri Aug 07, 2020 10:06 am

Hi,

Thanks for your feedback.
I used the latest x64 plugin to convert the html to PDF, and found that the result is better than your output file. Attached is my output file for your reference. I suggest you download the latest plugin and try again.
But unfortunately, the layout of the generated PDF page is not exactly the same as that rendered in the browser. Our plugin conversion method is actually based on the Qt plugin of the Chrome kernel, and I tried to use Chrome to directly convert the webpage to PDF, but the result is similar to that generated by our product, as shown below. Sorry, for this layout issue, I am afraid that there is no good way to improve it. Hope you can understand.
Save_as_PDF_in_Chrome.png

Sincerely
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Wed Aug 12, 2020 6:34 am

Ok, No Problem.Thanks for providing clarification.

Can you please guide me at how to handle possible Exception while converting URL to stream.Like if URL is not given correct, connection failed,i.e.,

HtmlConverter.Convert(url, stream,
//enable javascripts
true,
//load timeout
100 * 1000,
//page size
new SizeF(612, 792),
//page margins
new Spire.Pdf.Graphics.PdfMargins(0, 90, 0, 40));

santoshballa
 
Posts: 6
Joined: Wed Aug 05, 2020 12:59 pm

Wed Aug 12, 2020 10:05 am

Hello,

Thank you for your reply.
Before using our Spire.PDF for conversion, you can use the following code to determine whether the URL is correct or whether the connection is successful. Please feel free to contact us if you have further questions.

Code: Select all
 public static bool CheckPageUrl(string url)
        {
            bool result = false;
            try
            {
                if (url.IndexOf("http").Equals(-1))
                {
                    url = "http://" + url;
 
                }
                HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
                myHttpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko";
                myHttpWebRequest.Method = "GET";
                HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
                if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
                {
                    result = true;
                }
                myHttpWebResponse.Close();
            }
            catch
            {
                result = false;
            }

            return result;
        }


Sincerely
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Wed Aug 12, 2020 2:11 pm

Thank you for providing me the code, but if exceptions other than connection or validating URL, means while conversion? How to Handle those?
Sometime it throws System.IO.FileNotFoundException:
Example : url = "https://www.test.com/"

The code which you've provided is working fine. Thank you.

santoshballa
 
Posts: 6
Joined: Wed Aug 05, 2020 12:59 pm

Thu Aug 13, 2020 9:54 am

Hi,

Thanks for your feedback.
I noticed that the URL you provided is not accessible. And I tested the following code but the application did not throw the “System.IO.FileNotFoundException”. Did you perform any additional operations? If so, please provide your complete code for our further investigation. Besides, please tell us your OS information (E.g. Windows 7, 64 bit) and region setting (E.g. China, Chinese). Thanks in advance.
Code: Select all
MemoryStream ms=new MemoryStream();
HtmlConverter.Convert(url, ms,
//enable javascripts
true,
//load timeout
100 * 1000,
//page size
new SizeF(612, 792),
//page margins
new Spire.Pdf.Graphics.PdfMargins(0,0));


Sincerely
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Fri Aug 21, 2020 10:06 am

Hello,

Greetings from E-iceblue.
Does our product meet your needs? Could you please give us some feedback at your convenience?

Sincerely,
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Return to Spire.PDF