As we know, ASPX is a file extension that is used for server generated web pages leading to active server. It is associated with Microsoft ASP.NET framework. This format file can’t be opened locally in windows.
However, converting them into PDF can be a good way to open them locally. The following article will guide you on converting ASPX file to PDF in the easiest and most effective way using Iron PDF software.
Setting it up
You first require adding IronPdf.NET PDF class library in your website application. Make sure that you install the latest version of it. You can begin with normal ASPX web form that can render as HTML. You can later convert it into PDF. It is important to note that Style Sheets, hyperlinks, images, along with HTML forms are properly preserved during conversion process.
There are indeed numerous options for tweak and make perfect while converting ASPX file to the PDF by making use of .Net Web forms. You can even go through the documented options online. The following are some of the settings that can be configured according to your preferences.
- PDF file name
You can add an additional parameter to set file name of PDF document. You can control name of file when user may decide to keep it or download it.
- PDF File Behavior
The “InBrowser” file behavior shows PDF in the browser of the user directly. While this isn’t possible in each and every web browser, it is common feature of modern browsers.
- PDF Print Options
You can control output of PDF by adding instance of IronPdf.PdfPrintOptions Class. Some of the top PDF PrintOptions that are available include the following.
- CustomCssUrl – It allows custom CSS style sheet you want to apply to HTML.
- CssMediaType – It enables Media=”print” or “screen” for the CSS3 StyleSheets and CSS Styles.
- FitToPaperWidth – It shrinks the content of PDF to 1 page’s width where possible.
- PrintHtmlBackgrounds – Prints the HTML image backgrounds.
- Zoom – A% scale level that allows developer to shrink or enlarge HTML content.
Headers and Footers
Headers and footers can be added to the output of PDF. The simplest way for doing it is with the help of SimpleHeaderFooter class that supports basic layout. As a result, dynamic data like page numbering and current time can be easily added. One can also generate Headers and Footers in HTML using HtmlHeaderFooter class that supports images, CSS, and Hyperlinks.
While HTML usually flows into long page, PDFs generally simulate digital paper and thus are broken into equal or consistent pages. Adding the code “<div style = ‘page-break-after”always;’> </div> will create page break automatically in PDF which is .Net generated.
Experimenting is one of the best ways for learning anything including programming technique! Try IronPDF now and convert your ASPX files into PDF files without any hassles and in the most efficient way!