Alguien me puede ayudar con impresion desde ASP, lo que necesito es poder crear archivos PDF apartir de listados o paginas completas de ASP
Gracias!!!!!
| ||||
Bueno, es bastante fácil: Primero, bajate el componente (hecho con ASP, nada de DLL's ni esas cosas) de: http://www.aspxnet.it/public/default.asp, y aunque ahí hay un manual, te recomiendo mejor cheques este otro: http://www.thebook-demo.com/php/pdf/Docs/ Corre los demos de la web del autor y comenta si aún tienes dudas, es bastante intuitivo. Saludos |
| ||||
Chaca que ese archivo y en esa ruta exista. Si por alguna razón la rata es correcta pero el archivo no existe, solo pon lo siguiente en un archivo llamado helvetica.js en esa ruta
Código:
Saludos xfpdf_charwidths["helvetica"]=lib.newArray(lib.chr(0) , 278,lib.chr(1) , 278,lib.chr(2) , 278,lib.chr(3) , 278,lib.chr(4) , 278,lib.chr(5) , 278,lib.chr(6) , 278,lib.chr(7) , 278,lib.chr(8) , 278,lib.chr(9) , 278,lib.chr(10) , 278,lib.chr(11) , 278,lib.chr(12) , 278,lib.chr(13) , 278,lib.chr(14) , 278,lib.chr(15) , 278,lib.chr(16) , 278,lib.chr(17) , 278,lib.chr(18) , 278,lib.chr(19) , 278,lib.chr(20) , 278,lib.chr(21) , 278,lib.chr(22) , 278,lib.chr(23) , 278,lib.chr(24) , 278,lib.chr(25) , 278,lib.chr(26) , 278,lib.chr(27) , 278,lib.chr(28) , 278,lib.chr(29) , 278,lib.chr(30) , 278,lib.chr(31) , 278," " , 278,"!" , 278,"\"" , 355,"#" , 556,"$" , 556,"%" , 889,"&" , 667,"\'" , 191,"(" , 333,")" , 333,"*" , 389,"+" , 584,"," , 278,"-" , 333,"." , 278,"/" , 278,"0" , 556,"1" , 556,"2" , 556,"3" , 556,"4" , 556,"5" , 556,"6" , 556,"7" , 556,"8" , 556,"9" , 556,":" , 278,";" , 278,"<" , 584,"=" , 584,">" , 584,"?" , 556,"@" , 1015,"A" , 667,"B" , 667,"C" , 722,"D" , 722,"E" , 667,"F" , 611,"G" , 778,"H" , 722,"I" , 278,"J" , 500,"K" , 667,"L" , 556,"M" , 833,"N" , 722,"O" , 778,"P" , 667,"Q" , 778,"R" , 722,"S" , 667,"T" , 611,"U" , 722,"V" , 667,"W" , 944,"X" , 667,"Y" , 667,"Z" , 611,"[" , 278,"\\" , 278,"]" , 278,"^" , 469,"_" , 556,"`" , 333,"a" , 556,"b" , 556,"c" , 500,"d" , 556,"e" , 556,"f" , 278,"g" , 556,"h" , 556,"i" , 222,"j" , 222,"k" , 500,"l" , 222,"m" , 833,"n" , 556,"o" , 556,"p" , 556,"q" , 556,"r" , 333,"s" , 500,"t" , 278,"u" , 556,"v" , 500,"w" , 722,"x" , 500,"y" , 500,"z" , 500,"{" , 334,"|" , 260,"}" , 334,"~" , 584,lib.chr(127) , 350,lib.chr(128) , 556,lib.chr(129) , 350,lib.chr(130) , 222,lib.chr(131) , 556,lib.chr(132) , 333,lib.chr(133) , 1000,lib.chr(134) , 556,lib.chr(135) , 556,lib.chr(136) , 333,lib.chr(137) , 1000,lib.chr(138) , 667,lib.chr(139) , 333,lib.chr(140) , 1000,lib.chr(141) , 350,lib.chr(142) , 611,lib.chr(143) , 350,lib.chr(144) , 350,lib.chr(145) , 222,lib.chr(146) , 222,lib.chr(147) , 333,lib.chr(148) , 333,lib.chr(149) , 350,lib.chr(150) , 556,lib.chr(151) , 1000,lib.chr(152) , 333,lib.chr(153) , 1000,lib.chr(154) , 500,lib.chr(155) , 333,lib.chr(156) , 944,lib.chr(157) , 350,lib.chr(158) , 500,lib.chr(159) , 667,lib.chr(160) , 278,lib.chr(161) , 333,lib.chr(162) , 556,lib.chr(163) , 556,lib.chr(164) , 556,lib.chr(165) , 556,lib.chr(166) , 260,lib.chr(167) , 556,lib.chr(168) , 333,lib.chr(169) , 737,lib.chr(170) , 370,lib.chr(171) , 556,lib.chr(172) , 584,lib.chr(173) , 333,lib.chr(174) , 737,lib.chr(175) , 333,lib.chr(176) , 400,lib.chr(177) , 584,lib.chr(178) , 333,lib.chr(179) , 333,lib.chr(180) , 333,lib.chr(181) , 556,lib.chr(182) , 537,lib.chr(183) , 278,lib.chr(184) , 333,lib.chr(185) , 333,lib.chr(186) , 365,lib.chr(187) , 556,lib.chr(188) , 834,lib.chr(189) , 834,lib.chr(190) , 834,lib.chr(191) , 611,lib.chr(192) , 667,lib.chr(193) , 667,lib.chr(194) , 667,lib.chr(195) , 667,lib.chr(196) , 667,lib.chr(197) , 667,lib.chr(198) , 1000,lib.chr(199) , 722,lib.chr(200) , 667,lib.chr(201) , 667,lib.chr(202) , 667,lib.chr(203) , 667,lib.chr(204) , 278,lib.chr(205) , 278,lib.chr(206) , 278,lib.chr(207) , 278,lib.chr(208) , 722,lib.chr(209) , 722,lib.chr(210) , 778,lib.chr(211) , 778,lib.chr(212) , 778,lib.chr(213) , 778,lib.chr(214) , 778,lib.chr(215) , 584,lib.chr(216) , 778,lib.chr(217) , 722,lib.chr(218) , 722,lib.chr(219) , 722,lib.chr(220) , 722,lib.chr(221) , 667,lib.chr(222) , 667,lib.chr(223) , 611,lib.chr(224) , 556,lib.chr(225) , 556,lib.chr(226) , 556,lib.chr(227) , 556,lib.chr(228) , 556,lib.chr(229) , 556,lib.chr(230) , 889,lib.chr(231) , 500,lib.chr(232) , 556,lib.chr(233) , 556,lib.chr(234) , 556,lib.chr(235) , 556,lib.chr(236) , 278,lib.chr(237) , 278,lib.chr(238) , 278,lib.chr(239) , 278,lib.chr(240) , 556,lib.chr(241) , 556,lib.chr(242) , 556,lib.chr(243) , 556,lib.chr(244) , 556,lib.chr(245) , 556,lib.chr(246) , 556,lib.chr(247) , 584,lib.chr(248) , 611,lib.chr(249) , 556,lib.chr(250) , 556,lib.chr(251) , 556,lib.chr(252) , 556,lib.chr(253) , 500,lib.chr(254) , 556,lib.chr(255) , 500); Última edición por Myakire; 02/09/2004 a las 13:00 |
| ||||
ESTE ES EL CODIGO QUE ESTOY PONIENDO Y NO ME RESULTA, DE HECHO EL ARCHIVO SI EXISTE Y SI CONTIENE ESOS DATOS <%@language=javascript%> <!-- #include file="fpdf.asp "--> <% var pdf=new FPDF(); pdf.CreatePDF(); pdf.SetPath("fpdf /"); pdf.SetFont("Arial", "",16); pdf.Open(); pdf.AddPage(); pdf.Cell(40,10, "PRIMERA PRUEBA!"); pdf.Close(); pdf.Output(); %> |
| ||||
Cita: Ya lo probé y con eso tiene. var pdf=new FPDF(); pdf.CreatePDF(); //pdf.SetPath("fpdf /"); //Debería ser: pdf.SetPath("fpdf/"); pdf.SetFont("Arial", "",16); pdf.Open(); pdf.AddPage(); pdf.Cell(40,10, "PRIMERA PRUEBA!"); pdf.Close(); pdf.Output(); %> |
| ||||
Por cierto, tal vez me estoy adelantando, pero yo tuve este problema en IE (no así en otros): http://www.aspxnet.it/forum/topic.asp?TOPIC_ID=44 Chécalo, tal vez te sirva. |
| ||||
Ese es el problema, con este componente tienes que ir armando la página directamente con la clase, no con etiquetas html, casi, casi como si estuvieras haciendo un reporte en Cobol o en Clipper. va un ejemplo:
Código:
Pero como te comenté de manerá inicial: Si lo que pretendes es que a páginas que ya existen pasarla por un objeto y obtener un PDF, solo de pago o que las "parsees" tu mismo. <%@LANGUAGE="VBSCRIPT"%> <!--#include file="fpdf.asp"--> <% Session.LCID = 2058 vDep = Request("Dep") vDir = Request("Dir") vDepto = Request("Depto") vTextoDependencia = request.Form("txtDep") vTextoDireccion = request.Form("txtDir") vTextoDepto = request.Form("txtDepto") %><!-- #include File="conexion.asp" --><% dim adoRs set adoRs = Server.CreateObject("adodb.recordset") Query = "Execute sImprimeActividad "&vDep&", "&vDir&", "&vDepto&", "&vStatus adoRs.Open Query,cnn Set pdf=CreateJsObject("FPDF") pdf.CreatePDF() pdf.SetPath("fpdf/") pdf.Open() cnt=1 cnt=0 cnt2=0 CntAsuntos=0 Dep_Ant = "" Act_Ant = "" Depto_Ant = "" Fecha = CStr(Date()) while NOT adoRS.EOF if Depto_Ant <> adoRs("Depto") Then Depto_Ant = adoRs("Depto") pdf.AddPage() pdf.Image "fin.JPG",12,12,20,12 pdf.SetTextColor 9,38,244 call NuevaLinea(90,30,10,vTextoDependencia,12,5,"B","C",0) pdf.SetTextColor 24,103,235 call NuevaLinea(90,30,10,vTextoDireccion,9,5,"B","C",0) call NuevaLinea(90,30,10,CStr(adoRs("Depto")),9,5,"B","C",0) End If pdf.SetDrawColor 251,131,51 if Act_Ant <> adoRs("Descripcion") Then Act_Ant = adoRs("Descripcion") CntAsuntos=1 Cnt=Cnt+1 pdf.SetTextColor 0,0,0 call NuevaLinea(1,10,4,"#",8,0,"B","C",1) call NuevaLinea(11,130,4,"Asunto",8,0,"B","C",1) call NuevaLinea(141,30,4,"Importe",8,0,"B","C",1) call NuevaLinea(171,24,4,"Fecha",8,4,"B","C",1) call NuevaLinea(1,10,4,CStr(cnt),8,0,"B","C",0) x1 = pdf.GetY() call NuevaMLinea(11,130,4,CStr(adoRs("Descripcion")),7,0,"","J",0) x2 = pdf.GetY() pdf.SetY(x1) call NuevaLinea(141,30,4,CStr(FormatNumber(adoRs("Importe"),2)),7,0,"B","C",0) Fecha = MID(adoRs("Fecha_Post"),1,LEN(adoRs("Fecha_Post"))-8) ampm = RIGHT(adoRs("Fecha_Post"),4) call NuevaMLinea(171,24,4,CStr(Fecha&" "&m),6,7,"B","C",0) pdf.SetY(x2) End If AccionAnt = Replace(Trim(adoRs("Accion")),"’","") AccionAnt = Replace(AccionAnt,"'","") CntAsuntosAnt = CntAsuntos PropuestaAnt = adoRs("Propuesta") InstruccionesAnt = adoRs("Instrucciones") ObservacionesAnt = adoRs("ObservacionesInt") Mayor = 0 Campo = 0 Valores = "" Lin_Acc = FormatNumber(ROUND(pdf.GetStringWidth(CStr(AccionAnt)) / 60)+1,2) if CDbl(Lin_Act) >= Mayor Then Mayor = CDbl(Lin_Acc) Campo=1 End If Lin_Pro = FormatNumber(ROUND(pdf.GetStringWidth(CStr(PropuestaAnt)) / 50)+1,2) if CDbl(Lin_Pro) >= Mayor Then Mayor = CDbl(Lin_Pro) Campo=2 End If valores = CStr(Lin_Acc)&","&CStr(Lin_Pro)&","&CStr(Lin_Ins)&","&CStr(Lin_Obs) adoRS.MoveNext CntAsuntos=CntAsuntos+1 if NOT adoRs.EOF Then if Act_Ant <> adoRs("Descripcion") Then call LlenaTabla(Campo,Mayor,valores) End IF Else call LlenaTabla(Campo, Mayor,valores) End IF Wend pdf.Close() pdf.Output() Function LlenaTabla(Mayor, C,valores) pdf.SetDrawColor 0,0,0 call NuevaLinea(1,5,4,CStr(CntAsuntosAnt),8,0,"B","C",0) x1 = pdf.GetY() call NuevaMLinea(66,50,4,CStr(PropuestaAnt),6,0,"","L",0) If Mayor = 2 Then x2 = pdf.GetY() End If pdf.SetY(x2) pdf.Line 12,x2,205,x2 End Function Function NuevaLinea(Celda, Ancho, Alto, Texto, Fuente, Salto,Estilo,Alineacion, Marco) pdf.SetFont "Arial",Estilo,Fuente pdf.Cell Celda pdf.Cell Ancho,Alto,Texto,Marco,0,Alineacion pdf.Ln Salto End Function Function NuevaMLinea(Celda, Ancho, Alto, Texto, Fuente, Salto,Estilo,Alineacion, Marco) pdf.SetFont "Arial",Estilo,Fuente pdf.Cell Celda pdf.MultiCell Ancho,Alto,Texto,Marco,0,Alineacion pdf.Ln Salto End Function %> |