Welcome Guest Search | Active Topics | Sign In | Register

ScaleToFit Not Working Options
Chris McHenry
Posted: Thursday, February 22, 2024 4:45:30 PM
Rank: Newbie
Groups: Member

Joined: 2/22/2024
Posts: 2
//Convert HTML to PDF file using EO.Pdf
if (pageOrientation == ImageOrientation.Landscape)
{
EO.Pdf.HtmlToPdf.Options.PageSize = new SizeF(11.0f, 8.5f);
EO.Pdf.HtmlToPdf.Options.OutputArea = new RectangleF(0.25f, 0.25f, 10.5f, 8.0f);
}
else
{
EO.Pdf.HtmlToPdf.Options.PageSize = new SizeF(8.5f, 11.0f);
EO.Pdf.HtmlToPdf.Options.OutputArea = new RectangleF(0.25f, 0.25f, 8.0f, 10.5f);
}

EO.Pdf.HtmlToPdf.Options.SSLVerificationMode = EO.Pdf.SSLVerificationMode.None;
EO.Pdf.HtmlToPdf.Options.AllowLocalAccess = true;
EO.Pdf.HtmlToPdf.Options.AutoFitX = EO.Pdf.HtmlToPdfAutoFitMode.ScaleToFit;
EO.Pdf.HtmlToPdf.Options.AutoFitY = EO.Pdf.HtmlToPdfAutoFitMode.ScaleToFit;
var result = EO.Pdf.HtmlToPdf.ConvertHtml(htmlContent, ms);


HTML Template (Note: Replacement variables are filled in at runtime):
<html>
<body style="margin:0;padding:0">
<table width="792" height="612" cellpadding="0" cellspacing="0">
<tr>
<td width="792" align="center" valign="top">
<img src="{ProductDocImages}/Chart-596-case_shiller_V25.jpg" alt="" width="792"/>
</td>
</tr>
<tr>
<td width="792" align="left" valign="bottom">
<div style="height:10px;font-size:6pt;{LargeDisclosure}">&nbsp;</div>
<div style="margin:0 18px 0 18px">
<table width="746" cellpadding="0" cellspacing="0">
<tr>
<td width="20">&nbsp;</td>
<td width="70" align="left" valign="top">
<img src="{MemberPrintPhoto}" border="0" alt="" style="{PhotoExists};width:70px"/>
</td>
<td width="20">&nbsp;</td>
<td width="255" align="left" valign="top">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 9pt; color: #333333; font-weight: bold;">{FullName}<br/>{Title} {Partner1} {Partner1Title}</span>
<div style="font-size:1px;line-height:1px;height:2px;"></div>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 9pt; color: #333333;">{Phone1} {Phone2} {Phone3} {Email1} {Website}</span>
</td>
<td width="20">&nbsp;</td>
<td width="234" align="left" valign="top">
<img src="{CompanyPrintLogo}" alt="" border="0" style="{CompanyLogoExists};{CompanyLogoLandscape}"/>
<div style="font-size:1px;line-height:1px;height:3px;"></div>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 9pt; color: #333333">{Address1}{Address2}<br/>{City} {State} {PostalCode}</span>
</td>
<td width="20">&nbsp;</td>
<td width="107" align="right" valign="bottom">
{CompanyMark}
</td>
</tr>
</table>
<div style="height:9px;font-size:5pt;{ExLargeDisclosure}">&nbsp;</div>
<div style="font-size: {DisclosureFontSize}; font-family: Arial, Helvetica, sans-serif; margin-top: 2px; text-align: justify">
The material provided is for informational and educational purposes only and should not be construed as investment and/or mortgage advice, or a commitment to lend.
Although the material is deemed to be accurate and reliable, there is no guarantee of its accuracy. The material does not represent the opinion of {CompanyName}.
&#169; {Year} Media Center, LLC. All rights reserved. {CompanyDisclosure} {BranchDisclosure} {Disclosure}
</div>
</div>
</td>
</tr>
</table>
</body>
</html>
Code: C#


eo_support
Posted: Friday, February 23, 2024 12:57:54 PM
Rank: Administration
Groups: Administration

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

We tested your code here and it seems to work fine. Please keep in mind that ScaleToFit on both X and Y direction does NOT mean they will scale independently. For example, if you try to render a square on a long rectangle page, then the square will be scaled to fit horizontally to fit the entire width, but it won't fit the entire height because the page has more space vertically than horizontally. It can not fit the entire height because if it does, then the square will no longer be a square and that means the output has been distored.

If you still have problems, please provide more information on how and why you think it's not working and we will be happy to assist you further.

Thanks!
Chris McHenry
Posted: Tuesday, February 27, 2024 3:48:14 PM
Rank: Newbie
Groups: Member

Joined: 2/22/2024
Posts: 2
Hi, thank you for your response. What you're describing is exactly what I want to happen. In my case I want the html to scale to the width and maintain the aspect ratio (thus, there will be additional space on the Y axis). Here's an example of the output:
ScreenShot
PDF
eo_support
Posted: Tuesday, February 27, 2024 9:27:31 PM
Rank: Administration
Groups: Administration

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

Most likely your HTML has something that takes up space but is not visible. You can send a full working test project to us and we will be happy to investigate further. See here for more details:

https://www.essentialobjects.com/forum/test_project.aspx

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.