Logo
My Account |  Site Map | Contact Us  
Welcome Guest Search | Active Topics | Sign In | Register

PDF printing and margins Options
serializer
Posted: Thursday, February 1, 2018 1:27:43 PM
Rank: Advanced Member
Groups: Member

Joined: 5/9/2016
Posts: 42
Hi,

I tried settings margins but it does not reflect on the print out. It always print with 0 margin. I have tried to set values on both;

Code: Visual Basic.NET
Dim pgs As New System.Drawing.Printing.PageSettings()
        pgs.Margins = New System.Drawing.Printing.Margins(psc.MarginLeft, psc.MarginRight, psc.MarginTop, psc.MarginBottom)


and

Code: Visual Basic.NET
Dim ps As New System.Drawing.Printing.PrinterSettings()
     ps.DefaultPageSettings.Margins.Left = psc.MarginLeft
        ps.DefaultPageSettings.Margins.Right = psc.MarginRight
        ps.DefaultPageSettings.Margins.Top = psc.MarginTop
        ps.DefaultPageSettings.Margins.Bottom = psc.MarginBottom


Here is the full code:

Code: Visual Basic.NET
'Create objects for printer and page settings and PrintDocument
        AddHandler EO.Base.Runtime.Exception, AddressOf EOException

        Dim ps As New System.Drawing.Printing.PrinterSettings()

        Dim pgs As New System.Drawing.Printing.PageSettings()

        pgs.Margins = New System.Drawing.Printing.Margins(psc.MarginLeft, psc.MarginRight, psc.MarginTop, psc.MarginBottom)

        ' print range
        Select Case psc.PrintRange
            Case EnmPrintRange.AllPages
                    ' do nothing
            Case EnmPrintRange.CurrentPage
                pgs.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.CurrentPage
            Case EnmPrintRange.Selection
                pgs.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.Selection
            Case EnmPrintRange.SomePages
                pgs.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.Selection
        End Select

        ' add support for printing specific pages
        If psc.SelectedPages IsNot Nothing Then
            Dim selectedPages As String = GetSelectedPages(psc.SelectedPages)
            Dim pages() As String = selectedPages.Split(",".ToCharArray)
        End If

        'Set printer name
        ps.PrinterName = psc.SelectedPrinter

        'Set PageMargins (if required)
        ps.DefaultPageSettings.Margins.Left = psc.MarginLeft
        ps.DefaultPageSettings.Margins.Right = psc.MarginRight
        ps.DefaultPageSettings.Margins.Top = psc.MarginTop
        ps.DefaultPageSettings.Margins.Bottom = psc.MarginBottom

        ' copies
        ps.Copies = psc.NoOfCopies

        pgs.PrinterSettings = ps

        Dim pdfdoc As New PdfDocument(psc.File, psc.Password)

        Dim IsLandscape As Boolean = False
        If pdfdoc.Pages.Count > 0 Then
            IsLandscape = pdfdoc.Pages(0).Size.Width > pdfdoc.Pages(0).Size.Height
        End If

        Select Case psc.PageSettings.PaperOrientation
            Case EnmOrientation.Landscape
                pgs.PrinterSettings.DefaultPageSettings.Landscape = True
            Case EnmOrientation.Portrait
                pgs.PrinterSettings.DefaultPageSettings.Landscape = False
            Case EnmOrientation.Auto
                pgs.PrinterSettings.DefaultPageSettings.Landscape = IsLandscape
        End Select


        Dim mt As EO.Base.ManualTask = pdfdoc.Print(ps, pgs)
        mt.WaitOne()
        RemoveHandler EO.Base.Runtime.Exception, AddressOf EOException
eo_support
Posted: Thursday, February 1, 2018 1:59:29 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,070
Hi,

This appears to be an issue. We are looking into this and will get back to you as soon as we find anything.

Thanks!
serializer
Posted: Tuesday, February 13, 2018 4:21:19 AM
Rank: Advanced Member
Groups: Member

Joined: 5/9/2016
Posts: 42
Have you found any solution. I hope you find it soon as I bough the PDF component especially for printing.
eo_support
Posted: Tuesday, February 13, 2018 10:06:44 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,070
Hi,

Sorry about the delay. We did find what caused the problem but we are still trying the find the solution.

The root of the problem is the PDF print feature relies on the PDF plugin, and some printing settings, including margins are purposely ignored when printing a plugin. The reason is very simple ---- the plugin has its own settings. For example, a PDF page typically already have margins on the page (for example, if you use our HTML to PDF feature to create PDF file, then by default it would have 1 inch margins on all sides). So if the plugin were to honor the printing margins, it would result in double margins and it usually is not what user wanted.

What we are currently looking into is to have a way to allow "double marging" if you really do want that. This means if the PDF page already have a 1 inch margin on the page and you set another 0.5 inch margin for printing, then the final margin will be 1.5 inch. It is not possible for us to override the 1 inch margin the PDF page with the 0.5 margin you specified for printing because the 1 inch margin in the PDF file is not a simple margin settings --- it's just none of the drawing operation in the page choose not to draw in the margin area. The double margin feature can be useful if you wish to enlarge the existing margin in the PDF page. However it does not have much use beyond that.

Thanks!
serializer
Posted: Wednesday, February 14, 2018 4:35:24 AM
Rank: Advanced Member
Groups: Member

Joined: 5/9/2016
Posts: 42
Yes, the double margin could be an option. Right now, the printing is done outside of printer margins for customer so I doubt some default settings are used (text is cut right now).
eo_support
Posted: Thursday, February 15, 2018 1:26:04 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,070
Hi,

Many printer has a "non-printable" area so it can't print to too close to the edge of the paper. This does not mean the program did not honor the margin. If the text in the PDF file is too close to the edge, then it can be cut. In that case the "correct" solution would be to modify the PDF file so that you have enough margin on the page.

Nevertheless, we are still looking into the double margin options to see if it is possible for us to support it.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.