Page 1 of 2 12 LastLast
Results 1 to 40 of 43

Thread: [RESOLVED] Fancy Printing

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Resolved [RESOLVED] Fancy Printing

    Ive searched the forums but i cant come up with anything helpful enough to solve my problem.

    Ive got a program that does all kinds of things, but now i gotta take all the options and values and everything and make one nice big fancy report for my program to print out. But the thing is, most of what i find is just printing your VB Form or a text file.. This form i print will have lines, boxes, pictures, different size text, colors, all kinds of things, and i wanna be able to print draft, normal, and high quality.

    I cant seem to find something suitable for this, i guess mostly because my first problem is i dont know if i need to have my program create an HTML file, or a word document or just create it the way its gonna look on a form.. Im just so lost! Ahh!!!

    Any ideas for either problem here?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Fancy Printing

    I would start with dumping the contents to a Word document or Excel spreadsheet and let them deal with the formatting and printing.

    The app I'm currently working on has about 60 reports to it and I dump them all to Excel, and my users can do whatever they wish to them prior to printing. (This was a program spec but I liked the way it turned out....far less coding for me. )

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Well, i like the idea but the process has to be nearly instant. They gotta click a button that says "Process Forms" and then up comes the report, then they choose Draft, Normal, or HQ and then Print and there done..

    The people using this program are complete retards (not literally), so it cant be too complicated... Now if i could create it as a word document inside a control on a form and stick those buttons on there, that would work pretty good.

    But i dunno how hard thats gonna be...

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Fancy Printing

    All of my reports have a criteria screen where the user selects what they want and how they want it. Once they are done selecting, the click OK and based on their selections I create a SQL query, retrieve the data from by database, create a recordset, create an Excel spreadsheet out of the ether (I'm not using precreated templates, but that might be something you would want to investigate), and port the entire recordset over the the spreadsheet.

    The speed at which it runs depends on the criteria selected so it varies.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Sounds promising, do you have any code snipets or links that could help me out? I dont know any SQL or how to export to excel or word or anything.

    There's going to be a template, and it needs to import the information into the template, including a few pictures too.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Fancy Printing

    I have used wordpad instead of Word or Excel as it allows the end user to not be required to have either installed and wordpad comes free with windows. What you could also do is check for Office being installed and if not use wordpad. Using any of the Office apps will slow down the print queueing process. So for the faster method, use wordpad.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Quote Originally Posted by RobDog888
    I have used wordpad instead of Word or Excel as it allows the end user to not be required to have either installed and wordpad comes free with windows. What you could also do is check for Office being installed and if not use wordpad. Using any of the Office apps will slow down the print queueing process. So for the faster method, use wordpad.

    That was a something i was thinking about, a problem that could easily come about with this program, but again... how?

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Fancy Printing

    Just shell or shellexecute your desired file to be printed with write.exe and you will be in business. Getting pictures in it is a little more tricky but write does support them. Use a rtf file format for the most ease.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Well to do that, i have to create the file at runtime. Thats the first problem... I can do this with HTML since there's no encoding at all, just tags.. I could make the template in Frontpage, and make the program write the file and add in whats needed as it goes, its fairly simple i guess, but the printing part sucks...


    Doing it in Wordpad or Word or Excel would be much nicer, but how do i take the value's of my controls and write out a temp file for Word, Wordpad, or Excel to print?

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Fancy Printing

    Yes, the office apps would need something to display after they are opened either for printing or for display. This will be where your biggest time delay will occur.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    For this part of the program i really dont mind if it takes a few seconds to load.. As long as its not several minutes, but the report needs to look nice, and print nicely, and be easy to use...

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Fancy Printing

    Then which are you going to use? Excel or Word? Word may be easier since if you create a rtf document and they dont have word instanned (after you check for this) then you can just output to wordpad. With Excel you would have to create a csv file and then the images would be a problem.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Well then that eliminates Excel.

    Since all computers have wordpad on it but not Word, i think right now Word would be the best choice.

    So lets go with that, see what we can do

  14. #14
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Fancy Printing

    Why not use Crystal Reports to print ?

    Or, why not print on the printer object ?
    You know.. like:
    VB Code:
    1. Printer.Print "Hello world !"
    2. ' etc...
    3. Printer.EndDoc

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Well here's the thing... I know nothing about Crystal Reports, SQL, or exporting files to another file format other then a standard text file..

    I cant use Printer.Print becuase it doesnt allow me to customize a page properly with pictures and text and everything..

    Is there any way to make it as simple as loading everything onto a picture box and printing the picturebox on a full page, with custom settings? That would be easiest i think

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Fancy Printing

    Because its allot more work to print an image using the printer object. Plus it doesnt come out as nice. What if the user wanted a print preview?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Fancy Printing

    Yes, you can print easier if you placed everything to be printed in a picturebox.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Thats kinda what i need, a Print Preview.. I want the user to be able to see whats being printed first.. When they goto the Contract section, its going to show all the information. They need to double check it to make sure its all correct, then choose draft, normal, HQ, and print it..

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Quote Originally Posted by RobDog888
    Yes, you can print easier if you placed everything to be printed in a picturebox.
    How do i print the picturebox? Will it print all the pictures and everything the way it looks at runtime? And how do i make it scale itself to a full piece of paper, that way its not some little box of stuff on a piece of paper.

  20. #20
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Fancy Printing

    Quote Originally Posted by PMad
    I cant use Printer.Print becuase it doesnt allow me to customize a page properly with pictures and text and everything..
    You can print on the printer object just like you print in a picturebox.... you can put text & pictures

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Printer.Print PictureBox1


    like that?

  22. #22
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Fancy Printing

    something like this:
    VB Code:
    1. Printer.PaintPicture Picture1.Image, 0, 0
    2.     ' or...
    3.     Printer.PaintPicture Picture1.Picture, 0, 0
    See the other options of PaintPicture if you want to position the picture in a specific place or resize the picture...

  23. #23

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    ok, so everything i put on the Picture box will count as the .Image?

    doing that will print all labels, textboxes, pictures, and everything else i put into the picturebox?

  24. #24
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Fancy Printing

    If you load a jpeg, then it will be in the .Picture, if you draw in the picturebox, then it will be in the .Image

    Do you want to print the actual text box, or the data in it ?
    Do you want it to look exactly like a form ? (if yes, then why not just use the .PrintForm property ?)

  25. #25

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    I dont want it to look exactly like the form. Like the title of this thread, its gonna be a fancy looking report. If i print a form the way it looks, its gonna come out really weird.

  26. #26
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Fancy Printing

    As I was saying before... if you can draw it in a picture box, then you can draw it in the printer object... you can draw anything that you want on it... there is no limit...

  27. #27

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    So if i use labels, lines, boxes, and pictures inside a picture box, i can print the main picturebox and it will print the contents?

  28. #28

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Ok im gonna try out using 'Printer'...

    But i have a question. How do i tell it which device to use over a network? How can i give the user a choice, and select a default?

    Each time i try it i get the error 'Argument not optional' and it highlights '.PaintPicture'

  29. #29

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    ok i put the ',0 ,0' after the image, and it sent it to the default printer im guessing.. But it just sits there and says "Spooling"... wont print anything..

    Ok it finally printed.. But its a blank page, i have a picture, a couple labels, a check box, and a line in the picturebox... But it prints a blank page...

  30. #30
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Fancy Printing

    Quote Originally Posted by CVMichael
    Why not use Crystal Reports to print ?

    Or, why not print on the printer object ?
    You know.. like:
    VB Code:
    1. Printer.Print "Hello world !"
    2. ' etc...
    3. [B]Printer.EndDoc[/B]
    See the bolded line

  31. #31

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    ok i spent some more time searching through the forums, and here's what i found out from this thread: http://www.vbforums.com/showthread.php?t=441226

    Apparently trying to put controls into a picturebox and then printing them all cant be done, atleast thats what i got from that thread. So i started trying things that were said in that thread.

    Instead i have a new form load up, and it prints the form using .PrintForm

    The problem im having is, im trying to print something thats going to take up the entire page, with very little borders, about 1/4" on all sides, the rest of the paper will be filled with information.

    The problem is the borders on the top and left are perfect, but the right side and bottom arent.. So i messed with it some more and i got the border on the right correct, but now the bottom wont size up.

    The window can not get big enough to take up the bottom portion of the paper when printed. So reading on, i found this code:

    VB Code:
    1. Dim XZoom As Single, YZoom As Single
    2.    
    3. XZoom = 100 * Printer.Width / frmPrinterPage1.ScaleWidth
    4. YZoom = 100 * Printer.Height / frmPrinterPage1.ScaleHeight
    5.  
    6. If XZoom < YZoom Then
    7.     Printer.Zoom = XZoom
    8. Else
    9.     Printer.Zoom = YZoom
    10. End If
    11.  
    12. frmPrinterPage1.PrintForm

    Only problem is thats not working, but it worked for the people on that thread.... I must be doing something wrong?

    Now im trying to figure out the form width and form height i need, then put the template on there, which will be finished up by code on the main form, and then printed.

    But i cant figure it out, doesnt want to work for me

  32. #32

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    anybody got any ideas on how to do this?

    Or can anybody make some quick form that works and upload it here so i can look at it and get that same thing going in my project...?

    This is the very last thing i have to deal with and then my project is done! Finally! But this is being the biggest pain, and its the most important of all

  33. #33
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Fancy Printing

    Try making the width of the form smaller, or the height bigger...
    Zoom does what it says it does, it changes the width and height to fit the page, but if your width and height is not the same ratio as the page, then it will fit only one side width or height...

  34. #34

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    I thought of that already..

    Before i used .Zoom, i was getting the width right but not the height. I had extended the window to the maximum height but it wouldnt go, so i typed in a custom number which was around 17000, and it worked for 1 print.. After that it would continuously limit the height to around 13500 even if i had a bigger number typed in.

    Then i started using the .Zoom, i made the width and height alot smaller, and it printed out as if i didnt use .Zoom.

    The code im using for .Zoom should scale it to fit the page keeping the same aspect ratio. Which means regardless of what i do, the width or the height should be correct, and i can adjust from there to get the right size but it doenst do that. Instead i got 3~4 inch borders on the bottom and the right...

  35. #35
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Fancy Printing

    I did work it out. Have a look at this solution. It's not too difficult but I wouldn't be surprised there's an easier way.

  36. #36

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    Quote Originally Posted by sgrya1
    I did work it out. Have a look at this solution. It's not too difficult but I wouldn't be surprised there's an easier way.
    I mentioned that thread you started before that earlier. Ive downloaded the project you made but it doesnt work the way i need it too. I added a picturebox and it wouldnt print the picture inside the box, only the border around the picture.

    I have 4~6 pictures that will need to be printed out. The rest is labels, lines, and a few grids.

    Also when looking at your project, im a little confused because im 100% Newbie to the printing portion of VB. Its hard to understand all the coding in your program. It printed out the paper in Landscape, i cant do it landscape.

  37. #37
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Fancy Printing

    The project has one main picturebox that gets sent to the printer. For some reason some controls within that picturebox (other pictureboxes, frames and flexgrids are examples) don't seem to get sent with it so you have to do them each seperately.
    Ie paint each picturebox to another invisible picturebox and send an image of that invisible picturebox to the printer.

    These lines in the project check whether the output should be in portrait or landscape. Disable the landscape option if you just want portrait.

    VB Code:
    1. ' Determine if picture should be printed in landscape
    2. ' or portrait and set the orientation.'
    3. If Pic.Height >= Pic.Width Then
    4.     Prn.Orientation = vbPRORPortrait   'Taller than wide
    5. Else
    6.     Prn.Orientation = vbPRORLandscape  'Wider than tall
    7. End If '

  38. #38

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: Fancy Printing

    So for each picture i need to add, i have to sent it to the printer myself?

    How do i do that? You mentioned putting stuff in an invisible picturebox and sending the invisible picturebox to the printer.. Well what if its just a picturebox itself? Does it still need to go in an invisible picturebox?

  39. #39
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Fancy Printing

    In the example there are 4 pictureboxes. Picture1 is the main picture within the form (the one you use as the extents of the printed page). Picture 3 is an additional picture (you have 6 of these so there'll be a couple more to deal with). Pictures 2 and 4 (located to the right of picturebox 1) are needed to paint images of Pictures 1 and 3 onto (again you'll need another 5 of these).

    The only code you need to manipulate is the PrintNow routine to include painting your additional pictures and sending them to the printer.

    You'll also need the declarations and the PrintPictureToFitPage routine.
    Last edited by sgrya1; Feb 21st, 2007 at 01:16 PM.

  40. #40
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Fancy Printing

    PMad, I mixed up the picturebox numbers in my last post which I've just amended.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width