Skip to content

Conversation

@ArjanKw
Copy link

@ArjanKw ArjanKw commented Jul 23, 2024

Created a fork as I needed to create images with wkhtmltoimage in .NET 8.

  • Add .NET 8 support;
  • Support Partial views (return new ViewAsPdf("MyPartialView", isPartialView = true);
  • Added ViewAsImage based on original Rotativa code;
  • Refactored ViewAsPdf: use default ViewName, Model, ViewData and TempData properties instead of overriding them;
  • Removed MasterName as it wasn't used;
  • Added the zoom parameter (as Add Zoom property #53 #54 has conflicts);
  • Fixed the tests by upgrading the deprecated iTextSharp to itext7.
  • Added option to specify whether you want a Base URL to be added to the head in the HTML (fix for Creating internal links in PDF, and BaseUrl that gets inserted into the HEAD #88 ).

@ArjanKw
Copy link
Author

ArjanKw commented Jul 23, 2024

Also bumped the version to 1.4.0 and added manual test in Web App to verify that images are created (png and jpeg). A similar automated test as with Pdf (to check if a text inside the PDF is present) is not possible as it is an image.

@webgio What do you think of the proposed changes?

@ArjanKw
Copy link
Author

ArjanKw commented Jul 24, 2024

Added two unit tests based on existing Rotativa code that at least check for the image format.

@ArjanKw
Copy link
Author

ArjanKw commented Jul 24, 2024

Added some useful option flags, moved Zoom to AsResultBase (so it can be utilized by ViewAsImage as well), and added unit tests to verify that option flags are correctly passed to wkhtmltopdf/wkhtmltoimage.

This is the last commit for this PR before the review. @webgio Could you review the code?

Copy link
Owner

@webgio webgio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works, thanks for the contribution!

[InlineData("https://localhost:7059", "Asp.net 6")]
public void Contact_PDF(string url, string site)
//[InlineData("https://localhost:7059", "Asp.net 6")]
[InlineData("https://localhost:56246", "Asp.net 8")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@webgio webgio merged commit 36b1191 into webgio:master Oct 28, 2024
@ArjanKw ArjanKw deleted the feature/add-image-support branch October 28, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants