Reputation: 529
There is a simple asp.net webform which inserts data into three tables which are related to a common ID.
Table A : ID(P.K), Name.
Table B : B_Id(P.K), ID(F.K references ID of Table A), Address.
Table C : C_Id(P.K), ID(F.K references ID of Table A), Contact.
What can I use for generating pdf report in such scenario?
Code sample is appreciated. Thank you in advance for the answer!
Upvotes: 1
Views: 638
Reputation: 529
On Saving the records to the database I fetched them and performed the pdf generation as well as sent it via email attachment.
Link: https://www.aspsnippets.com/Articles/Generate-Create-PDF-and-send-as-email-attachment-in-ASPNet.aspx
This solved my problem.
Upvotes: 1
Reputation: 11
For Creating pdf. you can also use reporting services rdlc reports. it's part of visual studio. and it supports RTL for Arabic and Persian languages. you can render reports in background.
Upvotes: 0
Reputation: 330
you can use:
https://help.syncfusion.com/file-formats/pdf/create-pdf-file-in-asp-net-web-forms
The best workaround you can have is to make a zip file then do Response.Write(zipFile)
But if you still insist on having them separately(multiple downloads) better you save each file on the server first by:
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
PdfWriter.GetInstance(pdfDoc, new FileStream(Server.MapPath("~") + pdfName + ".pdf");
}
then use this trick https://stackoverflow.com/a/30682695/336511 to support multiple download. note that this will work on modern browsers.
var links = [
'https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.exe',
'https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.dmg',
'https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.jar'
];
function downloadAll(urls) {
var link = document.createElement('a');
link.setAttribute('download', null);
link.style.display = 'none';
document.body.appendChild(link);
for (var i = 0; i < urls.length; i++) {
link.setAttribute('href', urls[i]);
link.click();
}
document.body.removeChild(link);
}
<button onclick="downloadAll(window.links)">Test me!</button>
Upvotes: -1