Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To run jQuery in a Rotativa PDF, include jQuery and any dependent scripts in the Razor view that ViewAsPdf renders, and make sure the converter can load their URLs. Rotativa.AspNetCore renders that view to HTML and passes it to wkhtmltopdf; JavaScript runs, if it runs, during that conversion—not later in the PDF viewer. Do not assume that a jQuery ready handler waits for AJAX or other asynchronous work to finish.

Understand where jQuery runs

ViewAsPdf is not a browser window that remains open after the PDF is made. In Rotativa.AspNetCore, the view is rendered to HTML and that HTML is passed to the wkhtmltopdf executable for conversion. A script can affect the PDF only if it is present in that rendered HTML, its dependencies load, and the converter processes it in time.

This distinction explains many reports of “jQuery not working.” The PDF viewer displays the finished document; it does not run the original page’s jQuery. The key diagnostic questions are therefore whether the intended Razor view was rendered, whether the script URLs resolve for the converter, and whether the relevant work is synchronous or asynchronous. The project implementation documents the render-then-convert flow: Rotativa.AspNetCore ViewAsPdf source.

First identify which Rotativa you use

“Rotativa ViewAsPdf” can refer to the original library for ASP.NET MVC or to Rotativa.AspNetCore. Their examples and setup are not interchangeable. The original project documents the MVC action-result usage in its README. The separate Rotativa.AspNetCore README describes the Core package and its setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The ASP.NET Core README lists .NET Core 3.1, .NET 5, .NET 6, .NET 7, and .NET 8 as supported versions. Treat that as the project’s published compatibility statement, not a guarantee for other package versions or later runtimes. Check the version actually installed in your application before copying an overload or startup example.

Set up Rotativa.AspNetCore and the converter

The web application process must be able to find and execute wkhtmltopdf. The ASP.NET Core README says the default search is a Rotativa directory in the web app root and that configuration can specify another relative path. Deploy the executable for the application’s operating system and ensure the application identity has permission to read and execute it.

For startup configuration, the README specifies app.UseRotativa() for .NET 6 through .NET 8, and app.UseRotativa(env) for .NET Core 3.1 and .NET 5. Follow the instructions matching your package and runtime; do not apply one branch blindly to another.

Return the Razor view as a PDF

A minimal ASP.NET Core action uses the named-view overload documented by Rotativa.AspNetCore. Adapt the exact overload to the package version in your project and provide the model your view expects:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
public IActionResult Report()
{
    return new ViewAsPdf("Report", model);
}

In this example, Report is the view name and model is the data supplied to it. Rotativa.AspNetCore also documents overloads involving view data, models, partial views, and base-URL handling. Consult the project README and source for the signature available in your installed version rather than assuming every overload is identical.

Include jQuery in the rendered view

Put the script tags in the Razor view used for the PDF, or in a layout that the PDF view actually uses. Load jQuery before scripts that depend on it. For example, if the file is served from the application’s web root under wwwroot/lib/jquery/, a view might contain:

<script src="/lib/jquery/jquery.min.js"></script>
<script>
  $(function () {
    // Synchronous DOM changes may appear if the converter processes them
    // before capture. This does not wait for asynchronous work to finish.
  });
</script>

This is an illustrative pattern, not a guarantee that a particular converter build will execute every script. Verify the rendered HTML contains the tags and that the converter can retrieve the referenced file. A path that works in a developer’s browser may fail when the conversion process runs under a different host, base URL, identity, or network environment.

Check the base URL and asset paths

Rotativa.AspNetCore says it injects a base URL by default; its documented option setBaseUrl: false disables that behavior. Relative URLs can therefore resolve differently depending on the generated document and configuration. Prefer a path you have verified from the conversion environment, and inspect the HTML output or logs when local scripts, stylesheets, or images are missing. If you disable base URL handling, explicitly ensure the view’s assets still resolve.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remote assets also depend on network reachability and any authentication or access restrictions on the target host. The converter—not the browser where a developer previews the site—must be able to fetch them. Rotativa.io’s feature page advertises local images, CSS, and JavaScript assets, but that does not establish identical asset resolution behavior for every self-hosted deployment: Rotativa.io features.

