-
Sep 24th, 2013, 05:06 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] VB.NET Print Object To MS Word Or PDF
Is it in any way possible to take the contents contained in a VS2008 Print object (Graphics and Text) and create either
an MS Word document, PDF File Or A Jpeg image from these contents?
-
Sep 24th, 2013, 05:36 AM
#2
Re: VB.NET Print Object To MS Word Or PDF
Jpeg image, no problem.
MS Word document or PDF File are more complicated
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Sep 24th, 2013, 05:52 AM
#3
Thread Starter
Fanatic Member
Re: VB.NET Print Object To MS Word Or PDF
Thanks .paul jgeg image will suffice, any idea where i can get some help on how to do this?
-
Sep 24th, 2013, 06:01 AM
#4
Re: VB.NET Print Object To MS Word Or PDF
ok. show me your print code + i'll show you how to create a jpeg from that.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Sep 24th, 2013, 06:18 AM
#5
Re: VB.NET Print Object To MS Word Or PDF
If you want a PDF you can install CUTEPDF - it's free - and it appears as a "printer" on the machine.
Now you can create a PDF as simple as printing to an actual printer.
-
Sep 24th, 2013, 08:51 AM
#6
Thread Starter
Fanatic Member
Re: VB.NET Print Object To MS Word Or PDF
Hi .paul
Here is a shortened version of the print code:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'This Is where The Printing Takes Place
'Print The Graphics Image onto the page
'--------------------------------------
Dim Img As Image = Image.FromFile(Application.StartupPath & "\Graphics\" & Doc_GraphicsImageToPrint)
Dim UlCorner As New Point(0, 0)
e.Graphics.DrawImage(Img, UlCorner)
Dim PrintFont As New Font("Arial", 12,FontStyle.Bold, GraphicsUnit.Pixel, Nothing)
For I = 1 to Grid.Rows-1
e.Graphics.DrawString(Grid.Cell(I,1).Text, PrintFont, Brushes.Black,Grid.Cell(I,2).Text, Grid.Cell(I,3).Text)
Next
End Sub
-
Sep 24th, 2013, 08:55 AM
#7
Thread Starter
Fanatic Member
Re: VB.NET Print Object To MS Word Or PDF
Hi szlamany
Thanks for your reply, i have something similar called PDF24 which works well.
The problem is that users are complaining that they have to first select the printer, then create the PDF and then save it and only then can they e mail it.
What i am hoping to achieve is if they don't want to print the page but rather e mail it directly then the user clicks on a button, the page is then transformed into a PDF
or jpeg file which the program can now automatically attach to an e mail and send it directly
-
Sep 24th, 2013, 09:08 AM
#8
Re: VB.NET Print Object To MS Word Or PDF
Yeah - I know the problem. Selecting a file name "programatically" for a printed PDF can be a real chore - I've faced that myself.
If jpg works for you - then that might be the best choice. I've not done that myself - I'm sure someone will come along with some code for doing that...
Last edited by szlamany; Sep 24th, 2013 at 10:32 AM.
-
Sep 26th, 2013, 12:22 AM
#9
Thread Starter
Fanatic Member
Re: VB.NET Print Object To MS Word Or PDF
Hi all .paul said that this was possible in jpeg format, does anyone have any idea as to how i could do this?
-
Sep 26th, 2013, 10:10 AM
#10
Re: VB.NET Print Object To MS Word Or PDF
Code:
Private Sub PrintToJPeg()
Dim pd As New Printing.PrintDocument
Dim outputImg As New Bitmap(pd.DefaultPageSettings.Bounds.Width, pd.DefaultPageSettings.Bounds.Height)
Dim gr As Graphics = Graphics.FromImage(outputImg)
gr.Clear(Color.White)
'This Is where The Printing Takes Place
'Print The Graphics Image onto the page
'--------------------------------------
Dim Img As Image = Image.FromFile(Application.StartupPath & "\Graphics\" & Doc_GraphicsImageToPrint)
Dim UlCorner As New Point(0, 0)
gr.DrawImage(Img, UlCorner)
Dim PrintFont As New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Pixel, Nothing)
For I = 1 To Grid.Rows - 1
gr.DrawString(Grid.Cell(I, 1).Text, PrintFont, Brushes.Black, Grid.Cell(I, 2).Text, Grid.Cell(I, 3).Text)
Next
outputImg.Save("filename", Drawing.Imaging.ImageFormat.Jpeg)
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Sep 27th, 2013, 01:15 AM
#11
Thread Starter
Fanatic Member
Re: VB.NET Print Object To MS Word Or PDF
Hi .paul
Many thanks for your reply, it works very well, Cheers have a good weekend
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|