Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Html to PDF CSS Example

$
0
0
Hey,

I seem to be missing something.  I have attempted several tests and I cannot seem to get the external css to link up with my html file using aspose pdf.

Pdf pdf = new Pdf();
                //Set Page Size
                pdf.PageSetup.PageHeight = PageSize.LetterHeight;
                pdf.PageSetup.PageWidth = PageSize.LetterWidth;
                var margins = new MarginInfo();
                margins.Top = 36;
                margins.Left = 36;
                margins.Right = 36;
                margins.Bottom = 36;
                pdf.PageSetup.Margin = margins;
                pdf.HtmlInfo.ExternalResourcesBasePath = "C:/Users/Administrator/Documents/Visual Studio 2012/PDFTest/Content/html/";
// load the HTML file to Stream object
                using (Stream htmlAsStream = File.OpenRead("C:/Users/Administrator/Documents/Visual Studio 2012/Projects/PDFTest/Content/html/index.html"))
                {
                    // bind the source HTML
                    pdf.BindHTML(htmlAsStream, "");
                }
                // save the PDF file
                pdf.Save("C:/Users/Administrator/Desktop/Aspose.pdf");

my html file contains the following link ref = <link rel="stylesheet" type="text/css" href="style.css" />

I have also referenced several different examples on the Aspose website and they don't help.

Thanks,
Grant

Viewing all articles
Browse latest Browse all 3131