Different Results with Spire.Doc

Technical support for Spire.Doc

Moderator: iceblue support

Different Results with Spire.Doc

Postby skelsey » Mon Jul 22, 2013 4:11 pm

I have created a document that I want to send to a printer. I don't want to save it.
I started with creating the document and saving it and getting the results that I am expecting. When I change my program to just send the document to the printer the formatting is wrong. It is treating the carriage return line feed as a page break. The words are getting cut off around the margin. So instead of printing 2 pages I get 32 pages.

Any help would be appreciated!

Can you tell me why it is reading the crlf as a page break an/or how do I get around this? I tried to upload the word file but was not allowed.

Code: Select all
Private Sub btnSpire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpire.Click

        Dim dt As Orders.OrderDataDataTable
        Dim dr As Orders.OrderDataRow
        Dim da As New OrdersTableAdapters.OrderDataTableAdapter
        Dim i As Integer
        Dim j As Integer = 0
        Dim sOrderID As String = ""
        dt = da.GetOrderData()

        Dim dialog As New PrintDialog()
        dialog.AllowCurrentPage = True
        dialog.AllowSomePages = True
        dialog.UseEXDialog = True
        Dim testDoc As New Document()

        dr = dt.Rows(0)

        addHeader(dr, testDoc)
        addStaticRowHeader(testDoc)
        For i = 0 To dt.Rows.Count - 1

            dr = dt.Rows(i)
            padProduct(dr)
            addOrderData(dr, testDoc)

            j += 1
            'If j = 7 Then
            If j = 6 Then
                iPageNum += 1

                Dim nextPageBody As New Section(testDoc)
                Dim nextPageheaderParagraph As Documents.Paragraph = Nothing

                If nextPageBody.Paragraphs.Count > 0 Then
                    nextPageheaderParagraph = nextPageBody.Paragraphs(0)
                Else
                    nextPageheaderParagraph = nextPageBody.AddParagraph()
                End If
                nextPageBody = testDoc.Sections.LastItem

                nextPageheaderParagraph.AppendBreak(BreakType.PageBreak)

                addHeader(dr, testDoc)
                addStaticRowHeader(testDoc)
                j = 0
            End If

            sOrderID = dr.ORDER_ID
 
        Next i

        testDoc.SaveToFile(My.Application.Info.DirectoryPath & "\" & sOrderID & "TEST.doc", FileFormat.Doc)
        System.Diagnostics.Process.Start(My.Application.Info.DirectoryPath & "\" & sOrderID & "TEST.doc")

        'testDoc.PrintDialog = dialog
        'dialog.Document = testDoc.PrintDocument
        'dialog.Document.PrintController = New StandardPrintController()
        'dialog.Document.Print()

        Application.Exit()

    End Sub

Private Sub addHeader(ByVal dr As Orders.OrderDataRow, ByRef testDoc As Document)

        Dim pageHeader As String
        Dim phoneformatPattern As String = "(\d{3})(\d{3})(\d{4})"
        Dim strFormattedPhone As String
        Dim addy2 As String = ""
        Dim body As Section

        body = testDoc.AddSection()
        body.PageSetup.Orientation = Documents.PageOrientation.Landscape
        body.PageSetup.Margins.Top = 0.25F
        body.PageSetup.Margins.Bottom = 0.5F
        body.PageSetup.Margins.Left = 0.5F
        body.PageSetup.Margins.Right = 0.25F
        body.PageSetup.DefaultTabWidth = 0.5F

        'Create a new paragraph or get the first paragraph
        Dim headerParagraph As Documents.Paragraph = Nothing
        If body.Paragraphs.Count > 0 Then
            headerParagraph = body.Paragraphs(0)
        Else
            headerParagraph = body.AddParagraph()
        End If

        If Not dr.IsSHIP_TO_ADDR2Null Then
            addy2 = dr.SHIP_TO_ADDR2
        End If
        strFormattedPhone = Regex.Replace(Trim(dr.BILL_TO_PHONE_NUM), phoneformatPattern, "$1-$2-$3")

        pageHeader = "     Printed Date    : " & Now.ToString("MM/d/yyyy hh:mm:ss tt") & vbCrLf _
                    & "     Page            : " & padString((iPageNum + 1).ToString(), 42) & "PBN : " & dr.PRT_BATCH_NUM.ToString() & vbCrLf _
                    & "     Order Date      : " & padString(dr.CREATE_DTTIME, 40) & "Phone : " & strFormattedPhone & vbCrLf _
                    & "     Bill To Cust.   : " & dr.BILL_TO_NAME & vbCrLf _
                    & "     Customer        : " & padString(dr.SHOPPER_ID, 40) & "Email : " & dr.SHOPPER_EMAIL_ID & vbCrLf _
                    & "     Ship To Cust.   : " & dr.SHIP_TO_FIRST_NM & " " & dr.SHIP_TO_LAST_NM & vbCrLf _
                    & "     Ship To Address : " & dr.SHIP_TO_ADDR1 & vbCrLf _
                    & "     Ship To Address2: " & addy2 & vbCrLf _
                    & "     Ship To City    : " & dr.SHIP_TO_CITY & " " & dr.SHIP_TO_STATE & ", " & dr.SHIP_TO_ZIP & vbCrLf _
                    & "     Order Number    : " & padString(dr.ORDER_ID, 38) & "Sub Ord : " & dr.SUB_ORDER_ID & vbCrLf
        headerParagraph.AppendText(pageHeader).CharacterFormat.Font = myFont

    End Sub

Private Sub addStaticRowHeader(ByRef testDoc As Document)
        Dim rowDescrip As Section
        Dim statichead As String = ""

        rowDescrip = testDoc.Sections.Item(testDoc.Sections.Count - 1)
        rowDescrip.PageSetup.Orientation = Documents.PageOrientation.Landscape

        rowDescrip.PageSetup.Margins.Top = 0.25F
        rowDescrip.PageSetup.Margins.Bottom = 0.5F
        rowDescrip.PageSetup.Margins.Left = 0.5F
        rowDescrip.PageSetup.Margins.Right = 0.25F
        rowDescrip.PageSetup.DefaultTabWidth = 0.5F

        'Create a new paragraph or get the first paragraph
        Dim rw As Documents.Paragraph = Nothing
        If rowDescrip.Paragraphs.Count > 0 Then
            rw = rowDescrip.Paragraphs.Item(rowDescrip.Paragraphs.Count - 1)
        Else
            rw = rowDescrip.AddParagraph()
        End If

        statichead = "-------------------------------------------------------------------------------------------------------------------" & vbCrLf _
         & Space(5) & "Description" & Space(63) & "Item#" & Space(8) & "Dept#" & Space(4) & "Dept" & vbCrLf _
         & Space(5) & "Class/Sku" & Space(16) & "UPC #" & Space(35) & "Qty" & Space(6) & "Total Price" & vbCrLf _
         & Space(5) & "Color" & Space(10) & "Size" & Space(6) & "MIVenStylNum" & Space(8) & "Attribute 4 Name/Value" & Space(8) & "Attribute 5 Name/Value" & vbCrLf _
         & "-------------------------------------------------------------------------------------------------------------------" & vbCrLf
        rw.AppendText(statichead).CharacterFormat.Font = myFont

    End Sub

    Private Sub addOrderData(ByVal dr As Orders.OrderDataRow, ByRef testDoc As Document)
        Dim orderDescrip As Section
        Dim ordData As String = ""
        Dim secCount As Integer = testDoc.Sections.Count


        orderDescrip = testDoc.Sections.LastItem
        '.Item(0)
        'orderDescrip = testDoc.AddSection
        orderDescrip.PageSetup.Orientation = Documents.PageOrientation.Landscape

        orderDescrip.PageSetup.Margins.Top = 0.25F
        orderDescrip.PageSetup.Margins.Bottom = 0.5F
        orderDescrip.PageSetup.Margins.Left = 0.5F
        orderDescrip.PageSetup.Margins.Right = 0.25F

        orderDescrip.PageSetup.DefaultTabWidth = 0.5F
        'Create a new paragraph or get the first paragraph
        Dim rw As Documents.Paragraph = Nothing
        If orderDescrip.Paragraphs.Count > 0 Then
            rw = orderDescrip.Paragraphs(0)
        Else
            rw = orderDescrip.AddParagraph()
        End If

        insertPictureNEW(dr.SMALL_IMAGE, rw)

        ordData = Space(5) & prdITEMDESC & prdITEMID & prdDEPTNUM & prdDEPTDESC & vbCrLf _
         & Space(5) & prdCLSSKU & prdUPC & prdORDQTY & prdITEMTOTAL & vbCrLf _
         & Space(5) & prdCOLOR & prdSIZE & prdVENSTYLENUM & prdATTR4 & prdATTR5 & vbCrLf _
         & "-------------------------------------------------------------------------------------------------------------------" & vbCrLf

        rw.AppendText(ordData).CharacterFormat.Font = myFont
       

    End Sub

skelsey
 
Posts: 10
Joined: Mon May 06, 2013 1:54 pm

Re: Different Results with Spire.Doc

Postby Gary.zhang » Tue Jul 23, 2013 2:34 am

Hello,

Thanks for your inquiry.
Please provide us the document which you generated with the code, kindly note that you need to zip it and upload, or you could also send it to our Support email as below,
support@e-iceblue.com

Thanks,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1390
Joined: Thu Apr 04, 2013 1:30 am

Re: Different Results with Spire.Doc

Postby Gary.zhang » Wed Jul 31, 2013 9:13 am

Hello,
Sorry for disturbing you again.
Has the issue been resolved? Could you please give us some feedback if convenience? If not, please send us a simple and runable project in our side to help us reproduce the issue, and we will work out the solution for you ASAP.

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1390
Joined: Thu Apr 04, 2013 1:30 am

Re: Different Results with Spire.Doc

Postby skelsey » Wed Jul 31, 2013 11:51 am

I've got it to work! The code is below and the output file is attached. It was just a matter of understanding how the methods work.

Code: Select all
Imports System.ComponentModel
Imports System.Text
Imports Spire.Doc
Imports Spire.Doc.Fields
Imports Spire.Doc.Documents
Imports System.Data.OleDb
Imports ADOR
Imports System.Text.RegularExpressions
Imports System.Net
Imports System.Drawing.Printing


Public Class frmMain

    Private ord As New Orders.OrderDataDataTable
    Dim myFont As New Font("Courier New", 12, FontStyle.Bold)
    Dim iPageNum As Integer = 0
    Dim prdITEMDESC As String = ""
    Dim prdITEMID As String = ""
    Dim prdDEPTNUM As String = ""
    Dim prdDEPTDESC As String = ""
    Dim prdCLSSKU As String = ""
    Dim prdSKUIMS As String = ""
    Dim prdUPC As String = ""
    Dim prdORDQTY As String = ""
    Dim prdITEMTOTAL As String = ""
    Dim prdCOLOR As String = ""
    Dim prdSIZE As String = ""
    Dim prdVENSTYLENUM As String = ""
    Dim prdATTR4 As String = ""
    Dim prdATTR5 As String = ""

    Private Sub btnSpire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpire.Click

        Dim dt As Orders.OrderDataDataTable
        Dim dr As Orders.OrderDataRow
        Dim da As New OrdersTableAdapters.OrderDataTableAdapter
        Dim i As Integer
        Dim j As Integer = 0
        Dim sOrderID As String = ""
        dt = da.GetOrderData()

        Dim dialog As New PrintDialog()
        dialog.AllowCurrentPage = True
        dialog.AllowSomePages = True
        dialog.UseEXDialog = True
        Dim testDoc As New Document()

        dr = dt.Rows(0)

        addHeader(dr, testDoc)
        addStaticRowHeader(testDoc)
        For i = 0 To dt.Rows.Count - 1

            dr = dt.Rows(i)
            padProduct(dr)
            addOrderData(dr, testDoc)

            j += 1
            'If j = 7 Then
            If j = 6 Then
                iPageNum += 1
                Dim nextPageBody As Section
                nextPageBody = testDoc.Sections.LastItem
                Dim nextPageheaderParagraph As Documents.Paragraph = Nothing

                If nextPageBody.Paragraphs.Count > 0 Then
                    nextPageheaderParagraph = nextPageBody.Paragraphs(0)
                Else
                    nextPageheaderParagraph = nextPageBody.AddParagraph()
                End If

                nextPageheaderParagraph.AppendBreak(BreakType.PageBreak)

                addHeader(dr, testDoc)
                addStaticRowHeader(testDoc)
                j = 0
            End If

            sOrderID = dr.ORDER_ID
            'testDoc.SaveToFile(My.Application.Info.DirectoryPath & "\" & sOrderID & "TEST.doc", FileFormat.Doc)

            'testDoc.PrintDialog = dialog
            'testDoc.Document.PrintDocument.DefaultPageSettings.Landscape = True
            'dialog.Document = testDoc.PrintDocument
            'dialog.Document.PrintController = New StandardPrintController()
            'dialog.Document.Print()
        Next i

        testDoc.SaveToFile(My.Application.Info.DirectoryPath & "\" & sOrderID & "TEST.doc", FileFormat.Doc)
        System.Diagnostics.Process.Start(My.Application.Info.DirectoryPath & "\" & sOrderID & "TEST.doc")

        'testDoc.PrintDialog = dialog
        'dialog.Document = testDoc.PrintDocument
        'dialog.Document.PrintController = New StandardPrintController()
        'dialog.Document.Print()

        Application.Exit()

    End Sub

    Public Function LoadWebPicture(ByRef url As String, Optional ByVal timeout As Integer = 100000, Optional ByVal compression As System.Net.DecompressionMethods = DecompressionMethods.None) As System.Drawing.Image

        Const csSUBNAME As String = "LoadWebPicture"

        On Error GoTo ErrorHandler

        Dim img As System.Drawing.Image
        Dim request As Net.HttpWebRequest
        Dim response As Net.HttpWebResponse

        If url = "Not Found" Then
            LoadWebPicture = Nothing
            Exit Function
        End If

        request = DirectCast(Net.HttpWebRequest.Create(url), Net.HttpWebRequest)



        request.AutomaticDecompression = compression

        'Default is 100 seconds
        request.Timeout = timeout

        response = DirectCast(request.GetResponse, Net.HttpWebResponse)

        img = Image.FromStream(response.GetResponseStream())

        response.Close()

        LoadWebPicture = img
        Exit Function

ErrorHandler:
        LoadWebPicture = Nothing

    End Function

    Private Sub insertpic(ByVal strURL As String, ByRef testDoc As Document)
        Dim img As Image = LoadWebPicture(strURL)
        Dim imgSection As Section = testDoc.Sections(0)

        imgSection.PageSetup.Orientation = Documents.PageOrientation.Landscape

        Dim imgPara As Documents.Paragraph = imgSection.AddParagraph()
        Dim orderPic As DocPicture = imgPara.AppendPicture(img)
        imgPara.Format.LeftIndent = 3
        orderPic.HorizontalAlignment = ShapeHorizontalAlignment.Left
        orderPic.VerticalAlignment = ShapeVerticalAlignment.Bottom
        orderPic.WidthScale = 40
        orderPic.HeightScale = 40

    End Sub

    Private Sub insertPictureNEW(ByVal strURL As String, ByRef imgPara As Documents.Paragraph)

        Dim img As Image = LoadWebPicture(strURL)
        Dim orderPic As DocPicture = imgPara.AppendPicture(img)

        imgPara.Format.LeftIndent = -2
       
        orderPic.HorizontalPosition = HorizontalPosition.Right
        orderPic.HorizontalOrigin = HorizontalOrigin.LeftMarginArea
        orderPic.HorizontalAlignment = ShapeHorizontalAlignment.None
        orderPic.VerticalOrigin = VerticalOrigin.Paragraph
        orderPic.VerticalAlignment = ShapeVerticalAlignment.Bottom

        orderPic.TextWrappingStyle = TextWrappingStyle.InFrontOfText

        orderPic.WidthScale = 40
        orderPic.HeightScale = 40

        img.Dispose()

    End Sub

    Private Sub addHeader(ByVal dr As Orders.OrderDataRow, ByRef testDoc As Document)

        Dim pageHeader As String
        Dim phoneformatPattern As String = "(\d{3})(\d{3})(\d{4})"
        Dim strFormattedPhone As String
        Dim addy2 As String = ""
        Dim body As Section
        Dim bmulti As Boolean = False

        If testDoc.Sections.Count > 0 Then
            body = testDoc.Sections.LastItem
        Else
            body = testDoc.AddSection()
        End If

        body.PageSetup.Orientation = Documents.PageOrientation.Landscape
        body.PageSetup.Margins.Top = 17.0F
        body.PageSetup.Margins.Bottom = 17.0F
        body.PageSetup.Margins.Left = 17.0F
        body.PageSetup.Margins.Right = 17.0F
        body.PageSetup.DefaultTabWidth = 0.5F

        'Create a new paragraph or get the first paragraph
        Dim headerParagraph As Documents.Paragraph = Nothing
        If body.Paragraphs.Count > 0 Then
            headerParagraph = body.Paragraphs(0)
        Else
            headerParagraph = body.AddParagraph()
        End If

        If Not dr.IsSHIP_TO_ADDR2Null Then
            addy2 = dr.SHIP_TO_ADDR2
        End If
        strFormattedPhone = Regex.Replace(Trim(dr.BILL_TO_PHONE_NUM), phoneformatPattern, "$1-$2-$3")

        If bmulti Then
            pageHeader = "     Copy            : " & padString("1  of  20", 28) & "** Alvernia Order **" & vbCrLf & "     Printed Date    : " & Now.ToString("MM/d/yyyy hh:mm:ss tt") & vbCrLf
            headerParagraph.AppendText(pageHeader).CharacterFormat.Font = myFont
        Else
            pageHeader = "     Printed Date    : " & padString(Now.ToString("MM/d/yyyy hh:mm:ss tt"), 40) & "** Alvernia Order **"
            headerParagraph.AppendText(pageHeader).CharacterFormat.Font = myFont
        End If
        headerParagraph.AppendText(vbCrLf)

        pageHeader = "     Page            : " & padString((iPageNum + 1).ToString(), 42) & "PBN : " & dr.PRT_BATCH_NUM.ToString() & vbCrLf _
                    & "     Order Date      : " & padString(dr.CREATE_DTTIME, 40) & "Phone : " & strFormattedPhone & vbCrLf _
                    & "     Bill To Cust.   : " & dr.BILL_TO_NAME & vbCrLf _
                    & "     Customer        : " & padString(dr.SHOPPER_ID, 40) & "Email : " & dr.SHOPPER_EMAIL_ID & vbCrLf _
                    & "     Ship To Cust.   : " & dr.SHIP_TO_FIRST_NM & " " & dr.SHIP_TO_LAST_NM & vbCrLf _
                    & "     Ship To Address : " & dr.SHIP_TO_ADDR1 & vbCrLf _
                    & "     Ship To Address2: " & addy2 & vbCrLf _
                    & "     Ship To City    : " & dr.SHIP_TO_CITY & " " & dr.SHIP_TO_STATE & ", " & dr.SHIP_TO_ZIP & vbCrLf _
                    & "     Order Number    : " & padString(dr.ORDER_ID, 38) & "Sub Ord : " & dr.SUB_ORDER_ID & vbCrLf
        headerParagraph.AppendText(pageHeader).CharacterFormat.Font = myFont

    End Sub
    Private Sub addStaticRowHeader(ByRef testDoc As Document)
        Dim rowDescrip As Section
        Dim statichead As String = ""

        'rowDescrip = testDoc.Sections.Item(testDoc.Sections.Count - 1)
        rowDescrip = testDoc.Sections.LastItem
        rowDescrip.PageSetup.Orientation = Documents.PageOrientation.Landscape

        rowDescrip.PageSetup.Margins.Top = 0.25F
        rowDescrip.PageSetup.Margins.Bottom = 0.5F
        rowDescrip.PageSetup.Margins.Left = 0.5F
        rowDescrip.PageSetup.Margins.Right = 0.25F
        rowDescrip.PageSetup.DefaultTabWidth = 0.5F

        'Create a new paragraph or get the first paragraph
        Dim rw As Documents.Paragraph = Nothing
        If rowDescrip.Paragraphs.Count > 0 Then
            'rw = rowDescrip.Paragraphs.Item(rowDescrip.Paragraphs.Count - 1)
            rw = rowDescrip.Paragraphs(0)
        Else
            rw = rowDescrip.AddParagraph()
        End If

        statichead = "-------------------------------------------------------------------------------------------------------------------" & vbCrLf _
         & Space(5) & "Description" & Space(54) & "Item#" & Space(8) & "Dept#" & Space(4) & "Dept" & vbCrLf _
         & Space(5) & "Class/Sku" & Space(16) & "UPC #" & Space(35) & "Qty" & Space(6) & "Total Price" & vbCrLf _
         & Space(5) & "Color" & Space(10) & "Size" & Space(6) & "MIVenStylNum" & Space(8) & "Attribute 4 Name/Value" & Space(8) & "Attribute 5 Name/Value" & vbCrLf _
         & "-------------------------------------------------------------------------------------------------------------------" & vbCrLf
        rw.AppendText(statichead).CharacterFormat.Font = myFont

    End Sub
    Private Sub padProduct(ByVal dr As Orders.OrderDataRow)

        '***Item Description (length = 74)
        prdITEMDESC = padString(dr.ITEM_DESC, 65)

        '***Item ID (length = 13)
        prdITEMID = padString(dr.ITEM_ID, 13)

        '***Department Number (length = 7)
        prdDEPTNUM = padString(dr.DEPT_NUM, 9)

        '***Dept Description (length = 10)
        prdDEPTDESC = padString(dr.DEPT_DESC, 15)
        prdCLSSKU = padString(dr.CLASS_NUM.ToString() & "/" & dr.SKU_IMS_NUM.ToString(), 25)

        '***UPC (length = 40)
        If dr.GR_PRODUCT_ID.Equals("NULL") Then
            prdUPC = Space(40)
        Else
            prdUPC = padString(dr.GR_PRODUCT_ID, 40)
        End If

        '***Quantity (length = 9)
        prdORDQTY = padString(dr.ORDERED_QTY.ToString(), 9)

        '***Item Total (length = 33)
        prdITEMTOTAL = padString(dr.ITEM_TOTAL_AMT.ToString("0.00"), 33)

        '***Color Description (length = 10)
        If dr.CLR_DESC.Length > 15 And dr.CLR_DESC <> "NULL" Then
            prdCOLOR = dr.CLR_DESC.Substring(0, 14)
        ElseIf dr.CLR_DESC.Equals("NULL") Then
            prdCOLOR = Space(15)
        Else
            prdCOLOR = padString(dr.CLR_DESC, 15)
        End If

        '***Size Description (length = 10)
        If dr.SIZE_DESC.Equals("NULL") Then
            prdSIZE = Space(10)
        Else
            prdSIZE = padString(dr.SIZE_DESC, 10)
        End If

        '***Ven_Style_Num (length = 20)
        If dr.VEN_STYL_NUM.Equals("NULL") Then
            prdVENSTYLENUM = Space(20)
        Else
            prdVENSTYLENUM = padString(dr.VEN_STYL_NUM, 20)
        End If

        '***Attribute 4 (length = 30)
        If dr.ATTR_FOUR_NAME.Equals("NULL") And dr.ATTR_FOUR_VALUE.Equals("NULL") Then
            prdATTR4 = Space(30)
        ElseIf Not dr.ATTR_FOUR_NAME.Equals("NULL") And dr.ATTR_FOUR_VALUE.Equals("NULL") Then
            prdATTR4 = padString(dr.ATTR_FOUR_NAME, 30)
        ElseIf dr.ATTR_FOUR_NAME.Equals("NULL") And Not dr.ATTR_FOUR_VALUE.Equals("NULL") Then
            prdATTR4 = padString(dr.ATTR_FOUR_VALUE, 30)
        Else
            prdATTR4 = padString(dr.ATTR_FOUR_NAME & " " & dr.ATTR_FOUR_VALUE, 30)
        End If

        '***Attribute 5 (length = 30)
        If dr.ATTR_FIVE_NAME.Equals("NULL") And dr.ATTR_FIVE_VALUE.Equals("NULL") Then
            prdATTR5 = Space(30)
        ElseIf Not dr.ATTR_FIVE_NAME.Equals("NULL") And dr.ATTR_FIVE_VALUE.Equals("NULL") Then
            prdATTR5 = padString(dr.ATTR_FIVE_NAME, 30)
        ElseIf dr.ATTR_FIVE_NAME.Equals("NULL") And Not dr.ATTR_FIVE_VALUE.Equals("NULL") Then
            prdATTR5 = padString(dr.ATTR_FIVE_VALUE, 30)
        Else
            prdATTR5 = padString(dr.ATTR_FIVE_NAME & " " & dr.ATTR_FIVE_VALUE, 30)
        End If

    End Sub
    Private Sub addOrderData(ByVal dr As Orders.OrderDataRow, ByRef testDoc As Document)
        Dim orderDescrip As Section
        Dim ordData As String = ""
        Dim secCount As Integer = testDoc.Sections.Count


        orderDescrip = testDoc.Sections.LastItem
        '.Item(0)
        'orderDescrip = testDoc.AddSection
        orderDescrip.PageSetup.Orientation = Documents.PageOrientation.Landscape

        orderDescrip.PageSetup.Margins.Top = 0.25F
        orderDescrip.PageSetup.Margins.Bottom = 0.5F
        orderDescrip.PageSetup.Margins.Left = 0.5F
        orderDescrip.PageSetup.Margins.Right = 0.25F

        orderDescrip.PageSetup.DefaultTabWidth = 0.5F
        'Create a new paragraph or get the first paragraph
        Dim rw As Documents.Paragraph = Nothing
        If orderDescrip.Paragraphs.Count > 0 Then
            rw = orderDescrip.Paragraphs(0)
        Else
            rw = orderDescrip.AddParagraph()
        End If

        insertPictureNEW(dr.SMALL_IMAGE, rw)

        'Dim len As Integer = 74 - dr.ITEM_DESC.Length
        'Dim lenClass As Integer = 25 - (dr.CLASS_NUM.ToString.Length + dr.SKU_IMS_NUM.ToString.Length)
        'Dim clr As String = ""
        'Dim lenClr As Integer = 0
        'If dr.CLR_DESC.Length > 15 Then
        '    clr = dr.CLR_DESC.Substring(0, 14)
        '    lenClr = 1
        'Else
        '    clr = dr.CLR_DESC
        '    lenClr = 15 - dr.CLR_DESC.Length
        'End If

        'Dim lenUPC As Integer = 0
        'Dim UPC As String = ""
        'If dr.IsGR_PRODUCT_IDNull Then
        '    lenUPC = 40
        'Else
        '    lenUPC = 40 - dr.GR_PRODUCT_ID.ToString.Length
        '    UPC = dr.GR_PRODUCT_ID
        'End If

        'Dim lenqty As Integer = 9 - dr.ORDERED_QTY.ToString.Length
        'Dim lenStyl As Integer = 20 - dr.VEN_STYL_NUM.Length
        'Dim lenAtt4 As Integer = 29 - (dr.ATTR_FOUR_NAME.Length + dr.ATTR_FOUR_VALUE.Length)

        'ordData = Space(5) & dr.ITEM_DESC & Space(len) & dr.ITEM_ID & Space(8) & dr.DEPT_NUM & Space(4) & dr.DEPT_DESC & vbCrLf _
        ' & Space(5) & dr.CLASS_NUM & dr.SKU_IMS_NUM & Space(lenClass) & UPC & Space(lenUPC) & dr.ORDERED_QTY & Space(lenqty) & dr.ITEM_TOTAL_AMT.ToString("0.00") & vbCrLf _
        ' & Space(5) & clr & Space(lenClr) & dr.SIZE_DESC & Space(6) & dr.VEN_STYL_NUM & Space(lenStyl) & dr.ATTR_FOUR_NAME & " " & dr.ATTR_FOUR_VALUE & Space(lenAtt4) & dr.ATTR_FIVE_NAME & " " & dr.ATTR_FIVE_VALUE & vbCrLf _
        ' & "-------------------------------------------------------------------------------------------------------------------"

        ordData = Space(5) & prdITEMDESC & prdITEMID & prdDEPTNUM & prdDEPTDESC & vbCrLf _
         & Space(5) & prdCLSSKU & prdUPC & prdORDQTY & prdITEMTOTAL & vbCrLf _
         & Space(5) & prdCOLOR & prdSIZE & prdVENSTYLENUM & prdATTR4 & prdATTR5 & vbCrLf _
         & "-------------------------------------------------------------------------------------------------------------------" & vbCrLf

        rw.AppendText(ordData).CharacterFormat.Font = myFont

       

    End Sub

    Private Function padString(ByVal strValue As String, ByVal iMaxLen As Integer) As String
        Dim finalpaddedstring As String = ""
        Dim i As Integer
        Dim iLen As Integer = strValue.Length
        Dim iPadLen As Integer = iMaxLen - iLen


        For i = 1 To iPadLen
            finalpaddedstring = finalpaddedstring & Space(1)
        Next

        finalpaddedstring = strValue & finalpaddedstring

        Return finalpaddedstring

    End Function
    Private Sub PrintME() 'ByVal tmpDoc As String)
        Dim dialog As New PrintDialog()
        Dim result As DialogResult = dialog.ShowDialog()

        dialog.AllowCurrentPage = True
        dialog.AllowSomePages = True
        dialog.UseEXDialog = True

        If result = DialogResult.OK Then
            Try

                'dv.PrintDialog = dialog
                'dialog.Document = dv.PrintDocument
                'dv.PrintDocument.DefaultPageSettings.Landscape = True
                dialog.Document.PrintController = New StandardPrintController()
                dialog.Document.Print()

            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try

        End If

    End Sub

End Class
You do not have the required permissions to view the files attached to this post.
skelsey
 
Posts: 10
Joined: Mon May 06, 2013 1:54 pm


Return to Spire.Doc

Who is online

Users browsing this forum: No registered users and 1 guest