Reputation: 1853
I am generating PDF document using XSLT template with iTextSharp in my ASP.net MVC application.
I will be feeding in DataSet to XSLT template and get the final HTML string by following method
private static XmlDocument GetDataPopulatedXmlFromXslt(string xsltFilePath, DataSet dataToBePopulated)
{
var xslCompiledTransform = new XslCompiledTransform();
xslCompiledTransform.Load(xsltFilePath);
var objectXmlDoc = new XmlDocument();
objectXmlDoc.LoadXml(dataToBePopulated.GetXml());
var strBuilder = new StringBuilder();
using (var xmlWriter = new XmlTextWriter(new StringWriter(strBuilder)))
{
xslCompiledTransform.Transform(objectXmlDoc, xmlWriter);
var xsltXmlOutDoc = new XmlDocument();
xsltXmlOutDoc.LoadXml(strBuilder.ToString());
return xsltXmlOutDoc;
}
}
The next step will be to create iTextSharp Document like following
public void ParseXhtmlContents(string xhtml)
{
//Instantiate handler
var elementhandler = new ElementHandler();
//Bind a reader to text
using (TextReader sr = new StringReader(xhtml))
{
//Parse
XMLWorkerHelper.GetInstance().ParseXHtml(elementhandler, sr);
}
//Loop through each element
foreach (var element in elementhandler.Elements)
{
var div = element as PdfDiv;
if (div != null)
foreach (var table in div.Content.OfType<PdfPTable>())
{
table.HeaderRows = 1;
}
_iTextDocument.Add(element);
}
}
In the xhtml string I will have image tag like <img src="\\network\subfolder\image.png">
This image gets loaded in my final PDF only if EVERYONE user group is provided permission to subfolder folder.
Need to remove EVERYONE permission from this path and provide access to the required user.
Can anyone point out what user group needs to be provided permission in order for the image to get loaded in the document?
Upvotes: 0
Views: 326
Reputation: 2976
Step 1: Open IIS. Then add a virtual directory in your web application.
Step 2: Then map your shared path with the virtual directory added in Step 1
Step 3: Now click on Connect as..
Step 4: Set the credential of your desired user by which you want to connect your shared path.
Step 5: Now the IIS configuration part is over and you need to start using src="Image/Image.png" in your html.
Upvotes: 1