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

All forums · Statistics · Search ·

Two Pilots forum / For software developers / VB Problem
Author Message
# Posted: 25 May 2005 13:32

I am a VB user, I have a few question to ask as follow:

1. I was using the demo version. When i run the HelloPDB_VB example, an error which is "JavaScript Error at line1 : illegal character" occur since I was using the VB. What is this problem?

2. I was export the data to a text file then how can I convert it to PDF file? I cannot direct export the data to the PDF file. I use the way as the HelloPDF_VB example, I have to loop the data line by line from the text file that I have generated recently and then display it to the PDF file. For the line of code as
PDF.PDFPAGE_TextOut 0, 100, 0, lstrLine

lstrLine is the text that I want display in the PDF file. For example
lstrLine = "I like eat apple" & vbTab & " and I like banana."
when I look at the PDF file, the output is "I like eat apple and I like banana." and it does not accept the vbTab function.

3. Besides that, if I read the line from the text file as "abc 123 456 789"
When I look at the PDF file, it display "abc123456789", why it this happen?

4. I have try use the PDFPAGE_UnicodeTextOutBox same as PDFPAGE_TextOut but not success, can you show the right way to use this function?

5. At last, I hope that you can email me a short program convert the text file to PDF file, thanks.


# Posted: 25 May 2005 15:23

Dear Ella,

It is more preferable to use string equivalents instead of special characters (like vbTab), for example several spaces instead of vbTab.

Here is the VBScript code to convert text file to PDF:

Function ReadFile(vbsFile)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(vbsFile)
s = f.ReadAll()
ReadFile = s
End Function

Set PDF = CreateObject("PDFcreatorPilot2.piPDFDocument")

PDF.StartEngine "demo@demo","demo"

PDF.DocumentInfo_CreationDate = Now
PDF.Filename = "VB1.pdf"
PDF.AutoLaunch = true
str = ReadFile("License.txt")
PDF.PDFPAGE_TextOutBox 10,10, 13, 700,1000, str

Function PDFPAGE_TextOutBox returns length of the string that was successfully drawn in the "box", so you can count characters in your string before function call, and if not all characters printed in PDF (function return value is lower than your string length),
you can add page using NewPage method, and print rest of your text data.

In VBScript PDFPAGE_UnicodeTextOutBox is not accessible, so i think in VB too.

Anyway, i think the best way to put some data in PDF file is direct writing using library methods.

Thank you very much !

Best regards,

# Posted: 25 May 2005 16:52


Thanks for reply me but I have another problem. I want display the format record in the text file exactly same when it is display in the PDF file. When I try the coding you give me, all the alignment of record is changed in the PDF file. Do I need other function to format the record and display it same as text file?


# Posted: 25 May 2005 18:08

Dear Ella,

As i've said, it's better to use library methods for PDF generation.

You can make some class or function which will take data and put it into different sources - PDF, text files, XML etc. To format data in PDF, you can use any library methods related with graphics and text output - please read documentation about
PDFPAGE_TextBox, PDFPAGE_TextOut, PDFPAGE_SetWordSpacing, PDFPAGE_SetActiveFont, PDFPAGE_SetTextRenderingMode - and so on, all methods which can be useful in formatting output.

Thank you very much !

Best regards,

# Posted: 26 May 2005 08:02


Can you explain to me what is the parameters need to include for the function below:



# Posted: 26 May 2005 09:21

Dear Ella,

PDFPAGE_TextBox(X as long,Y as long,X1 as long,Y1 as long,Text as String,Hor as TxHorJust,Vert as TxVertJust)

Show 'Text' string inside area bounded Rec, specified by first 4 parameterst with horizontal justify (Hor) and vertical justify (Vert).
hjLeft = 0
hjCenter = 1
hjRight = 2
vjUp = 0
vjCenter = 1
vjDown = 2

PDFPAGE_TextOut(X as double,Y as double,Orientation as double,TextStr as String)

Draws a text line "textstr" using the current font starting at location (x, y) at "orientation" (in degrees).

PDFPAGE_SetWordSpacing(Spacing as double)

This procedure sets the additional space (in points) that should be inserted between words, i.e., for every space character found in the text string.

PDFPAGE_SetActiveFont(FontName as String,FontStyle_Bold as Boolean,FontStyle_Italic as Boolean,FontStyle_Underline as Boolean,FontStyle_StrikeOut as Boolean,FontSize as long,FontCharset as TxFontCharset)

Sets the active font for text operations.
PDF Creator Pilot emulates fsUnderLine and fsStrikeOut style. If the font does not have fsBold or fsItalic style then PDF Creator Pilot will emulate it as well.
FontName - name of the True Type font. If you use Arial, Courier New, Times New Roman with FontCharset= ANSI_CHARSET then PDF Creator Pilot will use standard fonts (Type1 fonts).
Also you can use 'Symbol' and 'ZapfDingbats' standard fonts.

FontCharset can be one of the constants defined as TxFontCharset.

Note: For CJK fonts you can use any name of the font. PDF Creator Pilot uses the name of standard CJK fonts for Adobe Acrobat. For each CJK language you must have corresponding Adobe language kit. You can find it on Adobe web site
Full TxFontCharset description can be found in library documentation.

PDFPAGE_SetTextRenderingMode(Mode as TxTextRenderingMode)

Sets the mode that determines how the character outline is used. By default, the character outline is used for filling operations by which inside of the outline path is painted solidly with the current fill color. This may be changed by calling this function. See TxTextRenderingMode constants in library documentation.

Thank you very much !

Best regards,



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


Page top