Click here to Skip to main content
15,889,877 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# EF5 List<ENum> Persisting ? Pin
Ssyxz26-Feb-13 15:14
Ssyxz26-Feb-13 15:14 
GeneralRe: C# EF5 List<ENum> Persisting ? Pin
Khorne26-Feb-13 20:41
Khorne26-Feb-13 20:41 
AnswerRe: C# EF5 List<ENum> Persisting ? Pin
Jegan Thiyagesan27-Feb-13 6:42
Jegan Thiyagesan27-Feb-13 6:42 
QuestionNeed code Pin
jelintaric25-Feb-13 22:41
jelintaric25-Feb-13 22:41 
AnswerRe: Need code Pin
Manfred Rudolf Bihy25-Feb-13 23:06
professionalManfred Rudolf Bihy25-Feb-13 23:06 
AnswerRe: Need code Pin
Mycroft Holmes25-Feb-13 23:43
professionalMycroft Holmes25-Feb-13 23:43 
AnswerRe: Need code Pin
Amir Mohammad Nasrollahi29-Jul-13 21:33
professionalAmir Mohammad Nasrollahi29-Jul-13 21:33 
Questionformatting issue with iTextSharp Pin
krishnapnv25-Feb-13 19:10
krishnapnv25-Feb-13 19:10 
Hello

I have a requirement to write pdfdocument using html contents in an ASP.NET MVC Project. I am writing the HTML code inside a string variable and then I am giving that string for rendering it as pdf bytes using the below code. The returned bytes I am saving it as pdf on the server. However I am getting too many formatting issues in the pdf generated.

When I saved the html contents which I passed to the string, formattings are good but somehow when I am trying to create a pdf out of those contents I am getting issues. Any help will be greatly appreciated.
public byte[] Render(string htmlText)
{
byte[] renderedBuffer;


using (var outputMemoryStream = new MemoryStream())
{
using (var pdfDocument = new Document())
{
PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDocument, outputMemoryStream);
pdfWriter.CloseStream = false;
//pdfWriter.PageEvent = new PrintHeaderFooter { Title = pageTitle };
pdfDocument.Open();
using (var htmlViewReader = new StringReader(htmlText))
{
using (var htmlWorker = new HTMLWorker(pdfDocument))
{
htmlWorker.Parse(htmlViewReader);
}
}
}

renderedBuffer = new byte[outputMemoryStream.Position];
outputMemoryStream.Position = 0;
outputMemoryStream.Read(renderedBuffer, 0, renderedBuffer.Length);
}

return renderedBuffer;
}
QuestionRe: formatting issue with iTextSharp Pin
Richard MacCutchan25-Feb-13 21:55
mveRichard MacCutchan25-Feb-13 21:55 
AnswerRe: formatting issue with iTextSharp Pin
krishnapnv28-Feb-13 18:03
krishnapnv28-Feb-13 18:03 
Questionexport or save as pdf format Pin
abhishek91111925-Feb-13 17:50
abhishek91111925-Feb-13 17:50 
AnswerRe: export or save as pdf format Pin
Pete O'Hanlon25-Feb-13 20:02
mvePete O'Hanlon25-Feb-13 20:02 
AnswerRe: export or save as pdf format Pin
Abhinav S25-Feb-13 20:22
Abhinav S25-Feb-13 20:22 
QuestionChanging tabbed form over to tiled Pin
MichCl25-Feb-13 9:27
MichCl25-Feb-13 9:27 
AnswerRe: Changing tabbed form over to tiled Pin
Dave Kreskowiak25-Feb-13 9:33
mveDave Kreskowiak25-Feb-13 9:33 
GeneralRe: Changing tabbed form over to tiled Pin
MichCl26-Feb-13 9:16
MichCl26-Feb-13 9:16 
GeneralRe: Changing tabbed form over to tiled Pin
Dave Kreskowiak26-Feb-13 9:40
mveDave Kreskowiak26-Feb-13 9:40 
QuestionForce Beep...! Pin
Jassim Rahma25-Feb-13 2:57
Jassim Rahma25-Feb-13 2:57 
AnswerRe: Force Beep...! Pin
Richard MacCutchan25-Feb-13 3:09
mveRichard MacCutchan25-Feb-13 3:09 
AnswerRe: Force Beep...! Pin
Dave Kreskowiak25-Feb-13 3:56
mveDave Kreskowiak25-Feb-13 3:56 
AnswerRe: Force Beep...! Pin
PIEBALDconsult25-Feb-13 4:32
mvePIEBALDconsult25-Feb-13 4:32 
AnswerRe: Force Beep...! Pin
Eddy Vluggen25-Feb-13 8:04
professionalEddy Vluggen25-Feb-13 8:04 
AnswerRe: Force Beep...! Pin
Amir Mohammad Nasrollahi29-Jul-13 21:38
professionalAmir Mohammad Nasrollahi29-Jul-13 21:38 
QuestionASP.NET UserControl In UserControl Pin
thekoko8924-Feb-13 16:30
thekoko8924-Feb-13 16:30 
AnswerCrosspost Pin
SoMad24-Feb-13 16:47
professionalSoMad24-Feb-13 16:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.