Printing Powerpack

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 2752 Views - Last Post: 05 January 2012 - 11:33 PM Rate Topic: -----

#1 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 131
  • Joined: 02-January 12

Printing Powerpack

Posted 04 January 2012 - 03:59 PM

Hi

I am using the VB.Net printing powerpack to emulate the old Printer.Print from VB6.
The printed output sent to a pdf doc via cutepdfwriter looks ugly/strange.
I have attached the output as document.pdf.

Any ideas why it looks like this?

Attached File(s)


Is This A Good Question/Topic? 0
  • +

Replies To: Printing Powerpack

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,507
  • Joined: 16-March 11

Re: Printing Powerpack

Posted 04 January 2012 - 04:13 PM

This is the link I found that helped me print pdfs when I needed it some time ago.

Link

I know it doesn't answer your question, just thought I'd share. Good luck sir.
Was This Post Helpful? 0
  • +
  • -

#3 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Printing Powerpack

Posted 04 January 2012 - 04:50 PM

Are you trying to print data to a PDF file, is that it?
Just a question - does your PDF printer show up as a regular printer in print dialogs? If so you could use a PrintDocument and a PrintDialog.
Was This Post Helpful? 0
  • +
  • -

#4 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 131
  • Joined: 02-January 12

Re: Printing Powerpack

Posted 04 January 2012 - 04:59 PM

Yes, CutePDF Writer acts like a normal printer (sans paper) and does appear in the PrintDialog.
If I print the same data from VB6 it looks perfect.
Was This Post Helpful? 0
  • +
  • -

#5 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Printing Powerpack

Posted 04 January 2012 - 05:02 PM

Curious - what are you trying to print? Excel document, RichtextBox?
Was This Post Helpful? 0
  • +
  • -

#6 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 131
  • Joined: 02-January 12

Re: Printing Powerpack

Posted 04 January 2012 - 05:16 PM

Hmmm. I tnink it has to do with this:

Printer.fontname = "Arial"



No matter what i put between quotes it prints the same font.

Trying to print my own data like this...
Printer.Write(TAB(prntset), "Debtor Name")
        prntset = prntset + 30
        Printer.Write(TAB(prntset), "Invoice No.")
        prntset = prntset + 14


        Printer.Write(TAB(prntset), "Inv. Date")

        prntset = prntset + 12


        Printer.Write(TAB(prntset), "Bal. Owing")


Was This Post Helpful? 0
  • +
  • -

#7 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Printing Powerpack

Posted 04 January 2012 - 05:23 PM

Err... Did it work?

Also, I'd be surprised if you put Printer.FontName = "Arial". Don't you need to specify a font, not a string? To me it seems you would do this:
Printer.Font = New System.Drawing.Font("Arial", emSize As Single, FontStyle As System.Drawing.FontStyle)

emSize As Single -> where you specify the size of the text
FontStyle As System.Drawing.FontStyle -> specify Bold, Italic, Underline, Strikeout or regular.
Was This Post Helpful? 1
  • +
  • -

#8 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 131
  • Joined: 02-January 12

Re: Printing Powerpack

Posted 04 January 2012 - 08:19 PM

Thanks for that mate. I did manage to find that myself on the MSDN website but it sure shows that you know what you're talking about.
Anyway it's going OK now EXCEPT for the look of the printed page; check out the difference between VB6 and .Net...
Also check out the massive difference in file size???
The .Net printing looks like a printer with a gummed up inkjet nozzle.

Attached File(s)

  • Attached File  vbNet.pdf (98.4K)
    Number of downloads: 104
  • Attached File  VB6.pdf (12.05K)
    Number of downloads: 65

Was This Post Helpful? 0
  • +
  • -

#9 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Printing Powerpack

Posted 04 January 2012 - 08:24 PM

Yeah... 90kb to 10kb is a big difference.
Also, I noticed the difference in text thickness (going from thick to very thin)
Also, the VB6 version didn't have any space between the heading and the values in the cells.
Was This Post Helpful? 0
  • +
  • -

#10 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 131
  • Joined: 02-January 12

Re: Printing Powerpack

Posted 04 January 2012 - 08:31 PM

The heading difference is just me fiddling about with the layout. Not an issue.
Was This Post Helpful? 0
  • +
  • -

#11 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Printing Powerpack

Posted 04 January 2012 - 08:32 PM

Can you post both of your codes (VB.Net and VB6)?
Was This Post Helpful? 0
  • +
  • -

#12 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 131
  • Joined: 02-January 12

Re: Printing Powerpack

Posted 04 January 2012 - 08:47 PM

VB6
Dim prntAction As actions_taken
totOriginalAmt = 0
totBalances = 0

If TypeOf wheretoprnt Is frmrepgen Then Exit Sub

If TypeOf wheretoprnt Is frmreportview Then
  form_hite& = (maxsrchrec * 215) + 1000
  frmreportview.Height = form_hite&
