Two Pilots™    Home  |  Navigation  |  Site Map  |  Products  |  Download  |  Prices  |  For Partners  |  Support


All forums · Statistics · Search ·

Two Pilots forum / For software developers / make my own text2pdf convert with pdfcreator
Author Message
pepino
Member
# Posted: 11 Jun 2007 16:28


hi,

Is it easy to make my own text2pdf with this software.

I have a simple textfile and i want to convert i to pdf.

Can someone give me an example.

Thankx in advance

Pepino

Stanislav
Member
# Posted: 12 Jun 2007 02:55


Dear Pepino,

You can use HTML2PDF Add-On to convert text and html files to PDF.
http://www.colorpilot.com/html2pdfaddon.html

Here is an example of how to convert HTML to PDF:
http://www.colorpilot.com/pdfsample_html2pdf_vbscr ipt.html

To convert text, comment out line
HTML.LoadFromString...
and put
HTML.LoadTextFile
with file name as a parameter. Also you can use LoadTextString.

Your text will be converted to PDF.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

pepino
Member
# Posted: 12 Jun 2007 11:39


Thankx for your quick answer.

But do you hava an examples in Delphi ?

Pepino

Stanislav
Member
# Posted: 13 Jun 2007 07:15


Dear Pepino,

We'll prepare example in Delphi and inform you when it'll be available.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

pepino
Member
# Posted: 27 Jun 2007 07:31


Hi,

To you manage to make an example

Ciao

Pepino

Stanislav
Member
# Posted: 27 Jun 2007 07:37


Dear Pepino,

Please use this VBScript example as a reference:

Option Explicit

Function ReadFile

Dim TextStream
Dim S
Dim File
Dim FSO
Const ForReading = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TextStream = FSO.OpenTextFile("LoremIpsum.txt", ForReading)
S = TextStream.ReadAll
ReadFile = S
End Function

Dim FileContents
FileContents = ReadFile
Wscript.Echo "String length is " & Len(FileContents)

Dim PDF
Set PDF = CreateObject("PDFCreatorPilot3.PDFDocument3")
PDF.StartEngine "DEMO@DEMO.com", "DEMO"
PDF.AutoLaunch = true
PDF.FileName = "OutputTextFile.pdf"
PDF.BeginDoc

Dim PageWidth, PageHeight, StartX, StartY, Width, Height, Margins, Data
Margins = 20
Dim CharsInOutput
CharsInOutput = 0

PageWidth = PDF.PDFPAGE_Width
PageHeight = PDF.PDFPAGE_Height
StartX = Margins
StartY = Margins
Width = PageWidth - 2 * Margins
Height = PageHeight - 2 * Margins

CharsInOutput = PDF.PDFPAGE_TextOutBox(StartX, StartY, 10, Width, Height, FileContents)
Data = Right(FileContents, Len(FileContents) - CharsInOutput)
Wscript.Echo "The string remainder after first page output is " & Len(Data)

While Len(Data) > 0
Wscript.Echo "New page, Len(Data)" & Len(Data)
PDF.NewPage
CharsInOutput = PDF.PDFPAGE_TextOutBox(StartX, StartY, 10, Width, Height, Data)
Wscript.Echo "Characters in output " & CharsInOutput
Data = Right(Data, Len(Data) - CharsInOutput)
Wscript.Echo "The string remainder after output is " & Len(Data)
Wend

PDF.EndDoc
Set PDF = Nothing

The "LoremIpsum.txt" is any text file.

Please don't forget to download latest version from our website.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Stanislav
Member
# Posted: 27 Jun 2007 07:38


You can comment out Wscript.Echo.

 

 

Powered by miniBB 2.0 RC7 © 2001-2004 Page creation time (sec.): 0.014

 

Page top