Click here to Skip to main content
12,629,107 members (32,258 online)
   

C#

 
AnswerRe: C# EF5 List<ENum> Persisting ? Pin
Ssyxz26-Feb-13 16:14
memberSsyxz26-Feb-13 16:14 
GeneralRe: C# EF5 List<ENum> Persisting ? Pin
Khorne26-Feb-13 21:41
memberKhorne26-Feb-13 21:41 
AnswerRe: C# EF5 List<ENum> Persisting ? Pin
Jegan Thiyagesan27-Feb-13 7:42
memberJegan Thiyagesan27-Feb-13 7:42 
QuestionNeed code Pin
jelintaric25-Feb-13 23:41
memberjelintaric25-Feb-13 23:41 
AnswerRe: Need code Pin
Manfred R. Bihy26-Feb-13 0:06
memberManfred R. Bihy26-Feb-13 0:06 
AnswerRe: Need code Pin
Mycroft Holmes26-Feb-13 0:43
memberMycroft Holmes26-Feb-13 0:43 
AnswerRe: Need code Pin
Amir Mohammad Nasrollahi29-Jul-13 22:33
professionalAmir Mohammad Nasrollahi29-Jul-13 22:33 
Questionformatting issue with iTextSharp Pin
krishnapnv25-Feb-13 20:10
memberkrishnapnv25-Feb-13 20: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 22:55
mvpRichard MacCutchan25-Feb-13 22:55 
AnswerRe: formatting issue with iTextSharp Pin
krishnapnv28-Feb-13 19:03
memberkrishnapnv28-Feb-13 19:03 
Questionexport or save as pdf format Pin
abhishek80800025-Feb-13 18:50
memberabhishek80800025-Feb-13 18:50 
AnswerRe: export or save as pdf format Pin
Pete O'Hanlon25-Feb-13 21:02
protectorPete O'Hanlon25-Feb-13 21:02 
AnswerRe: export or save as pdf format Pin
Abhinav S25-Feb-13 21:22
mvpAbhinav S25-Feb-13 21:22 
QuestionChanging tabbed form over to tiled Pin
MichCl25-Feb-13 10:27
memberMichCl25-Feb-13 10:27 
AnswerRe: Changing tabbed form over to tiled Pin
Dave Kreskowiak25-Feb-13 10:33
mvpDave Kreskowiak25-Feb-13 10:33 
GeneralRe: Changing tabbed form over to tiled Pin
MichCl26-Feb-13 10:16
memberMichCl26-Feb-13 10:16 
GeneralRe: Changing tabbed form over to tiled Pin
Dave Kreskowiak26-Feb-13 10:40
mvpDave Kreskowiak26-Feb-13 10:40 
QuestionForce Beep...! Pin
Jassim Rahma25-Feb-13 3:57
memberJassim Rahma25-Feb-13 3:57 
AnswerRe: Force Beep...! Pin
Richard MacCutchan25-Feb-13 4:09
mvpRichard MacCutchan25-Feb-13 4:09 
AnswerRe: Force Beep...! Pin
Dave Kreskowiak25-Feb-13 4:56
mvpDave Kreskowiak25-Feb-13 4:56 
AnswerRe: Force Beep...! Pin
PIEBALDconsult25-Feb-13 5:32
memberPIEBALDconsult25-Feb-13 5:32 
AnswerRe: Force Beep...! Pin
Eddy Vluggen25-Feb-13 9:04
mvpEddy Vluggen25-Feb-13 9:04 
AnswerRe: Force Beep...! Pin
Amir Mohammad Nasrollahi29-Jul-13 22:38
professionalAmir Mohammad Nasrollahi29-Jul-13 22:38 
QuestionASP.NET UserControl In UserControl Pin
thekoko8924-Feb-13 17:30
memberthekoko8924-Feb-13 17:30 
AnswerCrosspost Pin
SoMad24-Feb-13 17:47
memberSoMad24-Feb-13 17: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.


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 6 Dec 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid