Welcome Guest Search | Active Topics | Sign In | Register

HtmlToPdf PdfPageSizes.A4.Height BackGroundColor Options
Pingouf
Posted: Tuesday, March 14, 2017 5:37:20 AM
Rank: Newbie
Groups: Member

Joined: 12/9/2016
Posts: 2
Hello,

I'm trying to fill an A4 page with a red background. There is always a white line at the bottom of the page in portrait.

I do something wrong?

Example :

Quote:
PdfDocument doc = new PdfDocument();

HtmlToPdfOptions options = new HtmlToPdfOptions();
options.PageSize = new SizeF(PdfPageSizes.A4.Width, PdfPageSizes.A4.Height);
options.AutoAdjustForDPI = true;
options.OutputArea = new RectangleF(0f, 0f, sizeF.Width, sizeF.Height);
options.GeneratePageImages = true;

string contenuHtml = "<html><body><div style=\"background-color:red;width:794px;height:1123px;\">Contenu</div></body></html>";

var result = HtmlToPdf.ConvertHtml(contenuHtml, doc, options);
for (int i = 0; i < result.PageImages.Length; i++)
{
var pageImage = result.PageImages[i];
var clonedImage = (Bitmap)pageImage.Clone();
clonedImage.SetResolution(clonedImage.HorizontalResolution * 1, clonedImage.VerticalResolution * 1);
}

Thanks for help.

Didier.
eo_support
Posted: Tuesday, March 14, 2017 9:13:35 AM
Rank: Administration
Groups: Administration

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

Have you tried to set OutputArea slightly bigger than PageSize? Because the numbers are in float, so there can be rounding errors.

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.