Free Support Forum - aspose.com

Page Number and font size issue

I am working on converting a html file to pdf file with Aspose.html. i want page number at the end of page(in footer section) while converting html file to pdf file.
I want while converting html to pdf the size of font decreases.

How can I do this in Aspose. You can see my solution as attachment.

sample.zip (930 Bytes)

Thank you!

@supportntest

Regretfully, required feature is not available in Aspose.HTML for .NET at the moment while saving HTML to PDF. You can however do it with Aspose.PDF for .NET once PDF is generated.

For implementation of your requirements in Aspose.HTML, we have logged a feature request as HTMLNET-2799 in our issue management system. We will further investigate its feasibility and keep you informed about the status of its availability. Please be patient and spare us some time.

We apologize for the inconvenience.

@supportntest

We have further investigated the earlier logged ticket and found that you can add page numbers to the output PDF file using the following code snippet:

using (var configuration = new Aspose.Html.Configuration())
{
    var userAgent = configuration.GetService<Aspose.Html.Services.IUserAgentService>();
    userAgent.UserStyleSheet = @"@page 
                    {
                        /* Page counter located at the bottom of the page */
                        @bottom-right
                        {
                            -aspose-content: currentPageNumber();
                        }
                    }";

    var options = new Aspose.Html.Rendering.Pdf.PdfRenderingOptions();
    options.PageSetup.AnyPage.Margin = new Aspose.Html.Drawing.Margin(25);

    using (var document = new Aspose.Html.HTMLDocument("sample.html", configuration))
    using (var device = new Aspose.Html.Rendering.Pdf.PdfDevice(options, "out.pdf"))
    {
        document.RenderTo(device);
    }
}

An example, which demonstrates, how to add header and the total number of pages, can be found here https://docs.aspose.com/html/net/css-extensions/.

There are a couple of ways to change the font size, so in order to propose the most suitable method, we will need more information about the use case.

  • Do you want to change the font size of all elements or only of the particular ones?
  • Changing the font size may lead to a broken layout, so maybe you want to rescale document size instead?

I want to change font size of full document when converting html to pdf. Example: When I am converting html to pdf my html document font size is 25px I want in pdf that size is 10. and same with html to word.

@supportntest

Thanks for your feedback.

We have updated the ticket information accordingly and will get back to you as soon as we have some more updates regarding its resolution.