PDF Generating Tool Support Forum

HOME   Login   Register    Search




  Subject: Looking For PD4ML.NET Serve side Header/Footer Display Code
   PostPosted: 15 Feb 2011, 22:58 
Hello PD4ML.NET Support Team,

I did use the Java sample and tried to display page header and footers in PDF generated using an URL. I did created a Generic approach to use it through out my project and Sending the Responses back to the PDF posted page. I did my best to show the headers/Footers in the generated PDF file and failed. Can you please provide me a Sample code which deals with page headers and footers using .NET?

I have attached the sample Code files I did use at my End.

Thanks and Regards,
VA


  Subject: Re: Looking For PD4ML.NET Serve side Header/Footer Display Code
   PostPosted: 16 Feb 2011, 18:11 
Couldn't find a place to attach the documents....


  Subject: Re: Looking For PD4ML.NET Serve side Header/Footer Display Code
   PostPosted: 16 Feb 2011, 20:32 
First, get familiar with 3 ways to define of headers/footers:
html-pdf-faq-f1/pdf-page-headers-footers-definition-options-t41.html

Please take into account, that some of the methods work with PD4ML Pro only.

I've just added Java samples there: C# .NET code should be more-less identical. Let us know if there are still open questions.


  Subject: Re: Looking For PD4ML.NET Serve side Header/Footer Display Code
   PostPosted: 16 Feb 2011, 20:40 
It is not working that way, As I need to the same from service. All you have provided me in the same is doable from Client side. I did check the link you have provided before I post my question.

I have a Generic page which takes page URL as a parameter and produce the pdf.
I will call the Generate PDF method from a page where there is no client side coding is not possible.

Thanks
VA


  Subject: Re: Looking For PD4ML.NET Serve side Header/Footer Display Code
   PostPosted: 16 Feb 2011, 20:51 
As I wrote, there are some new Java samples there since few minutes ago.

OK, PD4ML.NET has PD4Converter.aspx.cs sample, which also takes URL as an parameter.

You need to add to the sample a section like

PD4PageMark footer = new PD4PageMark();
footer.setPageNumberTemplate("page $[page] of $[total]");
footer.setTitleAlignment(PD4PageMark.LEFT_ALIGN);
footer.setPageNumberAlignment(PD4PageMark.RIGHT_ALIGN);
footer.setInitialPageNumber(1);
footer.setPagesToSkip(1);
footer.setFontSize(14);
footer.setAreaHeight(18);	
pd4ml.setPageFooter(footer);

before
pd4ml.render(new Uri(inputUrl), outfile);


  Subject: Re: Looking For PD4ML.NET Serve side Header/Footer Display Code
   PostPosted: 16 Feb 2011, 21:47 
Thank you for your response.

When I do the same as you guided, I am getting below error


A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 174.143.96.38:80


Code:
Public Sub generatePDF(ByVal inputUrl As String, ByVal htmlWidth As Integer, ByVal pageFormat As String, ByVal permissions As Integer, ByVal bookmarks As String, ByVal orientation As String, ByVal insets As String, ByVal fontsDir As String, ByVal outfile As Stream)

            System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture

            Dim pd4ml As New PD4ML()
            If (insets IsNot Nothing) Then
                Dim st As Tokenizer = New Tokenizer(insets, ",")
                Try
                    Dim top As Integer = Int32.Parse(st.NextToken())
                    Dim left As Integer = Int32.Parse(st.NextToken())
                    Dim bottom As Integer = Int32.Parse(st.NextToken())
                    Dim right As Integer = Int32.Parse(st.NextToken())
                    Dim units As String = st.NextToken()
                    Dim ins As Rectangle = New Rectangle(top, left, bottom, right)

                    If ("MM".Equals(units.ToUpper())) Then
                        pd4ml.PageInsetsMM = (ins)
                    Else
                        pd4ml.PageInsets = (ins)
                    End If

                Catch ex As Exception
                    Throw New Exception("Invalid page insets (top, left, bottom, right, units): " & insets)
                End Try
            End If

            pd4ml.HtmlWidth = (htmlWidth)
            If (orientation Is Nothing) Then
                orientation = "portrait"
            End If

            If ("PORTRAIT".Equals(orientation.ToUpper())) Then
                pd4ml.PageSize = PD4Constants.getSizeByName(pageFormat)
            Else
                pd4ml.PageSize = pd4ml.changePageOrientation(PD4Constants.getSizeByName(pageFormat))
            End If

            If (permissions <> -1) Then
                pd4ml.setPermissions("empty", permissions, True)
            End If

            If (bookmarks <> Nothing) Then
                If ("ANCHORS".Equals(bookmarks.ToUpper())) Then
                    pd4ml.generateOutlines(False)
                ElseIf ("HEADINGS".Equals(bookmarks.ToUpper())) Then
                    pd4ml.generateOutlines(True)
                End If
            End If

            If (fontsDir <> Nothing AndAlso fontsDir.Length > 0) Then
                pd4ml.useTTF(fontsDir, True)
            End If

            Dim footer As New PD4PageMark()
            footer.setPageNumberTemplate("page $[page] of $[total]")
            footer.TitleAlignment = PD4PageMark.LEFT_ALIGN
            footer.PageNumberAlignment = PD4PageMark.RIGHT_ALIGN
            footer.InitialPageNumber = 1
            footer.PagesToSkip = 1
            footer.FontSize = 14
            footer.AreaHeight = 100
            pd4ml.PageFooter = footer

            'pd4ml.render(New Uri(inputUrl), outfile)
            'pd4ml.render(New Uri(inputUrl).AbsoluteUri, outfile)
            pd4ml.render(inputUrl, outfile)

        End Sub


I appreciate your further support in this regard.

Thanks
VA


  Subject: Re: Looking For PD4ML.NET Serve side Header/Footer Display Code
   PostPosted: 16 Feb 2011, 21:51 
The message tells your application cannot establish a direct HTTP connection with the host. Are you behind a firewall? Don't you need to define proxy settings?


  Subject: Re: Looking For PD4ML.NET Serve side Header/Footer Display Code
   PostPosted: 16 Feb 2011, 22:55 
Nope. It used to work before I added the footer code you have provided me. Thank you.


  Subject: Re: Looking For PD4ML.NET Serve side Header/Footer Display Code
   PostPosted: 17 Feb 2011, 16:09 
If I remove the footer code which is above the render page, the link is working as is. It is not giving me any error details.

All the code currently I am using in my application is posted in one of my previous posts.

Thank you
VA


  Subject: Re: Looking For PD4ML.NET Serve side Header/Footer Display Code
   PostPosted: 21 Feb 2011, 17:17 
There is a new PD4ML.NET version available for download. Please check if it solves the issue.



[Reply]     [ 16 posts ]  Go to page 1, 2  Next

cron
Copyright ©2004-10 zefer|org. All rights reserved. Bookmark and Share