In the previous tutorial we looked out how to create a simple PDF document that was one page and was only text. If you've seen many PDF documents on the web or elsewhere you know that they usually include more than just text. Fortunately we are able to do these things as well. In this VB PDF tutorial we're going to look at how to further use the mjwPDF class accomplish what we need. By the end of the tutorial you should be able to create a multi-page document that has headers, footers with page numbers, shapes, graphics, and web links.If you want, you can download the source code for this VB PDF tutorial and follow along with it.
If you haven't read the introductory tutorial about Creating a PDF document using Visual Basic. Please do so first. This VB tutorial builds off the previous one. In fact to start with lets look at the code we created before:
Private Sub Command1_Click()
' Create a simple PDF file using the mjwPDF class
Dim objPDF As New mjwPDF
' Set the PDF title and filename
objPDF.PDFTitle = "Test PDF Document"
objPDF.PDFFileName = App.Path & "\test.pdf"
' We must tell the class where the PDF fonts are located
objPDF.PDFLoadAfm = App.Path & "\Fonts"
' View the PDF file after we create it
objPDF.PDFView = True
' Begin our PDF document
objPDF.PDFBeginDoc
' Set the font name, size, and style
objPDF.PDFSetFont FONT_ARIAL, 15, FONT_BOLD
' Set the text color
objPDF.PDFSetTextColor = vbBlue
' Set the text we want to print
objPDF.PDFTextOut "Hello, World! From mjwPDF (www.vb6.us)"
' End our PDF document (this will save it to the filename)
objPDF.PDFEndDoc
End Sub
Great. With this code we've done all the initializing and created a basic file. Now lets add some formatting options. Right after we set the fonts folder lets add a few lines of code that tell mjwPDF what the document layout should be like.
' We must tell the class where the PDF fonts are located
objPDF.PDFLoadAfm = App.Path & "\Fonts"
' Set the file properties
objPDF.PDFSetLayoutMode = LAYOUT_DEFAULT
objPDF.PDFFormatPage = FORMAT_A4
objPDF.PDFOrientation = ORIENT_PORTRAIT
objPDF.PDFSetUnit = UNIT_PT
' View the PDF file after we create it
objPDF.PDFView = True
This code sets up a standard page (letter size) in portrait orientation and our units of measure as points.
Next lets do something fun. Often times you want to add a heading to a PDF document such as "Very Important Report Blah Blah" Lets figure out how to add a heading such as this to our document. Delete the bold lines of code below:
' Begin our PDF document
objPDF.PDFBeginDoc
' Set the font name, size, and style
objPDF.PDFSetFont FONT_ARIAL, 15, FONT_BOLD
' Set the text color
objPDF.PDFSetTextColor = vbBlue
' Set the text we want to print
objPDF.PDFTextOut "Hello, World! From mjwPDF (www.vb6.us)"
' End our PDF document (this will save it to the filename)
objPDF.PDFEndDoc
And add these lines of code in their place:
' Lets add a heading
objPDF.PDFSetFont FONT_ARIAL, 15, FONT_BOLD
objPDF.PDFSetDrawColor = vbRed
objPDF.PDFSetTextColor = vbWhite
objPDF.PDFSetAlignement = ALIGN_CENTER
objPDF.PDFSetBorder = BORDER_ALL
objPDF.PDFSetFill = True
objPDF.PDFCell "A centered heading", 15, 15, _
objPDF.PDFGetPageWidth - 30, 40
Let me explain what these mean. You should recognize the first line of code. It just sets the font info. Next we set the DrawColor (which in this case will be the highlight or inside color of our box). Next the text color is set and our alignment and border. The PDFSetFill=true tells mjwPDF to fill this box in when it prints out our text. The next line is what displays it all.
Let me break it down. The first parameter is simply the text we want displayed. Next we tell it how far over from the left we want the box (or cell) in our case we said 15 points over from the left. The next parameter is 15 points down from the top. Next we have to specify how wide the box is going to be. We want it to stretch all the way over to the right side of the page (minus the 15 point right border). To accomplish this we can use the mjwPDF classes PDFGetPageWidth function. This will give us the full width of the page we then subtract 30 off of it (15 for the left border and 15 for the right border), the last parameter is the height of the cell, 40 will be plenty high to accommodate our text.
If you run the code you should see your PDF pop up with a beautiful header at the top of the page.
Another fun thing is to create shapes in your PDF files. This can be used to create bar graphs or to highlight certain areas. Here is some sample code that creates a square.
' Lets draw a dashed red square
objPDF.PDFSetLineColor = vbRed
objPDF.PDFSetFill = True
objPDF.PDFSetLineStyle = pPDF_DASHDOT
objPDF.PDFSetLineWidth = 1
objPDF.PDFSetDrawMode = DRAW_NORMAL
objPDF.PDFDrawPolygon Array(300, 150, 400, 150, 400, 250, 300, 250)
Most the settings are self explanatory. Notice that you can specify the line style and the line width. Also notice that there is no draw square function. Instead there is a draw polygon function. It takes one parameter, but that parameter is an array of points specified in x y coordinates. X being how far from left to right to draw the point and Y being how far from top to bottom. So in our example we are specifying 4 points (the four corners of the square).
Next lets draw an ellipse. An ellipse is simply a circle that can be squeezed either vertically or horizontally. To define it correctly we have to use some mathematical terms. If you remember from geometry class a circle has a radius. The radius is the distance from the center of the circle to the edge of the circle. An ellipse has two radiuses. One is horizontal the other is vertical. So the code for our ellipse is this:
' Lets draw an ellipse
objPDF.PDFSetDrawColor = vbYellow
objPDF.PDFSetLineColor = vbBlack
objPDF.PDFSetLineStyle = pPDF_DASHDOT
objPDF.PDFSetLineWidth = 1.25
objPDF.PDFSetDrawMode = DRAW_DRAWBORDER
objPDF.PDFDrawEllipse 300, 150, 75, 25
All the parameters should make sense by now. The new line is the PDFDrawEllipse call. Its a very simple call except that many times you think the x and y coordinates would correspond to the center of the circle. However, you would be wrong. Instead the first to parameters correspond to the upper left corner of the square that bounds the ellipse. The next two parameters specify the horizontal radius and the vertical radius respectively. If this seems confusing just run the program and you will see what I mean. The x & y parameters for our ellipse are the same as the x & y parameters for our first point in the square so you will see how it works. If you run the program you should see this:
Lets step back to text manipulation in PDF documents again. One thing you usually see in a professional document is the header like we did above. Another thing is usually page numbers in the footer. We can use the same logic we used for our header to add page numbers. I would like to add the numbers in the footer of the page on the right side, like most documents have. I'm not going to walk through how you can do this step by step, but here is the code for a visual basic subroutine that adds the page number to the bottom right corner of your PDF document.
' Adds the page number to the current page
Private Sub AddPageNumber(objPDF As mjwPDF, pageNumber As Integer)
Dim sPageInfo As String
Dim fontSize As Double
Dim margin As Double
fontSize = 10 'Size of font to use
margin = 40 'Size of margin (left, right, bottom)
' Set what we want to print for page info
sPageInfo = "Page " & pageNumber
' Should save these settings and change them back for more robust code
objPDF.PDFSetTextColor = vbBlack
objPDF.PDFSetAlignement = ALIGN_RIGHT
objPDF.PDFSetFont FONT_ARIAL, Conversion.CInt(fontSize), FONT_NORMAL
objPDF.PDFSetFill = False
' Uncomment the below line if you want to see how our formatting works
'objPDF.PDFSetBorder = BORDER_ALL
' Draw the page number at the bottom of the page to the right
objPDF.PDFCell sPageInfo, margin, _
objPDF.PDFGetPageHeight - margin - fontSize, _
objPDF.PDFGetPageWidth - (margin * 2), fontSize
End Sub
Now that we know how to add page numbers how do we actually create multiple pages? Its very simple. When you are done with the first page, simply call the PDFEndPage method. Next call the PDFNewPage method to start the next page. Than just call the commands to add your text or shapes to the next page. You can do this as many times as you want. Don't forget to call the AddPageNumber method on each page though.
Another useful feature of PDF documents is adding bookmarks. Bookmarks allow you to jump from section to section in a PDF document easily. When the user views a PDF document with bookmarks, they are able to see a table of contents type tab on the left side of the screen. Note: if you want that pane to be visible by default you should add this line of code to the initializing section of your program.
' Lets us set see the bookmark pane when we view the PDF
objPDF.PDFUseOutlines = True
Adding a bookmark is very easy in Visual Basic using mjwPDF. For instance lets add four bookmarks to our first page of our document. Call these anywhere in your code before you call the PDFEndPage method.
'Lets add a bookmark to the start of page 1
objPDF.PDFSetBookmark "A. Page 1", 0, 0
'Now a bookmark half way down page 1
objPDF.PDFSetBookmark "A1. Page 1 Halfway down", 1, 300
'Now one at the end page 1
objPDF.PDFSetBookmark "A2. End of Page 1", 1, 500
'Another one a little further down and shows nesting
objPDF.PDFSetBookmark "A2-Sub1.", 2, 800
The first call to PDFSetBookmark creates a bookmark labeled "A. Page 1". The next parameter is the depth of this bookmark. Note: Start your depth at 0. The last parameter is the y position to where the bookmark will move the page. So the first call created a bookmark titled "A. Page 1" that points to the top of page 1. The next call creates a bookmark titled "A1. Page 1 halfway down". It has a depth of 1 (so it will be a child under our first bookmark) and it will scroll the page 300 points down. If you run the program you will see all the bookmarks created like this screen shows.
Another necessity to learn when creating PDF documents is how to add images to them. The mjwPDF class allows you to add any .jpg images to your PDF document. If the image is in a different format you will need to convert it to .jpg before you will be able to add it to your PDF file. However, if the image is a jpeg it is very easy to add it to the PDF doc. In the sample source code included with this tutorial you will see a logo.jpg file. Below is the code to end our first page and to start our second page. On the second page we add our logo to the upper left corner of the page.
objPDF.PDFEndPage
'Start page 2
objPDF.PDFNewPage
'Lets add an image to page 2
objPDF.PDFImage App.Path & "\logo.jpg", _
15, 15, 50, 50, "http://www.vb6.us"
The highlighted code is what adds the logo. We call the PDFImage function. The first parameter is the path to the jpeg file. The next two parameters are the x and y coordinates for the logo. The next two parameters specify the width and height of the image. These parameters can be left off and then it will just display the picture in its original size. You can also specify just the height or width and it will scale the other side of the picture to keep it in proportion. The last parameter is also optional, but it allows you to specify a web site to go to if someone clicks on the image.
If you run your program now you will see a PDF file that has all the properties of a complete PDF document. Headers, shapes, images, and page numbers. Combining all these techniques you should be able to do just about anything you would want to. Download the Advanced PDF VB Tutorial source code to see the full sample.
This is a common question. Although the mjwPDF class does allow you to do some pretty cool things you still may wish to buy a control for one or more of the reasons below:
If you get to a point where you do need to buy a PDF control I can probably recommend one to you. Send me an email and I can help you out. Otherwise if the mjwClass works for you feel free to use it. I would still ask you to send me an email just so I know what your using it for. Thanks.
error
Set oRep = Fso.GetFolder(sPathBegin)
error!! is not the path.
Hi
Nice stuff.
Went thru' the entire discussion but cud not find anything on "line break". How do I force a text string output to the next line if the str length is more than can be accommodated in a single line.
Much appreciated.
Good code thanks a lot!!!
Good code thanks a lot!!!
fonts in making PDF's
Hi,
It's great to finaly found a way to make pdf's within vb6.
But i've got a question.
Are there more fonts available. In the directory wich was shipped by te class i only saw e few.
The strange thing however was that ik could use objPDF.PDFSetFont FONT_arial, 10, FONT_BOLD
eventhough Arial was not included. And the other way around, i could not use Helvetica, altough it was shipped.
Maybe i'm doing somthing wrong
Hope to hear from you.
Greetings,
André van der Plas
You should read in deeply the code
in this function
Public Sub PDFSetFont(str_Fontname As PDFFontNme, in_FontSize As Integer, Optional str_Style As PDFFontStl)
the author check the name of constant then convert to exactly file name with .afm files in the \fonts folders.
let see more or contact me for understanding
microsoft access convert to pdf and word
I have a project that ask me to make a system that allow the microsoft access to export document to pdf or word.. but in that document every page will have different ID number..so I need to export then make it automatically seperated to its own id number then save to the chosen file..anyone know how can i do this in visual basic? please help me..
Improve PDF generation performance
I need this in order to modify a legacy application that uses Adobe Printer and it's not as fast as I expect. The application is a PDF invoice creator.
Does anyone has experience creating thousands of PDF per hour? Does this code allows me to do that?
Thanks in advance.
problems for multiline text Or Text file
Hi,
This code is working fine but there is problem When i Add
objPDF.PDFTextOut "Hello, World! From mjwPDF (www.vb6.us) fsdfksdflsdkldflfkldfldkldfdlflgsdgsdkgjsdkgjsdgsdgsdrttrutyfddgddddddddddtwey8ddddddddddwetwetyddddddddgdsgdsg"
large string
In pdf file it shows only one line text And it is up to 40 characters it does not shows remaining character
will u please help me
Thank's in Advanced
BackgroundImage
Hi, thanks for the great work on this class.
I want to know if is there any way to put a background Image on the PDF?
error 70 with windows 7
Listings in PDF work fine with Windows XP but run the program with windows 7 gives error 70, and breaks the program. Please .. help me
Multi-Line (why the extra line space)
So I am feeding multi-lines. When I send each line to the PDFTextOut sub, I am seeing an extra line of space. Does anyone know why there is an extra line of space??
Line 1
Line 2
Line 3
re: Multi-Line (why the extra line space)
So how did you feed Multi-Lines? if it is by using the y axis of the page, then just reduce the space between them.
For example:
objPDF.PDFTextOut "this is line one", 100, 50
objPDF.PDFTextOut "this is line two", 100, 70
objPDF.PDFTextOut "this is line three", 100, 90
If the 20 points are much then make that smaller.
Get picture from imagebox
Is there a way to get a picture from an imagebox and put it on the PDF?
Multiple Lines on the pdf
My head hurts... I cant figure out how to fetch the data from a list box and write them to a pdf in multiple lines like they appear in the list.
The line remains one, and goes outside the page. No vbCrLf has worked or anything. Can anyone please help?
*edit: Solved it. I just didn't read the listbox data correct.
Nope. still nothing.
I got the lines from the listbox, but from a multiline text box i cant figure it out. The line stays the same and the text goes outside the pdf document. Any help?
Watermark
Good Day,
does anyone have a sample of how the watermark work?
Page "turning"
Hello:
I need my application to launch and page through a PDF file. I am able to launch but not page through. Can you help with that?
Thank you very much....
Inserting Form Fields
Hi.
When I create the PDF - Files I don't have all the information to put in, this have to be done later by the user. Is it possible to create form fields with your class?
Thanks
Matthias
Put data in a PDF using Visual Basic 2010
Can somebody tell me if his possible put data in a PDF using Visual Basic??
I have a program with a "Clients" DataBase, and i want to put the client name and adress in a PDF almost created.
His possible???
Hi opened the PDF using the "OpenFileDialog"
Thanks
Put data in a PDF using Visual Basic 2010
Can somebody tell me if his possible put data in a PDF using Visual Basic??
I have a program with a "Clients" DataBase, and i want to put the client name and adress in a PDF almost created.
His possible???
Hi opened the PDF using the "OpenFileDialog"
Thanks
pdf file doesnt work
I ran the basic example and when I try to open the created file in adobe reader it tells me that the file is either of the wrong type or is damaged.
Anyone else have this problem and hopefully a solution for it?
View Start at first page
Hi,
How to set the PDF Document Start View at First Page, Now it start with last page.
Thank's
image problem
Hi, I want to add a picture to my pdf file but it says:
Invalid JPEG marker
Cannot add image to PDF file.
Whats the problem?
PDFPrinter.PDFImage App.Path
PDFPrinter.PDFImage App.Path & "\Testing.jpg", 15, 220, 150, 100, "http://www.vb6.us"
App.Path & "\Testing.jpg" is position of picture
How to draw curves using the class mwjPDF
I would like to draw simple curves. Plz. help me how to, using this class giving the piece of code.
I NEED TO KNOW ASWELL!!!!!
I NEED TO KNOW ASWELL!!!!!
Creating Annotation at specific position
Hi, First of all let me thank you for sharing such wonderful library. I have one request and I guess you can help me out. How can i add annotation to existing PDF at specified position? Lets say for example if i want to create a annotation at 100,100 position with size 200, 200. How can i do that? Thanks in advance.
Swiftprint code and your class
Hi There,
I created an application a while ago using Swiftprint and all was well - if was pretty complex to figure out and elaborate page manipulation ensured that I can provide all the printing the client wanted. Client phoned asking if we can store the printput to PDF... I am thinking of using your application/class to achieve this but see myself having to re-write all of that code. Is there an easier way?
Inserting Page Number and Filename at the bottom of Each Page
I would like to be able to insert a footer on each page of an existing PDF, with the file path, file name and the page number as page ## of ##.
The code above shows how insert page number on one page. Can it work through each page in the document. I am running the code from a microsoft access data base.
Thanks in advance for your help.
Page
Page Number
PDFPrinter.PDFTextOut "Page " & PDFPrinter.PDFPageNumber ,
PDFPrinter.PDFGetPageWidth / 2 - PDFPrinter.PDFGetStringWidth("Page " & PDFPrinter.PDFPageNumber), _
PDFPrinter.PDFGetPageHeight - PDFPrinter.PDFTextHeight
Re: Inserting Page numbers
I would like to know this, too.
jump to bookmark
great job you have done. your code is very nice. But i have a question how to jump to specific bookmark whenever i open pdf file.
printform to pdf
How Do i send Form layout directly to PDF
How to convert crystal report 8.5 to PDF using VB6
hi all,
am developing a vb application that uses crystal control to show the report.on the same time i need to export the report to pdf file.
case1
while printing invoice each copy of invoice it will add in to one pdf file.
pls help its urgent
URGENT!word file to pdf
please help me to create pdf from word file.
need urgent help..
thanks in advance
go to the microsoft website
go to the microsoft website and look for DOC to PDF converter. They have a free addin that you can add to your microsoft word. Go to primopdf.com and check their website. It's a free converter and very good.
Google pdfcreator.
Google pdfcreator.
help regarding vb6?
dear experts,
i wan to know whether i can upload doc files,pdf files,images etc to the database.... using vb6 as front end and back end as MS Access database.... if so plz explain me how to do it wit simple example...as im beginner to vb6... thanks in advance... do reply if u know....
How to print PICTUREBOX
Very good class library but missing image from pictureBox. I have modify this library, but there are the problems. I getting error when i try to add image into PDF, "Insufficient data for an image".
Contact me send Sample
Help me.
Elisio
Hi All Im also facing the
Hi All
Im also facing the same problem. Can anyone can help me with this? Really appreaciate it if can solve it. Im using adobe reader 9.3.
Thanks
jx
How to print PICTUREBOX
Very good class library but missing image from pictureBox. I have modify this library, but there are the problems. I getting error when i try to add image into PDF, "Insufficient data for an image".
Contact me, send Sample
elisio.cappio@alice.it
Help me.
Elisio
PDGImage
Hi, may I know anyone replied your request? Because I am also facing the same problem.
same here. any news on this
same here. any news on this one?
Other types of images?
Hi. I store images in a sql table wich are later saved to the local disk for use in VB. However, when I store these images in the DB, they lose their format, wich means even if they were originally jpgs, they become (apparently) BMPs once i call them, so i cant use this class to print said images. Is there a way to transform these files to jpg through VB? or what would i need to be able to print these images?
Hope you can help. Thanks
Image handling enhancement
I'm sending plain raw images to a PDF without text and so I needed to make sure the image was fit to the page. In the existing code, if the image size was larger than the page, the edges would be cut off. I added some code so that if the image width and height were unspecified (ie. 0), then the image would be resized to fit to the page dimensions:
In the PDFImage sub, change the following code from this:
If w = 0 And h = 0 Then
w = ArrInfo(0) / in_Ech
h = ArrInfo(1) / in_Ech
End If
to this:
If w = 0 And h = 0 Then
w = ArrInfo(0) / in_Ech
h = ArrInfo(1) / in_Ech
If w > PDFCanvasWidth(in_Canvas) Then
w = PDFCanvasWidth(in_Canvas)
h = w * ArrInfo(1) / ArrInfo(0)
End If
If h > PDFCanvasHeight(in_Canvas) Then
h = PDFCanvasHeight(in_Canvas)
w = h * ArrInfo(0) / ArrInfo(1)
End If
End If
I also added this code for centering, but it may have other undesired effects, such as not allowing an image to start off the left of the page:
Right after the following code in PDFImage:
If w = 0 Then w = h * ArrInfo(0) / ArrInfo(1)
If h = 0 Then h = w * ArrInfo(1) / ArrInfo(0)
put this code:
If y < 0 Then y = (PDFCanvasHeight(in_Canvas) - h) / 2
If x < 0 Then x = (PDFCanvasWidth(in_Canvas) - w) / 2
When you want to add a full page, centered image use the following command:
objPDF.PDFImage sFilename, -1, -1
If you want to use the command like it was before, just specify the other parameters:
objPDF.PDFImage sFilename, 0, 0, 50, 50
run-time error when using PDFSetBorder = BORDER_BOTTOM
I have the following lines of code in my project:
objPDF.PDFSetFont FONT_ARIAL, 6, FONT_normal
objPDF.PDFSetDrawColor = vbWhite
objPDF.PDFSetTextColor = vbBlack
objPDF.PDFSetAlignement = ALIGN_LEFT
objPDF.PDFSetBorder = BORDER_BOTTOM
objPDF.PDFSetFill = True
objPDF.PDFCell "0000000", 329, 35, 70, 9
And am getting the following error at run-time:
Run-time error 13: Type mismatch
The error is occurring on this line in the mjwPDF class module:
If PDFstrTempBorder = "LRTB" Or PDFstrTempBorder = 1 Then
And I find that if I change my pdfsetborder property to either BORDER_NONE or BORDER_ALL, the run-time error disappears, but if it is set to BORDER_LEFT, BORDER_RIGHT, BORDER_TOP, or BORDER_BOTTOM, I get the run-time error.
Any idea what would cause this? Is this is a program bug?
Thanks,
Kevin
run-time error when using PDFSetBorder = BORDER_BOTTOM
I had the same problem. I solved it by changing PDFStrTempBorder fron string to variant. I had to do this for all these border constants.
Thank you that fixed it for
Thank you that fixed it for me as well - I changed the PDFStrTempBorder to variant, and also changed the tBorder variable to a variant type, and then all the borders worked as you would expect them to. Thanks.
Great stuff
I have a question though. How can one access an already existing pdf and pull out text and pictures. Is it just the reverse of opening it and trying to read the text or is there something else?
Thanks
how to write pdf file using sql query record set
how to write pdf file using sql query record set
thanks in advance
Vikas Verma
add data of a TEXT-BOX to PDF
how do i add the data of a TEXT-BOX,in vich which the user will write data..to a PDF file..
plzzz help man..mail me the soln.
thanks in advance
Other fonts for PDF file creation
Truly great tutorial and example for learning about creating DPF files in VB. Is there, or would you consider writing, some tutorial on how other fonts could be used for creating PDF files?
I have spent a considerable time researching available documentation on the PDF file format specifications and experimenting with your code, but so far I've had no luck (I consider myself to be a quite advanced VB expert, although real professionals would likely consider me a diletant).
Default Page
Hello, I think you have done a fantastic job with this class. I have one question though that I have not seen asked here. I am making multi-page PDF documents, but when they are opened in the acrobat reader it always opens to the end of the document. I didn't see any obvious functions to make it open to page 1. I would appreciate any help you can give me as it is very important that the document opens to page 1. Thank you, I appreciate it
Default Page Solution
Default Page Solution :
Salut,
Dans la procédure PDFSetCatalog, j'ai remplacé les instructions :
"/OpenAction [3 0 R ..."
par les instructions :
"OpenAction [1 0 R ..."
et cela fonctionne ...
Congratulations to mjwPDF Class !
very good
Thank you Sergel!
Default Page Solution
Would someone please translate this to English and fill in the "....". Thanks.
Default Page Solution
I've figured it out. In the Class Module find the PDFSetCatalog Sub. In the code for PDFZoomMode you will see four statements that have "/ OpenAction [3 0 R ......" in them. Change the 3 to 1 in all four statements.
This resolved the situation. The displayed document now begins at page 1, both within the VB application and when the file is opened directly with Adobe Acrobat.
As an aside, why would the default ever be to display the document beginning with the last page?
Thank you Tom! I was going
Thank you Tom! I was going to try and figure out this out today and you saved a ton of time!
Hi ! "Thank you Tom !
Hi !
"Thank you Tom ! ..."
And no thanks for SergeL ???
Adding code 32 font
I need write PDFs with barcodes, i found the code39 afm file and put it in the Font directory, but i don't know very well how can i add the font to the project to use it.
I was reading the class methods and i think that only can use the default fonts. I modify some lines of the class to add the new font but the method PDFGetStringWidth launch this error: "Runtime error '9', subscript out of range" in the line "ArrFNT(aAsc(1)) = Int(aWX(1))".
May be the code39.afm not correct?
Please Help me !!!
Fonts
Did you ever figure out how to add more fonts? We need to have a lot more font options but I have not been able to add any yet.
windows Vista
I tried your class in several examples, and has always worked, since I'm using Vista does not work anymore! crashes in this part of code:
Private Sub PDFEndStream()
Dim TempSize As Long
TempStream = TempStream & sTempStream
If dTempStream <> "" Then TempStream = TempStream & dTempStream
sTempStream = ""
dTempStream = ""
PDFOutStream TempStream, "endstream"
PDFOutStream TempStream, "endobj"
PDFOutStream sTempStream, "%FIN_OBJ/%"
StreamSize2 = 6
PDFAddToOffset Len(TempStream)
Strm.WriteLine TempStream '***** ERROR!! "Permission denied".
TempSize = Len(TempStream) - StreamSize1 - StreamSize2 - Len("Stream") - Len("endstream") - 6
ContentNum = CurrentObjectNum
CurrentObjectNum = CurrentObjectNum + 1
TempStream = ""
PDFOutStream sTempStream, "%DEBUT_OBJ/%"
PDFOutStream TempStream, CurrentObjectNum & " 0 obj"
PDFOutStream TempStream, CStr(TempSize)
PDFOutStream TempStream, "endobj"
PDFOutStream sTempStream, "%FIN_OBJ/%"
PDFAddToOffset Len(TempStream)
Strm.WriteLine TempStream
End Sub
and tells me "Permission denied".
The same code on Win XP works fine!
Do you have experience of this case?
Vista is troublesome - Get Windows 7
Where are you saving your files i.e. which folders?
Vista is notoriously troublesome because they have blocked every access by the user except the Administrator.
If you have written an application that save data to the typical windows directory i.e. such as "program files" then you may have this permission problem.
My suggestion, try saving your application to "common files" folder.
extract the fonts en the file PDF
youyou have can extracting fonts the file PDF .... PDF to Fonts..? think you.
f
This is helpful. But how do
This is helpful. But how do i open the current(saved) pdf file and write into it? help is much appreciated
Very nice information
Very nice information manMelissa, this article realy help me. Thanks it really looks promising! Your blog is one of the most wonderful places to visit.
Help pls, to open a pdf file and print it programatically?
Can someone help me please. Assuming I have 2 printers setup on mydesktop. Printer1 is a Black and white and Printer 2 is Color. Printer1 is the default printer. I wanted my VB Program to open the pdf file and automatically select Printer2 (Color) for printing? I am using Microsoft Print Dialog reference in my project to bring up the printer dialog box.
converting pdf file to word document in vb
Dear friends,
i need help to convert a pdf file to a word document using vb, pls can anyone help me to do this,
if so pls mail me on thanusree@ncssoft.in
thanks
Using a diferent Font
I'm using the class to create a PDF report. It works fine while I use the fonts provided with the sample code. I used TTF2PT1 utility to convert the Calibri.ttf Font to an afm file. It seems to work good. I create the PDF report well but when I open it, a message saying "The Calibri.afm Font contains an erroneous /Bbox" Of course I did the corrections to the code for it. Can anyone help what to do for solve this? I'll appreciate your best help.
pocket watches
pocket watches pocket watch mens pocket watches antique pocket watches
Post new comment