Not supported output file extension when converting html to pdf

Running asp.net mvc core under .net8.
Using Aspose.HTML-Cloud 22.12.1 from nuget
var result = await api.ConvertUrlAsync(“https://website.com/stuff/report.out”, “exported.pdf”);
Is getting the error “Not supported output file extension.”
I believe the problem is that the URL doesn’t end with .HTML and it’s not something I can change.

Is there a way to tell the API that the input file is HTML?
Thanks

@rdorris

The error message “Not supported output file extension” typically occurs when the API cannot determine the input file type based on the URL provided. In your case, since the URL does not end with .html, the API may not recognize it as an HTML file.

To work around this limitation, you can specify the input format explicitly by using the appropriate API methods designed for converting web pages to PDF. Here are a couple of options you can consider:

  1. Convert Web Page to PDF: You can use the ConvertUrlAsync method, but ensure that the API is aware that the content is HTML. If the API does not support this directly, you might need to use a different endpoint that allows you to specify the input format.

  2. Use Aspose.PDF Cloud API: If the Aspose.HTML Cloud API does not meet your needs, you can use the Aspose.PDF Cloud API to convert web pages to PDF. The following endpoints can be helpful:

    • GET /pdf/create/web: This endpoint converts a web page to PDF format and returns the resulting file in the response.
    • PUT /pdf/{name}/create/web: This endpoint converts a web page to PDF format and uploads the resulting file to storage.

These methods allow you to convert web pages without needing the URL to end with .html. You can find more details about these endpoints in the Aspose documentation.

If you continue to face issues, consider checking the API documentation for any updates or changes regarding input formats and supported extensions.

For further assistance, you may want to explore related forum posts or documentation that discuss similar issues with HTML to PDF conversion.

Sources:
[1]: HTML Converter - Convert HTML with Cloud SDK and REST API

Hi @rdorris thanks for the comment. Most likely you are right regarding nuget package. We will check this. At the mean time please consider using our REST API instead because in REST you expicetly provide FROM and TO formats for conversion:

  1. Obtain bearer token with the same creds you use with nuget:
curl -X POST https://api.aspose.cloud/connect/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET"
  1. Run conversion:
curl -X POST "https://api.aspose.cloud/v4.0/html/conversion/html-pdf/sync" \
2     -H "Content-Type: application/json" \
3     -H "Authorization:Bearer <JWT_token>" \
4     -d '{"InputPath": "https://example.com"}'

More details here: Convert HTML to PDF using Cloud SDK – Aspose.HTML Cloud - it says SDK in title but it covers also REST version. I suggested you sync version - when you wait for conversion. Similar to what SDK does. But you can also use async version - this when you submit conversion, check status and download when conversion is completed. It’s the approach for large files.

Please let us know if it didn’t work well for you. We don’t have your url to try