Link to home
Start Free TrialLog in
Avatar of teogos
teogosFlag for United States of America

asked on

PRINT TO A FILE WITH THE FILE PATH HARDCODED

Visual Studio Power packs on VB.net 2013
I get the form to print to a printer with no problem with the code below

 Dim a As Date
        a = Today.ToString("MM-dd-yy")
        Dim pf As New PrintForm
        pf.Form = Me
        pf.Form.BackColor = Color.White
        pf.Form.Controls.Remove(ListBoxmachines)
        pf.Form.Controls.Remove(bntback)
        pf.Form.Controls.Remove(BNTPRINTEFF)
        pf.PrinterSettings.DefaultPageSettings.Landscape = True
        pf.PrinterSettings.DefaultPageSettings.Margins.Top = 0.5
        pf.PrinterSettings.DefaultPageSettings.Margins.Right = 0.5
        pf.PrinterSettings.DefaultPageSettings.Margins.Left = 0.5
        pf.PrinterSettings.DefaultPageSettings.Margins.Bottom = 0.5
        pf.PrinterSettings.DefaultPageSettings.Landscape = True
        pf.PrinterSettings.Copies = 1
        pf.DocumentName = Today.ToString("MM-dd-yy") & " " & "VSP ROOM"
        pf.Print()
        pf.Form.Controls.Add(ListBoxmachines)
        pf.Form.Controls.Add(bntback)
        pf.Form.Controls.Add(BNTPRINTEFF)




However I want to keep a electronic copy of the file. is there anyway I can print to a file  on PDF format an. I need to save this file  like for example  C:\files
Avatar of Matti
Matti
Flag of Finland image

Hi!

PDF-printers do allow normal set path, but it's double work.

Matti
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of teogos

ASKER

The problem with the BITMAP, is that I do not want to print all the controls on the form, Like CLICK BOTTOMS
Avatar of teogos

ASKER

Matti,  can you provide with some code samples. If this is possible, I just want to save the file. and later if the user wants to print will be his choice once the file is save
>>The problem with the BITMAP, is that I do not want to print all the controls on the form, Like CLICK BOTTOMS

Hide them, save and reshow them.
Avatar of teogos

ASKER

Ok, Got the Form save to an Image with the code below

 Dim bmpScreenshot As Bitmap = New Bitmap(Width, Height, PixelFormat.Format32bppArgb)
        ' Create a graphics object from the bitmap
        Dim a As Date
        a = Today.ToString("MM-dd-yy")
        Dim gfxScreenshot As Graphics = Graphics.FromImage(bmpScreenshot)
        ' Take a screenshot of the entire Form1
        bntback.Visible = False
        Button1.Visible = False
        gfxScreenshot.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, Me.Size, CopyPixelOperation.SourceCopy)
        ' Save the screenshot  
        bmpScreenshot.Save("c:\VSP.Jpeg", ImageFormat.Jpeg)
        bntback.Visible = True
        Button1.Visible = True
        MsgBox("IMAGE SAVE")


But I want to everytime is save  put also the current date along with the image name on this line

bmpScreenshot.Save("c:\VSP.Jpeg", ImageFormat.Jpeg)
 but I can seem to figure out the sintax. I tried
something like this
Dim a As Date
        a = Today.ToString("MM-dd-yy")
bmpScreenshot.Save("c:\VSP.Jpeg& a", ImageFormat.Jpeg)
but does not work
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial