borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2013 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Next Topic (resize and flip the image) New Topic New Poll Post Reply
AndreaVB Forum : VB General : PDF
Poster Message
karl93
Level: Graduate

Registered: 07-11-2011
Posts: 9

icon PDF

Hello boys,
I save my form in visual basic 6 in pdf format. I have written in this way:


Private Sub mnuSalva_Click() Dim rec As String rec = Form7.Caption CommonDialog1.DialogTitle = "Salva file" CommonDialog1.Filter = "PDF|*.pdf" CommonDialog1.FilterIndex = 2 CommonDialog1.ShowSave Filename = CommonDialog1.Filename F = 1 Open Filename For Output As F Print #F, rec Close F Filename = "Senza Titolo" End Sub



But when I open the pdf file I get an error. How can I fix this?

07-11-2011 at 11:39 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 643
icon Re: PDF

You are writing to a plain text file, not a pdf. Use Notepad to open the file.
It is not possible to output documents formatted as pdf in this way. A PDF file encapsulates a complete description of a fixed-layout document, including the text, fonts, graphics, and other information needed to display it. It cobines 3 technologies - the PostScript page description language, a font embedding system, and a structured storage system to bind it all together. In other words, it's way beyond the scope of any basic file Input/Output methods in VB6.  

____________________________
multi-tasking - the ability to hang more than one app. at the same time.

07-11-2011 at 02:50 PM
View Profile Send Email to User Show All Posts | Quote Reply
karl93
Level: Graduate

Registered: 07-11-2011
Posts: 9
icon Re: PDF

Thanks for the reply.
I ask you kindly help to solve my problem. How can I do?

08-11-2011 at 10:26 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 643
icon Re: PDF

If you want to save a file as a pdf document then the easiest way to do it is to first save the file as a text file - as you aready are, then "Print" the file to a "PDF Printer". This is a program that appears in your list of Printers as if it was a piece of hardware, but when you "Print" to it instead of getting a piece of paper you get a file converted into a pdf document. You can get free pdf printers (such as CutePDF) which should do the job for you. Just Google "free pdf printer" to see what is available.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

08-11-2011 at 12:21 PM
View Profile Send Email to User Show All Posts | Quote Reply
karl93
Level: Graduate

Registered: 07-11-2011
Posts: 9
icon Re: PDF

How do I modify my code? Can you help?


Thanks  

08-11-2011 at 01:28 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 643
icon Re: PDF

Printing (and everything else) from the latest version of VB.NET is much easier than from VB6 - you are quite clearly new at VB programming, so unless you have a really good reason for wanting to use VB6 I would recommend that you download VB.NET 2010 Express from the Microsoft Website - it is FREE and there is a lot of online documentation to show you how to use it.
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-basic-express

If you really must persisit in trying to print a pdf from VB6 then read this:-
http://www.vb6.us/tutorials/visual-basic-tutorial-pdf


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

11-11-2011 at 12:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
karl93
Level: Graduate

Registered: 07-11-2011
Posts: 9
icon Re: PDF

Thanks for the replies.  

However, one last question. A program in VB6 can be installed on a PC running Windows Vista or Windows 7?

13-11-2011 at 09:25 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 643
icon Re: PDF

Yes. See this support statement from Microsoft.
http://msdn.microsoft.com/en-us/vstudio/ms788708
BUT - the implication within this statement is that it will not be supported in the next version, Windows 8 - and this has already reached the Developer preview stage, so will be with us soon. So, I repeat my suggestion that you really should be looking at VB.NET for your programming.


[Edited by GeoffS on 14-11-2011 at 02:16 PM GMT]

____________________________
multi-tasking - the ability to hang more than one app. at the same time.

14-11-2011 at 02:07 PM
View Profile Send Email to User Show All Posts | Quote Reply
karl93
Level: Graduate

Registered: 07-11-2011
Posts: 9
icon Re: PDF

Ok. Thanks for the advice. I will go to VB.Net in future.  

However, continuing with my problem.
I installed the program and set through Control Panel -> Printers -> PDFCreator as the default printer.

Then after I went into my VB program and I put this code:

    Private Sub mnuSalva_Click()      Me.PrintForm      End Sub



But doing it this way does not go out the window to save the form in PDF. Most likely I did something wrong. Kindly ask you more help!  


Thanks

[Edited by karl93 on 15-11-2011 at 11:26 AM GMT]

15-11-2011 at 11:23 AM
View Profile Send Email to User Show All Posts | Quote Reply
karl93
Level: Graduate

Registered: 07-11-2011
Posts: 9
icon Re: PDF

All ok. It works perfectly. I'm sorry.
Now I would like to make changes.
In particular I would like the default file name to save is "Microsoft Visual Basic", but the current date.

Possible?   

15-11-2011 at 08:01 PM
View Profile Send Email to User Show All Posts | Quote Reply
karl93
Level: Graduate

Registered: 07-11-2011
Posts: 9
icon Re: PDF

Any help?  

17-11-2011 at 08:31 AM
View Profile Send Email to User Show All Posts | Quote Reply
karl93
Level: Graduate

Registered: 07-11-2011
Posts: 9
icon Re: PDF

Help?  

18-11-2011 at 07:19 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 643
icon Re: PDF

Dim strTmp As String

strTmp = "Form_Name" & Format(Date, "ddmmyyyy") & ".pdf"
App.Title = strTmp
Me.PrintForm

Compile the project into an EXE and then run the exe, it will show the filename as set by strTmp


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

22-11-2011 at 04:55 PM
View Profile Send Email to User Show All Posts | Quote Reply
karl93
Level: Graduate

Registered: 07-11-2011
Posts: 9
icon Re: PDF

Thank you! Very nice!  

22-11-2011 at 10:32 PM
View Profile Send Email to User Show All Posts | Quote Reply
EdenZ
Level: Protégé

Registered: 12-04-2013
Posts: 6
icon Re: PDF

you wanna create pdf files using VB.NET ,right ? pdf generating sdk in VB.NET can help developers to create pdf reader in your own project.

[Edited by EdenZ on 14-05-2013 at 06:56 AM GMT]

14-05-2013 at 06:56 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : PDF
Next Topic (resize and flip the image) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2013 Andrea Tincaniborder