End If



wheretoprnt.PSet (0, 0)
wheretoprnt.ScaleMode = 6
wheretoprnt.FontName = "Times New Roman"
wheretoprnt.FontSize = 9

prntset = 5

wheretoprnt.Print Tab(prntset); "Debtor Name";
prntset = prntset + 30
wheretoprnt.Print Tab(prntset); "Invoice No.";
prntset = prntset + 14
wheretoprnt.Print Tab(prntset); "Inv. Date";
prntset = prntset + 12
wheretoprnt.Print Tab(prntset); "Bal. Owing";
prntset = prntset + 14
If chkdisp(0).Value = 1 Then
    wheretoprnt.Print Tab(prntset); "Orig. Amt";
    prntset = prntset + 14
End If

If chkdisp(1).Value = 1 Then
    wheretoprnt.Print Tab(prntset); "Last Action";
    prntset = prntset + 21
End If

If chkdisp(2).Value = 1 Then
    wheretoprnt.Print Tab(prntset); "Date";
    prntset = prntset + 11
End If

If chkdisp(3).Value = 1 Then
    wheretoprnt.Print Tab(prntset); "Contract";
    prntset = prntset + 12
End If

If chkdisp(4).Value = 1 Then
    wheretoprnt.Print Tab(prntset); "Notes";
    prntset = prntset + 100
End If

wheretoprnt.Print

pp = -1
For n = 1 To maxsrchrec
  pagecount = pagecount + 1
  pp = pp + 1
  Get #1, holdrec(searchcount, n), reportData
  prntset = 5
  If TypeOf wheretoprnt Is frmreportview Then
    If pp = 0 Then
       frmreportview.cmdShow(pp).Tag = holdrec(searchcount, n)
    Else
       Load frmreportview.cmdShow(pp)
       frmreportview.cmdShow(pp).Visible = True
       frmreportview.cmdShow(pp).Top = frmreportview.cmdShow(pp - 1).Top + 3.7
       frmreportview.cmdShow(pp).Tag = holdrec(searchcount, n)
    End If
  End If
  
  wheretoprnt.Print Tab(prntset); RTrim$(reportData.surname); ", "; Left$(reportData.name, 1);
  prntset = prntset + 30
  wheretoprnt.Print Tab(prntset); RTrim$(reportData.invoice_number);
  prntset = prntset + 14
  wheretoprnt.Print Tab(prntset); Format$(reportData.inv_date, "DDMmmYY");
  prntset = prntset + 12
  wheretoprnt.Print Tab(prntset); Format$(reportData.inv_balance, "####0.00");
  prntset = prntset + 14
  
  totBalances = totBalances + reportData.inv_balance
  If chkdisp(0).Value = 1 Then
    wheretoprnt.Print Tab(prntset); Format$(reportData.inv_amount, "####0.00");
    prntset = prntset + 14
    totOriginalAmt = totOriginalAmt + reportData.inv_amount
  End If
  
  
  If chkdisp(1).Value = 1 Then
    If reportData.numof_action_records <> 0 Then
        lastActionRec = reportData.action_records(reportData.numof_action_records)
        Get #2, lastActionRec, prntAction
    End If
    wheretoprnt.Print Tab(prntset); Trim$(prntAction.action);
    prntset = prntset + 21

    
  End If


  If chkdisp(2).Value = 1 And chkdisp(1).Value = 1 Then
     wheretoprnt.Print Tab(prntset); Format$(prntAction.act_date, "DDMmmYY");
     prntset = prntset + 11
  End If

  If chkdisp(3).Value = 1 Then
     wheretoprnt.Print Tab(prntset); reportData.contract;
     prntset = prntset + 12
  End If

  If chkdisp(4).Value = 1 And chkdisp(1).Value = 1 Then
     wheretoprnt.Print Tab(prntset); Trim$(prntAction.comment);
     prntset = prntset + 100
  End If

If TypeOf wheretoprnt Is Printer Then
  If pagecount = 55 Then
     Printer.NewPage
     Printer.Print
     Printer.Print
     pagecount = 0
  End If
End If

Next n

wheretoprnt.Print
wheretoprnt.Print Tab(5); "Number of Records:  "; maxsrchrec;

wheretoprnt.Print Tab(63); "Total OutStanding: ";
wheretoprnt.Print Tab(91); Format$(totBalances, "$#0.00");

If chkdisp(0).Value = 1 Then
   wheretoprnt.Print Tab(120); "Total of Original Debt:";
   wheretoprnt.Print Tab(157); Format$(totOriginalAmt, "$#0.00");
End If

If TypeOf wheretoprnt Is Printer Then wheretoprnt.EndDoc

If TypeOf wheretoprnt Is frmreportview Then
  frmrepgen.Hide
  mesage.Visible = False
End If



VB.Net
 Dim Printer As New VBP.Printer
        Dim lastActionRec As Short
        Dim pagecount As Short
        Dim prntAction As actions_taken

        Dim currHZ As Single

        totOriginalAmt = 0
        totBalances = 0
        Printer.ScaleMode = 6  'mm

        Printer.Orientation = 2

        Printer.Font = New Font("Times New Roman", 9)


        currHZ = 5

        'Printer.PSet(0, 0)

        Printer.CurrentX = currHZ
        Printer.Write("Debtor Name")
        currHZ += 35
        Printer.CurrentX = currHZ

        Printer.Write("Invoice No.")
        currHZ += 20
        Printer.CurrentX = currHZ

        Printer.Write("Inv. Date")

        currHZ += 20
        Printer.CurrentX = currHZ

        Printer.Write("Bal. Owing")
        currHZ += 20
        Printer.CurrentX = currHZ

        If chkdisp_0.CheckState = 1 Then
            Printer.Write("Orig. Amt")
            currHZ += 20
            Printer.CurrentX = currHZ

        End If


        Printer.Write("Last Action")
        currHZ += 40
        Printer.CurrentX = currHZ

        Printer.Write("Date")
        currHZ += 20
        Printer.CurrentX = currHZ


        If chkdisp_1.CheckState = 1 Then
            Printer.Write("Contract")
            Printer.CurrentX += 20
        End If

        Printer.Print("Notes")

        Printer.Print(" ")


        For n = 1 To maxsrchrec
            'pagecount = pagecount + 1


            FileGet(1, reportData, holdrec(searchcount, n))
            currHZ = 5
            Printer.CurrentX = currHZ
            Printer.Write(RTrim(reportData.surname) & ", " & VB.Left(reportData.name, 1))
            currHZ += 35
            Printer.CurrentX = currHZ

            Printer.Write(RTrim(reportData.invoice_number))
            currHZ += 20
            Printer.CurrentX = currHZ


            Printer.Write(VB6.Format(reportData.inv_date, "DDMmmYY"))
            currHZ += 20
            Printer.CurrentX = currHZ

            Printer.Write(VB6.Format(reportData.inv_balance, "####0.00"))
            currHZ += 20
            Printer.CurrentX = currHZ

            totBalances = totBalances + reportData.inv_balance
            If chkdisp_0.CheckState = 1 Then
                Printer.Write(VB6.Format(reportData.inv_amount, "####0.00"))
                currHZ += 20
                Printer.CurrentX = currHZ

                totOriginalAmt = totOriginalAmt + reportData.inv_amount
            End If


            If reportData.numof_action_records <> 0 Then
                lastActionRec = reportData.action_records(reportData.numof_action_records - 1)
                FileGet(2, prntAction, lastActionRec)
            End If
            Printer.Write(Trim$(prntAction.action))
            currHZ += 40
            Printer.CurrentX = currHZ

            Printer.Write(VB6.Format(prntAction.act_date, "DDMmmYY"))
            currHZ += 20
            Printer.CurrentX = currHZ


            If chkdisp_1.CheckState = 1 Then
                Printer.Write(reportData.contract)
                currHZ += 20
                Printer.CurrentX = currHZ

            End If

            Printer.Print(Trim$(prntAction.comment))


            If pagecount = 55 Then
                Printer.NewPage()
                Printer.Print()
                Printer.Print()
                pagecount = 0
            End If

        Next n

        Printer.Print()

        Printer.Write(TAB(5), "Number of Records:  " & maxsrchrec)

        Printer.Write(TAB(63), "Total OutStanding: ")

        Printer.Write(TAB(91), VB6.Format(totBalances, "$#0.00"))

        If chkdisp_0.CheckState = 1 Then

            Printer.Write(TAB(120), "Total of Original Debt:")

            Printer.Write(TAB(157), VB6.Format(totOriginalAmt, "$#0.00"))
        End If

        Printer.EndDoc()



Was This Post Helpful? 0
  • +
  • -

#13 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Printing Powerpack

Posted 04 January 2012 - 08:55 PM

Hmm… not sure why the fonts aren't formatting right... Could have to do with the scaling level.
About the sizes, not sure either.
Sorry :)
Was This Post Helpful? 0
  • +
  • -

#14 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 131
  • Joined: 02-January 12

Re: Printing Powerpack

Posted 04 January 2012 - 10:37 PM

I've found the problem but it's still baffling it's this line:

Printer.Orientation = 2



Prints fine in Portrait mode and crap in Landscape mode.
Was This Post Helpful? 0
  • +
  • -

#15 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Printing Powerpack

Posted 04 January 2012 - 11:05 PM

What's the data type of the property orientation?
Is it an Integer, Single, String, Double or some kind of Enum?
Type Printer, followed by a dot, and in intellisense click on the orientation property and it should come up with something like: Property Orientation As <datatype>
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2