Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Jan 05, 2015 3:34 pm

I am generating a pdf from an html page using the sample code and setting the PdfPage Settings like so

Code: Select all
Spire.Pdf.PdfDocument pp = new Spire.Pdf.PdfDocument();
        Spire.Pdf.PdfPageSettings pst = new Spire.Pdf.PdfPageSettings();
        pst.Size = Spire.Pdf.PdfPageSize.Letter;
        pst.Orientation = Spire.Pdf.PdfPageOrientation.Portrait;


If I want the resulting pdf to fit into a single Letter Page what should the width and height of my html be constrained to?

danm
 
Posts: 6
Joined: Mon Jan 05, 2015 3:01 pm

Tue Jan 06, 2015 2:48 am

Dear danm,

Thanks for your inquiry.

For your requirement, please refer to the code below:
Code: Select all
[STAThread]
static void Main(string[] args)
{
   PdfDocument pdf = new PdfDocument();

   PdfPageSettings setting = new PdfPageSettings();
   setting.Size = PdfPageSize.Letter;
   setting.Orientation = PdfPageOrientation.Portrait;

   PdfHtmlLayoutFormat format = new PdfHtmlLayoutFormat();
   format.FitToPage = Clip.Both;
   format.Layout = PdfLayoutType.OnePage;

   pdf.LoadFromHTML("Your website url", false, true, false, setting, format);
   pdf.SaveToFile("Result.pdf");

}
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Tue Jan 06, 2015 8:52 pm

Thank I am using these settings and everything works fine except for the positioning of a footer. The footer is in a container div styled like this
Code: Select all
#container {
            width: 612pt;
            height: 792pt;
            min-height: 792pt;
        }


and the footer is styled like this to always appear on the very bottom of the page
Code: Select all
  footer#footer {
        width: 100%;
        position: absolute;
        bottom: 0;
    }


It renders perfectly in a browser (even in the .net WebBrowser control which I believe is what you use to render) with the footer on the bottom of the page but when the pdf is created there is whitespace beneath the footer. Is there some option I am missing?

danm
 
Posts: 6
Joined: Mon Jan 05, 2015 3:01 pm

Wed Jan 07, 2015 1:51 am

Dear danm,

Spire.PDF use IE to render the html and convert it to pdf.

To help us reproduce this problem, can you provide us this website url to have a test?

Thank you.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Thu Jan 08, 2015 10:30 pm

This happens with the free version of Spire Pdf when converting the google home page to a pdf. The footer at the bottom that is absolutely positioned to the bottom is rendered in the resulting pdf with white space beneath it.
Using the Spire Pdf Pack Hot Fix 3.2.31, however, there is no additional whitespace.

danm
 
Posts: 6
Joined: Mon Jan 05, 2015 3:01 pm

Fri Jan 09, 2015 1:42 am

Dear damn,

After testing with free version and commercial version, I can see this additional whitespace appears in free version, not in commercial version. Therefore I recommend you to use commercial version as it is more powerful and more stable than free version.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Mon Jan 12, 2015 8:07 am

Hello damn,

Have you tried Spire.PDF v3.2.31 to resolve this problem? Did it work?

Looking forward to your response.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.Doc