Choose where dynamic data is produced

Prefer server-rendered values for essential PDF content

If a value must appear in the PDF, the most dependable design is to produce it before conversion: load it in the controller or other server-side code, put it in the view model, and render it in Razor. That way, the HTML supplied to the converter already contains the required content instead of depending on a later browser request.

Do not treat document ready as an AJAX completion signal

$(function () { ... }) runs when jQuery’s document-ready condition is met; it does not establish that a network request started inside the callback has completed before PDF capture. The reviewed Rotativa.AspNetCore documentation and implementation describe rendering and conversion but make no timing guarantee for AJAX or other delayed script work. If you require client-side asynchronous generation, verify the behavior with the exact wkhtmltopdf binary and version you deploy, and confirm any wait option or custom switch against that binary’s supported behavior before relying on it.

Debug a PDF with missing jQuery output

  1. Confirm the library and package. Decide whether the application uses classic ASP.NET MVC Rotativa or Rotativa.AspNetCore, then use that project’s documentation and matching controller pattern.
  2. Confirm the selected view and data. Check that the action returns the Razor view you edited and that the model or view data already contains the values expected in the PDF.
  3. Inspect script tags and paths. Verify the generated HTML includes jQuery before dependent scripts. Check whether the default base URL behavior or setBaseUrl: false changes how relative paths resolve.
  4. Check access from the application process. Make sure the asset host is reachable and the app’s execution identity can access the files. A script loading successfully in your interactive browser does not prove it is available to the converter.
  5. Check the converter executable. Confirm wkhtmltopdf is installed at the configured location and is readable and executable by the web app process.
  6. Separate DOM work from delayed work. Test whether the missing content is produced synchronously or depends on AJAX, a timer, or another delayed operation. Render required data server-side where possible.
  7. Validate custom switches against the deployed binary. Rotativa documents passing custom switches, but this alone does not mean a switch is supported or behaves the same in every converter version.

Or skip the browser setup

If your job is to capture a web page as an image or PDF rather than generate a server-rendered Rotativa report, ScreenshotNeo offers a screenshot API and MCP server. Its API returns PNG, JPEG, WebP, or PDF from a URL. It is not a substitute for supplying your own Razor model to Rotativa, but it can avoid running a browser-conversion setup for URL-based captures.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Example cURL request (replace the URL with the page you want to capture):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Cookie and consent banners are accepted or removed before capture, along with more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When a hosted conversion service may fit better

If operating a local converter is the constraint, Rotativa.io describes a hosted generation service on Azure. Its feature and instruction pages can help assess whether the hosted approach fits your application, but the pages cited here do not establish current prices, service limits, or program terms. Review the service’s current details before choosing it: Rotativa.io instructions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Practical reliability and cost considerations

Self-hosted Rotativa puts responsibility for the executable, asset access, and compatibility on the application team. Keep the package version and deployed converter binary identifiable in each environment, since a result that works locally may differ when production uses another operating system, path, or binary. Test the actual PDF-generation route after deployment, not only the Razor page in a browser.

For generated reports, preparing data server-side also reduces dependence on remote resources and uncertain client-side timing. Where remote assets are necessary, plan for their availability and access requirements. The sources reviewed do not establish conversion performance figures, reliability rates, or current Rotativa.io pricing, so these should be measured or confirmed for the environment and service you select.

Frequently Asked Questions

Does jQuery run when someone opens the finished Rotativa PDF?

No. The relevant script execution, if it occurs, is during HTML-to-PDF conversion; the PDF viewer receives the finished document.

Can I use the same ViewAsPdf example for classic Rotativa and Rotativa.AspNetCore?

No. They are separate libraries for different ASP.NET stacks; follow the documentation for the package installed in your application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.