Trebam napraviti dokument PDF i spremiti stranci . To trebam napraviti na serveru u web aplikaciji sa aspx, i c# .
Prije sam koristio Select.HtmlToPdf i sve je bilo ok. Ali kako su sada svi traže da im se plato , trenutno nisam u mogućnosto , tražim neki kod koj i bi mi napravip pdf
pokušao sam sa :
Code:
public static bool CreatePDFFromStringITEXTSHARP(string html, string file)
{
bool pov = false;
try
{
string put = HttpContext.Current.Server.MapPath("\\PDF\\");
put = put + file + ".pdf";
if (html == null || file == null)
{
// neke od varijabli su null, vratite grešku ili izvadite iz funkcije
// return false;
}
else
{
Document document1 = new Document();
document1.Open();
using (FileStream fs = new FileStream(put, FileMode.Create))
{
PdfWriter writer = PdfWriter.GetInstance(document1, fs);
HTMLWorker htmlWorker = new HTMLWorker(document1);
htmlWorker.Parse(new StringReader(html));
}
if (document1 == null)
{
Thread.Sleep(1 * 5 * 1000);
}
document1.Close();
pov = true;
}
}
catch (Exception exc)
{
pov = false;
}
return pov;
}
public static bool CreatePDFFromStringITEXTSHARP(string html, string file)
{
bool pov = false;
try
{
string put = HttpContext.Current.Server.MapPath("\\PDF\\");
put = put + file + ".pdf";
if (html == null || file == null)
{
// neke od varijabli su null, vratite grešku ili izvadite iz funkcije
// return false;
}
else
{
Document document1 = new Document();
document1.Open();
using (FileStream fs = new FileStream(put, FileMode.Create))
{
PdfWriter writer = PdfWriter.GetInstance(document1, fs);
HTMLWorker htmlWorker = new HTMLWorker(document1);
htmlWorker.Parse(new StringReader(html));
}
if (document1 == null)
{
Thread.Sleep(1 * 5 * 1000);
}
document1.Close();
pov = true;
}
}
catch (Exception exc)
{
pov = false;
}
return pov;
}
ali nikako . napravi mi file, ali prazna i ne može se otvoriti.
Već dugo vremea radi m na tome.
Da li bi mi ko mogao pomoći ??'