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 May 01, 2013 4:43 pm

Greetings, my company is actively evaluating the purchase of Spire.Office for .NET Site Enterprise Subscription.

We are looking at the capabilities for generating a PDF from HTML, and have come up with a few questions.

1) We are currently using the PdfDocument LoadFromHTML method. When I use the following code, the PDF generated from www.google.com contains scroll bars. Does the process of converting to HTML depend on loading a web browser / rendering engine?

2) Do you have documentation or suggestions for formatting the HTML / CSS to avoid scroll bars? Is there a suggested width?

3) Is there a way to have the document rendered in Landscape (currently it is in portrait)?

4) Are there HTML tags / attributes which will help control where page breaks occur in the rendered PDF?

5) Is there a mechanism to load HTML directly into a PDF without using a URL?

6) Is there any way to pass HTTP authentication information (headers / cookies) when loading HTML from a URL?

Thanks in advance.

private void button2_Click(object sender, EventArgs e) {
PdfDocument pdf = new PdfDocument();
string url = "http://www.google.com";
pdf.LoadFromHTML(url, true, true, true);
pdf.SaveToFile(@"C:\SpireTest.pdf");
pdf.Close();
DocViewer(@"C:\SpireTest.pdf");
}

private void DocViewer(string fileName) {
try {
System.Diagnostics.Process.Start(fileName);
} catch { }
}

mbyrne
 
Posts: 4
Joined: Mon Apr 29, 2013 2:29 pm

Thu May 02, 2013 8:44 am

Hello Michael,

Thanks for your inquiry.

1) We are currently using the PdfDocument LoadFromHTML method. When I use the following code, the PDF generated from www.google.com contains scroll bars. Does the process of converting to HTML depend on loading a web browser / rendering engine?

Yes, it does.

2) Do you have documentation or suggestions for formatting the HTML / CSS to avoid scroll bars? Is there a suggested width?

If the HTML has set body's overflow style as scroll, it will appear the scroll bar after converting to the PDF. Please refer to the link http://www.w3schools.com/cssref/pr_pos_overflow.asp to avoid scroll bar.

3) Is there a way to have the document rendered in Landscape (currently it is in portrait)?

There is a way to have the document rendered in Landscape as below, please refer to it.
Code: Select all
PdfDocument pdf = new PdfDocument();
PdfSection pdfsec = pdf.Sections.Add();
pdfsec.PageSettings.Orientation = PdfPageOrientation.Landscape;
string url = "http://www.google.com";
pdfsec.LoadFromHTML(url, true, true,new PdfHtmlLayoutFormat
            {
                FitToPage=Clip.Both
            }
            );

Regarding the issue4, 5 and 6, now our product doesn't support these functions, and it has been transferred to our Dev team, they are discussing if they will develop these new features. Sorry for inconvenience.

If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu May 02, 2013 2:12 pm

Gary,

Thanks for your reply. In regards to loading a web browser / rendering engine, can you tell me which one is used, so that we know how to best structure our HTML and CSS?

Thanks

mbyrne
 
Posts: 4
Joined: Mon Apr 29, 2013 2:29 pm

Fri May 03, 2013 1:52 am

Michael,

Thanks for your reply.
Web browser is used, IE8 is best.

If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue May 07, 2013 9:02 am

Dear Michael,

Have your issues(1,2,3) been solved?
If you encounter any issue during use our Spire.Office, please feel free to contact us.

Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue May 07, 2013 12:59 pm

Right now, we are looking for a solution that supports page-break-inside and page-break-before CSS attributes, or something equivalent. Thanks for your help.

mbyrne
 
Posts: 4
Joined: Mon Apr 29, 2013 2:29 pm

Wed May 08, 2013 3:04 am

Dear Michael,

Thanks for your reply.

Sorry for that our Spire.Pdf component doesn't support page-break-inside and page-break-before CSS attributes at present,
but it as a new feature has added into our schedule. As soon as there is any update, we will tell you.

Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Mar 06, 2015 9:10 pm

amy.zhao wrote:Dear Michael,

Thanks for your reply.

Sorry for that our Spire.Pdf component doesn't support page-break-inside and page-break-before CSS attributes at present,
but it as a new feature has added into our schedule. As soon as there is any update, we will tell you.

Regards,
Amy
E-iceblue support team


Has this been added into the product yet?

patness
 
Posts: 10
Joined: Tue Jul 08, 2014 12:15 am

Mon Mar 09, 2015 8:43 am

Hello,

The solution supports the feature, you can try it.
http://www.e-iceblue.com/Tutorials/Spir ... lugin.html

Best wishes,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF