Sunteți pe pagina 1din 6

wxPdfCOM Generador Pdf gratuito http://www.linares.

net/wxpdfcom/

Crea documentos PDF desde Visual Basic con facilidad.

Solo tienes que añadir wxPdfCom a las referencias de tu proyecto.

También puedes usar wxPdfCOM desde Delphi.

(La instrucciones y proyecto de ejemplo en Delphi son cortesía de Carlos Sánchez)

Hola mundo
Cerrar
Dim pdf As PdfComLib.PdfDoc

Private Sub cmdHelloWorld_Click()


Set pdf = New PdfDoc
pdf.AddPage (1)
pdf.SetFont "Arial", "", 10
pdf.Cell 20, 10, "Hello World !", 0, 0, 1, 0, ""
pdf.SaveAsFile ("helloworld.pdf")
End Sub

Resultado

1 de 6 31/03/2011 14:04
wxPdfCOM Generador Pdf gratuito http://www.linares.net/wxpdfcom/

Hola mundo (En Delphi)


procedure TForm1.btn2Click(Sender: TObject);
Cerrar

var i: integer;
begin
PDF.CleanupInstance();
PDF.AddPage(1);
i := 0;
PDF.SetFont('Arial', '', 10, i);
i := 0;
PDF.Cell(20, 10, 'Hello World !', 0, 0, 1, i, '');
PDF.SaveAsFile ('helloworld.pdf');
ShowMessage ('Ok');
end;
Resultado

Bookmark
Dim pdf As PdfComLib.PdfDoc
Cerrar

Private Sub CmdBookmark_Click()


Set pdf = New PdfDoc
pdf.Open
pdf.SetFont "Arial", "", 15
'Page 1
pdf.AddPage PORTRAIT
pdf.Bookmark "Page 1", 0, -1
pdf.Bookmark "Paragraph 1", 1, -1
pdf.Cell 0, 6, "Paragraph 1", 0, 0, 0, 0, ""
pdf.LN 50
pdf.Bookmark "Paragraph 2", 1, -1
pdf.Cell 0, 6, "Paragraph 2", 0, 0, 0, 0, ""
pdf.Annotate 60, 30, "First annotation on first page"
pdf.Annotate 60, 60, "Second annotation on first page"
'Page 2
pdf.AddPage PORTRAIT
pdf.Bookmark "Page 2", 0, 0
pdf.Bookmark "Paragraph 3", 1, -1
pdf.Cell 0, 6, "Paragraph 3", 0, 0, 0, 0, ""
pdf.Annotate 60, 40, "First annotation on second page"
pdf.Annotate 90, 40, "Second annotation on second page"
pdf.SaveAsFile "bookmark.pdf"
End Sub

2 de 6 31/03/2011 14:04
wxPdfCOM Generador Pdf gratuito http://www.linares.net/wxpdfcom/

Header() y Footer()
Private Sub CmdHeading_Click()
Cerrar

Dim NumPag As Integer


NombreDocumento = "headingtest.pdf"
Set Pdf = New PdfDoc
Pdf.AliasNbPages "{nb}"
Pdf.SetFont "Arial", "", 10

Pdf.header (True)
Pdf.SetY (1)
Pdf.Cell 15, 10, "This is a Header", 0, 0, 1, 0, ""
Pdf.SetY (5)
Pdf.header (False)

Pdf.Footer True
Pdf.SetY -15
Pdf.SetFont "Arial", "I", 8
Pdf.SetTextColor 128, 0, 128
Pdf.Cell 0, 10, "P�g {pg}/{nb}", 0, 0, PDF_ALIGN_CENTER, 0, ""
Pdf.Footer False

Pdf.SetFont "Arial", "", 10


For NumPag = 1 To 5
Pdf.AddPage (1)
Pdf.Cell 15, 10, "Body page " & Str(NumPag), 0, 0, 1, 0, ""
Next

Pdf.SaveAsFile (NombreDocumento)
MsgBox ("Ok")
End Sub
Resultado
Ejemplo de Alfa y Sector()
Private Sub CmdSector_Click()
Cerrar

Dim x As Single
Dim Radio As Single
Radio = 5
Dim Alfa As Integer
Set Pdf = New PdfDoc
Pdf.AddPage (1)
NombreDocumento = "alfasector.pdf"
'Alfa = pdf.SetAlpha(0.1, 0.1, 2)
'pdf.SetAlphaState Alfa
For x = Radio To Pdf.GetPageWidth + Radio Step Radio * 2
Pdf.SetFillColor Rnd(255) * 255, Rnd(255) * 255, Rnd(255) * 255
Pdf.Sector x, 0, Radio, 0, 180, PDF_STYLE_FILLDRAW, False, 180
Pdf.Sector x, Pdf.GetPageHeight + 1, Radio, 0, 180,
PDF_STYLE_FILLDRAW, True, 180
Next
For x = Radio To Pdf.GetPageHeight + Radio Step Radio * 2
Pdf.SetFillColor Rnd(255) * 255, Rnd(255) * 255, Rnd(255) * 255
Pdf.Sector 0, x, Radio, 0, 180, PDF_STYLE_FILLDRAW, True, 90
Pdf.Sector Pdf.GetPageWidth, x, Radio, 0, 180, PDF_STYLE_FILLDRAW,
False, 90
Next
Pdf.SaveAsFile (NombreDocumento)
MsgBox ("Ok")

3 de 6 31/03/2011 14:04
wxPdfCOM Generador Pdf gratuito http://www.linares.net/wxpdfcom/

Ejemplo de DrawCircle()
Private Sub cmdcirculos_Click()
Cerrar

Dim x As Single
Dim xcentro As Single, ycentro As Single
Dim Radio As Single
Dim Salto As Single
Dim Alfa As Integer
Set Pdf = New PdfDoc
Pdf.AddPage (1)
xcentro = Pdf.GetPageWidth / 2
ycentro = Pdf.GetPageHeight / 2
Radio = ycentro * 1.5
Salto = 0.5
Alfa = Pdf.SetAlpha(0.1, 0.1, 2)
Pdf.SetAlphaState Alfa
While Radio > 0
Pdf.SetDrawColor Rnd(255) * 255, Rnd(255) * 255, Rnd(255) * 255
Pdf.DrawCircle xcentro, ycentro, Radio, 0, 0, PDF_STYLE_DRAW, 0
Radio = Radio - Salto
Wend
NombreDocumento = "circulos.pdf"
Pdf.SaveAsFile (NombreDocumento)
MsgBox ("Ok")
End Sub
Resultado

Ejemplo de Rect()
Cerrar

Private Sub CmdCuadros_Click()


Dim x As Single, y As Single, w As Single, h As Single
Dim Salto As Single
Dim Saltox As Single, Saltoy As Single
Dim Alfa As Integer
Set Pdf = New PdfDoc
Pdf.AddPage (1)
Saltox = 0.5
Saltoy = Saltox * Pdf.GetPageHeight / Pdf.GetPageWidth
x = Saltox
y = Saltoy
w = Pdf.GetPageWidth - Saltox
h = Pdf.GetPageHeight - Saltoy
While x < Pdf.GetPageWidth / 2 And y < Pdf.GetPageHeight / 2
' pdf.SetDrawColor Rnd(255) * 255, Rnd(255) * 255, Rnd(255) * 255
Pdf.Rect x, y, w, h, PDF_STYLE_DRAW
x = x + Saltox
y = y + Saltoy
w = w - 2 * Saltox
h = h - 2 * Saltoy
Wend
NombreDocumento = "cuadros.pdf"
Pdf.SaveAsFile (NombreDocumento)
MsgBox ("Ok")
End Sub
Resultado

4 de 6 31/03/2011 14:04
wxPdfCOM Generador Pdf gratuito http://www.linares.net/wxpdfcom/

Arrows
Private Sub CmdArrow_Click()
Cerrar

Set Pdf = New PdfDoc


Pdf.SetFont "Arial", "", 10
Pdf.AddPage (PORTRAIT)
Pdf.Arrow 10, 10, 50, 50, 3, 10, 3
Pdf.Arrow 120, 120, 50, 50, 3, 10, 3
Pdf.Arrow 40, 18, 55, 50, 1, 5, 3
Pdf.Arrow 300, 120, 50, 60, 2, 3, 2
NombreDocumento = "arrows.pdf"
Pdf.SaveAsFile (NombreDocumento)
MsgBox ("Ok")
End Sub
Resultado

Si te gusta WXPDFCOM y te resulta util, tal vez lo quieras conocer más a fondo.
Hazte con nuestra guía. Es la mejor forma de apoyar nuestro proyecto.

Por otro lado, nuestra dll está basada en el proyecto wxPdfDocument (C++), y éste a su vez está
inspirado en fpdf (Php)
Busca en sus documentaciónes respectivas. Alli encontrarás más información y ejemplos.

5 de 6 31/03/2011 14:04
wxPdfCOM Generador Pdf gratuito http://www.linares.net/wxpdfcom/

Como usar WXPdfCOM en Delphi


Cerrar

Por Carlos Sanchez

1) Registrar la DLL, desde una ventana de DOS y como Administrador


hacermos regsvr32 pdfcom.dll
2) Crear nuestro proyecto que va a usar la librer�a o abrirlo si ya existe
3) Menu Project, Import Type Library
4) Boton "Add"
5) Elegir la dll
6) Boton: "Create Unit"
7) Ya podemos usar el componente, lo tenemos en la solapa "ActiveX"

Nota: probado con Delphi 7


Descargate el proyecto de ejemplo para Delphi

Pulsa aqui para descargar pdfcom.dll.

Guarda el archivo en una de tus carpetas

Registra la dll con la sentencia siguiente regsvr32 tucarpeta/pdfcom.dll

6 de 6 31/03/2011 14:04

S-ar putea să vă placă și