Welcome Guest Search | Active Topics | Sign In | Register

Update to latest EO.PDF, font smaller, margin position changed Options
K. Zimny
Posted: Friday, June 23, 2017 9:43:14 AM
Rank: Member
Groups: Member

Joined: 8/4/2014
Posts: 11
I've updated EO.PDF library from version 2015 (2015.2.41.0) to 2017 (17.1.76.0).
Problem 1: when I convert HTML to PDF the same text is rendered smaller, whether the parameter ZoomLevel = 1.0f; is applied or not.
Problem 2: the left and top margins become smaller

My code looks as follows:

Code: C#
private MemoryStream CreateDocument(string text)
        {
            PdfDocument doc = new PdfDocument();
            //
            HtmlToPdfOptions options = new HtmlToPdfOptions();
            options.PageSize = EO.Pdf.PdfPageSizes.A4;
            options.ZoomLevel = 1.0f;
            options.AutoAdjustForDPI = false;
            options.OutputArea = new System.Drawing.RectangleF(0.5f, 0.5f, 7f, 10.5f);

            HtmlToPdf.ConvertHtml(text, doc, options);

            using (MemoryStream memory = new MemoryStream())
            {
                doc.Save(memory);
                return memory;
            }
        }


Is there any setting that may affect this behavior? I have no idea what needs to be changed.
eo_support
Posted: Friday, June 23, 2017 1:17:10 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

The smaller margin is because the new version does not consider body.margins. The new version made this change because the page already have margin, so in order to avoid double margins, it will always ignore margins set on your HTML body element.

The smaller text is caused by zoom level. The converter will automatically zoom out if your contents is wider than the paper. So if your HTML is indeed wider than the paper, you will either zoom out or have your contents cut off. To avoid contents being cut off, you must modify your HTML so that it can render correctly (without a horizontal scroll bar) when you load it in a browser window with a small width value.

To avoid auto zoom, you must set both ZoomLevel and AutoFitX/AutoFitY. Setting ZoomLevel alone will not force the zoom level, it only sets the maximum zoom level. You can find more information here about output zooming:

https://www.essentialobjects.com/doc/pdf/htmltopdf/auto_fit.aspx

Hope this helps. Let us know if you still have any questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.