Is it possible to generate pdf as in"3 X 4" form?
I have tried a code as below but PDF is not been generated, I had downloaded JSPDF.min from here
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="js/jspdf.min.js"></script>
<script>
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
$('#cmd').click(function () {
doc.fromHTML($('#content').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.save('sample-file.pdf');
});
</script>
html code
<div id="content">
<h3>Hello, this is a H3 tag</h3>
<p>a pararaph</p>
</div>
<div id="editor"></div>
<button id="cmd">generate PDF</button>
This is my code in my page and I am not able to create the PDF and any how PDF gets generated how can I made it show in 3X4 format?
OI had get reference of this code from http://jsfiddle.net/5ud8jkvf/11511/ and over here the PDF is generated properly, What am I missing?
I Had used iTextSharp and had made use of it. Below is my following code
using iTextSharp.text;
using iTextSharp.text.pdf;
string shippingaddress = "My name is khan <br/>";
shippingaddress += "And I am not a terrorist<br/>";
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
{
//Below code defines the PDF generate Size
Rectangle newRect = new Rectangle(0, 0, 240, Convert.ToSingle(138.6));
Document document = new Document(newRect,10f,10f,10f,10f);
Document.Compress = true;
PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
document.Open();
Font boldFont = new Font(Font.FontFamily.HELVETICA, 12,Font.BOLD);
Paragraph para = new Paragraph("Header", boldFont);
document.Add(para);
string text = shippingaddress.Replace("<br/>", "\n");
Paragraph paragraph = new Paragraph();
paragraph.SpacingBefore = 2;
paragraph.SpacingAfter = 2;
paragraph.Leading = 12;
paragraph.Alignment = Element.ALIGN_LEFT;
paragraph.Font = FontFactory.GetFont(FontFactory.HELVETICA, 12f,BaseColor.BLACK);
paragraph.Add(text);
document.Add(paragraph);
document.Close();
byte[] bytes = memoryStream.ToArray();
memoryStream.Close();
Response.Clear();
Response.ContentType = "application/pdf";
string pdfName = "Movie Name";
Response.AddHeader("Content-Disposition", "inline; filename=" + pdfName + ".pdf");
Response.ContentType = "application/pdf";
Response.Buffer = true;
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
Response.BinaryWrite(bytes);
Response.End();
Response.Close();
}
Through this code I was able to create an PDF with the 3X4 format. Mat this answer will be help full