Issue: While converting HTML to PDF the Bootstrap CSS classes are not reflected

Hello Support,

We have using Aspose.pdf version as 11.1.1.
And trying to convert HTML to PDF. Our HTML contains some Bootstrap CSS classes.
But after conversion to PDF, it does not reflect in it.

Following code we have written:

//Load HTML string
Document doc = new Document(new
MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)), htmlLoadOptions);

//Save PDF file
doc.Save(@“C:\TestPDf\outputoutput.pdf”);
//** end

html = It’s a Inner HTML of .aspx page and css reference is given as
http://localhost:50333/Website/Secure/JScriptFrameWork/KendoUI/styles/kendo.bootstrap.min.css

Please suggest.
Thank you.

Hi Ajay,


Thanks for your inquiry. Please note when you need convert a HTML that is using some external resources (CSS/Images/Fonts) then you need to pass resources path to HtmlLoadOptions() as parameter.

Please check following documentation links for details, these will help you to accomplish the task. However if the issue persist then please share your sample HTML and resource files, so we will check and guide you accordingly.


We are sorry for the inconvenience caused.

Best Regards,

Hello Support Team,

Thanks for the response.

I have tried the both option.(Convert Html to PDF and Convert Web page to PDF).

But none of them worked for me.

While I trying with the 2nd option i.e. Webpage to PDF in that, even I logged in and specify web request URL as follows,:

WebRequest request = WebRequest.Create(“http://localhost:50333/Website/ABC.aspx”);

the resultant PDF is generated for Login page not for the ABC.aspx page.

Please find the following code sample.

1] ** ABC.aspx

<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeFile="DetailsPrint.aspx.cs" Inherits="DetailsPrint" %></div><div><br></div><div><!doctype html></div><div><html></div><div><head id="Head1" runat="server"></div><div>    <title></title></div><div></head></div><div><body id="print-view"></div><div>    <form id="form1" runat="server"></div><div>      <div class="fixed-header"></div><div>        <header class="row page-header"></div><div>          <div class="w-90 relative pull-left"></div><div>                    <h1 id='matter-name'></h1></div><div>                    <div class="absolute"></div><div><span class="Apple-tab-span" style="white-space:pre">			</span><small><span class="text-muted">Last edited by</span> </div><div><span class="Apple-tab-span" style="white-space:pre">	</span>   <span class="Apple-tab-span" style="white-space:pre">	</span>               <span id="UpdatedBy"></span></div><div>                              <span class="text-muted">on</span> </div><div>                              <span id="UpdatedDate" data-bind="value: editedDate"></span></div><div>                    </small></div><div>                   </div></div><div>                </div></div></div><div>   </header><!-- /Page Header --></div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">	</span><div class='row collapsible-container' id='new'></div><div>                    <div class='col-lg-10 col-md-10 col-sm-10 collapsible-panel form-alignleft'></div><div>                        <div class='non-collapsible'></div><div>                            <div class='row'></div><div>                                <div class='col-lg-12 form-ele-lg'></div><div>                                    <div class="form-label"></div><div>                                        <span></div><div>                                            <label for="selected-name">Name :</label> </div><div>                                        </span></div><div>                                    </div></div><div>                                    <div></div><div>                                      <span id="selected-name"></span>                                 </div><div>                                    </div></div><div>                                </div></div><div>                            </div> </div></div><div><div>                        </div></div><div>                   </div></div><div>                </div> </div></div><div><br></div><div><%--   Add CSS refrence in aspx page--%></div><div><div>       <link href="http://localhost:50333/Website/Themes/CSS/main.css" rel="stylesheet" /></div><div>       <link href="http://localhost:50333/Website/Themes/JScriptFrameWork/CSS/slider.css"                  rel="stylesheet" />

2] On code behind side .cs

srtring html ==  /* Inner HTML of ABC.aspx page .*/
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions("http://localhost:50333/Website/Themes");
//Load HTML string 
Document doc = new Document(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)), htmlLoadOptions);
doc.Save(@"C:\TestPDf\outputoutput.pdf")

Please suggest. Thank you.

Hi Ajay,


Thanks for sharing additional information. I will test the scenario and will update you soon.

Best Regards,