I am currently trying to convert this piece of Java, which contains Lambda Expressions (.stream(), .filter(), collect() methods) code to C# LINQ code:
Java Code:
Map<Rectangle, PdfStream> highlightStreams = page.getAnnotations()
.stream()
.filter((a) -> (PdfName.Stamp.equals(a.getSubtype()) || PdfName.FreeText.equals(a.getSubtype())) && a.getNormalAppearanceObject().isStream())
.collect(
Collectors.toMap(
a -> a.getRectangle().toRectangle(),
a -> (PdfStream) a.getNormalAppearanceObject()
));
page.getAnnotations().forEach(page::removeAnnotation);
Here is the C# that I have so far. Some of the API classes are from iText7. I would like some help on it if possible please on how this can be translated to C#.
C# Code:
Dictionary<Rectangle, PdfStream> highlightStreams = page.GetAnnotations()
.Where(
(a) => (PdfName.Stamp.Equals(a.GetSubtype()) || PdfName.FreeText.Equals(a.GetSubtype()))
&& a.GetNormalAppearanceObject().IsStream())
.ToDictionary(a => a.GetRectangle().ToRectangle(),
a => (PdfStream) a.GetNormalAppearanceObject());
foreach (var pdfAnnotation in page.GetAnnotations())
{
page.RemoveAnnotation(pdfAnnotation);
}