web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Issue using StringReader in CRM Online Plugin

(0) ShareShare
ReportReport
Posted on by

Hi,

We are generating a PDF file using iTextSharp Assembly. But CRM is throwing error in below line

HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(document);

  hw.Parse(new StreamReader(html));

html is the HTML string. The error we get is "Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed". I checked and found that usage of StringReader is not allowed due to security reasons. Can someone help us out here?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Sorry for the typo. It is throwing error only when I am using StringReader not StreamReader. If I don't use StringReader it works fine but the PDF is not generating correctly.

  • Community Member Profile Picture
    on at

    I am trying to read a html string. I tried using XMLWorkerHelper provided with iTextSharp but now the pdf is corrupted. Can you help me out? I need to read a record, generate a pdf and attach it to an email+create a not attachment.

  • Suggested answer
    Tim Dutcher Profile Picture
    2,100 on at

    Here's a related thread with a code example that appears to be working...

    community.dynamics.com/.../113406

  • Verified answer
    Community Member Profile Picture
    on at

    We opted to go with the HTML and then user can export that html page in form of a pdf file. Thanks everyone for your inputs.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans