Well I can’t get it to create a PDF with function that I know works

Any reason you are not using css properly to style the document rather than 
each individual item being locally styled because that is the first place to 
look??

 

john renfrew 

Right Way Up 



 

From: chaitanya krishna [mailto:kolladot...@yahoo.com] 
Sent: 15 March 2013 14:16
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] Unable to genreate a PDF as in PDF File

 

 

Hi team,

 

I am using the ITextsharp to generate a PDF file for the attachec html file. 
Sample PDF was also attached. 

 

I am missing the background color and borders to that, can you please suggest a 
sample code to generate appropriately. below is the code.

 

byte[] pdfContents = Render();

string pdfName = "file.pdf";

pafPdfPath = Path.Combine(path, pdfName);

// // Create a new stream to write to the file

using (BinaryWriter Writer = new BinaryWriter(System.IO.File.Open(pafPdfPath, 
FileMode.CreateNew)))

{

Writer.Write(pdfContents);

Writer.Flush();

Writer.Close();

}

 

public byte[] Render()

{

htmlText = System.IO.File.ReadAllText("c:\\file.html");

 

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))

{

////Create a provider collection to set various processing properties

//System.Collections.Generic.Dictionary<string, object> providers = new 
System.Collections.Generic.Dictionary<string, object>();

////Set the image base. This will be prepended to the SRC so watch your forward 
slashes

//providers.Add(HTMLWorker.IMG_BASEURL, "http://YOUR_DOMAIN";);

////Bind the providers to the worker

//htmlWorker.SetProviders(providers);

htmlWorker.Parse(htmlViewReader);

}

}

}

renderedBuffer = new byte[outputMemoryStream.Position];

outputMemoryStream.Position = 0;

outputMemoryStream.Read(renderedBuffer, 0, renderedBuffer.Length);

}

return renderedBuffer;

}

 

 

 

 

Regards,
Chaitanya Kolla.
9885155441

 

Image
Lorem Ipsum
ID: Lorem Ipsum
DOB: Lorem Ipsum
PROVIDER: Lorem Ipsum
Address: Lorem Ipsum, Franklin, TN 37067 Secure Fax Server: (123) Lorem Ipsum
 
Lorem Ipsum
Lorem Ipsum Lorem Ipsum/or
co-morbid conditions
Lorem Ipsum
Completed
Lorem Ipsum   no
Lorem Ipsum   no
Lorem Ipsum   no
Lorem Ipsum   yes
Lorem Ipsum   yes
Lorem Ipsum

Lorem Ipsum

Lorem Ipsum Lorem Ipsum Lorem Ipsum
Lorem Ipsum 12/2/2012 Member refused

 

Lorem Ipsum Lorem Ipsum Lorem Ipsum
Lorem IpsumLorem IpsumLorem IpsumLorem IpsumLorem IpsumLorem IpsumLorem IpsumLorem IpsumLorem IpsumLorem IpsumLorem IpsumLorem Ipsum Lorem IpsumLorem IpsumLorem Ipsum Lorem IpsumLorem IpsumLorem Ipsum

 

Lorem Ipsum Lorem Ipsum Lorem Ipsumn
Lorem IpsumLorem IpsumLorem IpsumLorem Ipsum 2/4/2013 12:00:00 AM Lorem Ipsum
LOREM IPSUM
Lorem Ipsum Lorem Ipsum
co-morbid conditions
Lorem Ipsum Lorem Ipsum
Lorem Ipsum 440.0 Lorem Ipsum Lorem Ipsum Yes

Attachment: File.pdf
Description: Adobe PDF document

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to