We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML -> PDF OpenSans/Europa

Hey, I’m trying to render a pdf document from html w/ some OpenSans & Europa fonts. At first I tried setting the font-family of the text to OpenSans or Europa and that didn’t work.

I then tried replacing the text w/ a regular expression but like this

    var europaTxtFragAbsorber = new TextFragmentAbsorber($"(_{fontName}_).+(_/{fontName}_)");
    TextSearchOptions textSearchOptions = new TextSearchOptions(true);
    europaTxtFragAbsorber.TextSearchOptions = textSearchOptions;
    doc.Pages.Accept(europaTxtFragAbsorber);
    var textFragmentCollection = europaTxtFragAbsorber.TextFragments;

    var startIdx = fontName.Length + 2;
    var lenOfBrackets = startIdx * 2 + 1;
    // Loop through the fragments
    foreach (TextFragment textFragment in textFragmentCollection)
    {
        // Update text and other properties
        textFragment.Text = textFragment.Text.Substring(startIdx, textFragment.Text.Length - lenOfBrackets);
        textFragment.TextState.Font = newFont;
    }

but the performance was abysmal. Are there any other solutions to setting the font to OpenSans or Europa?

@joelmeyer

Thanks for contacting support.

Would you please share your sample HTML file(s) with us. We will test the scenario in our environment and address it accordingly.

.DisplayBlock { display: block; }
	.InlineB {
		display: inline-block;
	}

	.EncasingTableContainer {
		padding: 1em 0;
		` font-family: Europa, sans-serif;
		font-size: 14pt;
	}

	.EncasingTable {
		height: auto;
		color: #1a2b57;
		border-collapse: collapse;
	}

	.ContactIcons {
		height: 1.25em;
		width: 1.25em;
		margin: 0 auto;
	}

	.AvailabilityTableContainer {
		display: inline-block;
		width: auto;
	}

	.AvailabilityTable {
		margin-right: 0;
		margin-left: auto;
		border-collapse: collapse;
	}

	.NowPowContainer img {
		height: 2em;
		margin-bottom: 1em;
	}

	.CareCoordinatorContainer {
		font-family: Europa;
	}

	.CareCoordinatorHeader {
		margin-bottom: 1em;
	}

		.CareCoordinatorHeader div:first-child {
			font-style: italic;
			margin-bottom: 0.25em;
		}

		.CareCoordinatorHeader div:nth-child(2) {
			font-weight: bold;
		}

	.ContactInfoTable {
		width: inherit;
	}

	.TagLineContainer {
		font-weight: bold;
		margin-bottom: 1em;
	}

	.ContactContainer, .CareCoordinatorContainer, .NowPowContainer {
		width: 33%;
		padding: 0 0.5em;
		vertical-align: top;
	}

	.CareCoordinatorContainer {
		text-align: right;
		border-right: 2px dashed #e0e0de;
	}

	.ContactInfoTable td {
		font-family: Europa;
		text-align: right;
		vertical-align: top;
	}

	.DataCell {
		padding-right: 0.5em;
	}

	.AvailabilityTable td {
		padding-left: 0.5em;
	}

	.NowPowDescription, .TagLineContainer, .DayCell div {
		direction: rtl;
		unicode-bidi: bidi-override;
	}

	.DayCell, .NowPowContainer {
		font-family: 'Times New Roman', Times, Serif;
	}

	.NowPowContainer {
		text-align: right;
	}
</style>
(555) 555-5557
joel.meyer@healthcorner.org
1276 N Clybourn Ave
Chicago, IL 60610
1 AM - 10 PM
الجمعة - الإثنين
Dev Multitenant Enterprise
Joel Meyer
this is my arabic text العديد من الجامعات مستعدة لدفع الأموال لدفع الناس لتناول الأفوكادو وذلك من أجل دراسة تدعى "النظام الغذائي المعتاد وتجربة الأفوكادو"
						</div>
					</td>
					<td class='NowPowContainer'>
						<div><img src='https://workablehr.s3.amazonaws.com/uploads/account/logo/226796/large_nowpow_tall.JPG'></div><div>
							<div class='TagLineContainer'>ربط الرعاية الصحية بالرعاية الذاتية</div><div class='NowPowDescription'>
								هى خدمة توفر لك قائمة من الأماكن و البرامج <div style=' display: inline-block; font-family: Europa;'>woPwoN</div>
								المجاورة لك والمطابقة لإحتياجاتك الصحية التي يتم تسجيلها من زيارتك لنا اليوم. ومن خلال هذه الخدمات، تستطيع الاستمتاع بحياه مستقلة مع الحفاظ على صحتك ومعالجة أي أمراض قد تعاني منها
							</div>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
	</div><div id='services-container'>
		<div>
			<table style='width: 100%'>
				<tr>

					<td style='width: 20%'>
						<hr style='height: 10px;
                    color: #23A888;
                    background-color: #23A888;' />
					</td>
					<td style='text-align:center;'>
						<table style='width: 100%; text-align:center;'>
							<tr>
								<td>
									<h2 style='display: inline-table; color: #23A888; direction: rtl; unicode-bidi: bidi-override;'>طب الأسنان والعيون</h2>
								</td>
								<td style='width: 60px;'>
									<div style='
                            height: 45px;
                            width: 47px;
                            background: url(http://localhost:34566/PLUGINS/Content/Static/erx-section-hexiconbg-highres-teal.png);
                            background-repeat: no-repeat;
                            background-size: 47px 45px;
                            text-align:center;'>

										<img src='http://localhost:34566/PLUGINS/Content/Categories/dental-and-vision_white-01.png' style='
                                height: 30px;
                                width: 30px;
                                display: inline-block;
                                padding-top: 5px;' />
									</div>
								</td>
							</tr>
						</table>
					</td>

					<td style='width: 20%'>
						<hr style='height: 10px;
                    color: #23A888;
                    background-color: #23A888;' />
					</td>
				</tr>
			</table>
		</div>
		<div style='page-break-inside: avoid'>
			<div>
				<h2 style='color: #23A888; direction: rtl; unicode-bidi: bidi-override;'>رعاية أطباء الأسنان - عام</h2>
			</div>
			<div>
				<table style='margin-bottom: 15px; width: 100%; text-align: end; font-family: Europa'>

					<tr style='padding-bottom: 30px;'>
						<td style='padding-top: 10px; text-align: right;'>
							<span style='color: blue;'>Sonrisa Family Dental</span><span> mi 2.85 : ةفاسملا</span>
						</td>
						<td style='width: 30px; align-content: end; text-align: right; vertical-align: top; padding-top: 10px;' rowspan=4>
							<img style='width: 20px' src='http://localhost:34566/PLUGINS/Content\Static\Labels\erx-service-label-teal_A.png'>
						</td>
					</tr>
					<tr style='padding-bottom: 30px;'>
						<td style='text-align: end; padding-top: 10px;'>
							2001  S California Ave  Chicago, IL 60608 | English, الإسبانية :<span>ةغللا</span> | رسوم متغيرة, الدفع الذاتي, التأمين :<span>موسرلا</span>
						</td>
					</tr>
					<tr style='padding-bottom: 30px;'>
						<td style='text-align: end; padding-top: 10px;'>
							<span>نينثإلا - ةعمجلا 9:00 AM - 5:00 PM, تبسلا 8:00 AM - 2:00 PM :)ديكأتلل لصتا( تاعاسلا</span>
						</td>
					</tr>
					<tr style='padding-bottom: 30px;'>
						<td style='text-align: end; padding-top: 10px;'>
							<span style='color: blue'><img style='width: 20px' src='http://localhost:34566/PLUGINS/Content/Static/erx-icon-phone-blue-highres.png'>(773) 484-1201<img style='width: 20px' src='http://localhost:34566/PLUGINS/Content/Static/erx-icon-email-blue-highres.png'>marisol.lopez@sonrisafamilydental.com<img style='width: 20px' src='http://localhost:34566/PLUGINS/Content/Static/erx-icon-link-blue-highres.png'>http://www.sonrisafamilydental.com</span>
						</td>
					</tr>
					<tr style='padding-bottom: 30px;'>
						<td style='padding-top: 10px; text-align: right;'>
							<span style='color: blue;'>Esperanza Health Centers</span><span> mi 2.85 : ةفاسملا</span>
						</td>
						<td style='width: 30px; align-content: end; text-align: right; vertical-align: top; padding-top: 10px;' rowspan=4>
							<img style='width: 20px' src='http://localhost:34566/PLUGINS/Content\Static\Labels\erx-service-label-teal_B.png'>
						</td>
					</tr>
					<tr style='padding-bottom: 30px;'>
						<td style='text-align: end; padding-top: 10px;'>
							2001  S California Ave  Chicago, IL 60608 | English, الإسبانية :<span>ةغللا</span>
						</td>
					</tr>
					<tr style='padding-bottom: 30px;'>
						<td style='text-align: end; padding-top: 10px;'>
							<span>نينثإلا - ءاعبرألا 8:00 AM - 6:00 PM, سيمخلا 12:00 PM - 8:00 PM, ةعمجلا 8:00 AM - 6:00 PM, تبسلا 8:00 AM - 3:00 PM :)ديكأتلل لصتا( تاعاسلا</span>
						</td>
					</tr>
					<tr style='padding-bottom: 30px;'>
						<td style='text-align: end; padding-top: 10px;'>
							<span style='color: blue'><img style='width: 20px' src='http://localhost:34566/PLUGINS/Content/Static/erx-icon-phone-blue-highres.png'>(773) 484-1201</span>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div id='importantNumWebsites'>
			<div>

				<table style='width: 100%; text-align:center;'>
					<tr>

						<td style='width: 20%'>
							<hr style='height: 10px;
                        color: #000000;
                        background-color: #000000' />
						</td>

						<td>
							<table style='width: 100%; text-align:center;'>
								<tr>
									<td>
										<h2 style='display: inline-table;'>أرقام ومواقع إلكترونية مهمة</h2>
									</td>
									<td style='width: 60px;'>
										<div style='
                                height: 45px;
                                width: 47px;
                                background: url(http://localhost:34566/PLUGINS/Content/Static/erx-footer-contact-highres.png);
                                background-repeat: no-repeat;
                                background-size: 47px 45px;
                                text-align:center;'>
										</div>
									</td>
								</tr>
							</table>
						</td>

						<td style='width: 20%'>
							<hr style='height: 10px;
                        color: #000000;
                        background-color: #000000' />
						</td>
					</tr>
				</table>
			</div>
			<div>
				<table style='width: 100%; text-align:center; font-family: Europa;'>
					<tr>
						<td>
							<div style='font-weight: bold'>Enterprise Website</div>
							<div>www.enterprisesite.com</div>
						</td>
						<td>
							<div style='font-weight: bold'>Enterprise Phone</div>
							<div>555-123-4567</div>
						</td>
						<td>
							<div style='font-weight: bold'>Enterprise Mobile Phone</div>
							<div>555-555-9876</div>
						</td>
					</tr>
					<tr>
						<td>
							<div style='font-weight: bold'>Enterprise Hotline</div>
							<div>1-800-123-5555</div>
						</td>
						<td>
							<div style='font-weight: bold'>Enterprise Weekend Phone</div>
							<div>555-987-6543</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>

@joelmeyer

Thanks for sharing sample HTML.

Please also share the values of fontname and newFont in your shared code snippet, so that we may able to test the scenario accordingly.