Sign In  Sign Up Live-Chat

Multipage PDF generation problem

Last post 07-24-2007, 1:29 PM by gnrkrazy. 21 replies.
Page 1 of 2 (22 items)   1 2 Next >
Sort Posts: Previous Next
  •  07-11-2007, 12:15 PM 83658

    Multipage PDF generation problem

    Attachment: Present (inaccessible)
    I am using ASPOSE.pdf version 2.9.3.0
    I have a program that takes data from the database and creates a table to show the data.
    I then take the returned data and add it to a created datatable which just stores records meeting the current critera. I then import this to the pdf table and add it to the section.
    The splitting works fine on the data but when it displays in the pdf it is on many more pages than needed.
    Each time there is data to put to a table and to the pdf i create a new section with the same size and options enabled. then I add a table import the data for that group.. I also create a header and footer and apply them to this new section. Now when i look at the data I expect roughly 30 lines of data in my table so however that breaks down the data i will get 1 or 2 pages in most cases. However I am not seeing that. I get one group that is broken down to 2 rows of data per page when i only am adding 1 table. How can that be? any suggestions on how to fix it? I provided the generated pdf so you can see what I am talking about. If you need to see code that is being used to generate this i will gladly provide it.
    Thanks
    Ray

     
  •  07-11-2007, 2:45 PM 83684 in reply to 83658

    Re: Multipage PDF generation problem

    Hi,

    Thank you for considering Aspose.

    First of all, please upgrade to latest version.

    Secondly, as you are mentioning that whenever any rows are fetched then you create new section and add header footer to it. So, by default whenever you add a Section then it moves to new page. Therefore, whenever you add a section then set it's value to isNewPage=false. What I recommend is that you should have only one section, there is no need to add multiple section.

    Third, what I think is that the table are added whenver new rows are found, so in this case you should get the table and add rows in the existing table, if the columns are same then there is no need to create a new table every time. Hence you find tables in so many groups.To overcome that you can use isKeptWithNext and isKeptTogether property to true.

    If you need more help, please do let us knew.

     Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

     

     
  •  07-12-2007, 8:02 AM 83857 in reply to 83684

    Re: Multipage PDF generation problem

    I will be upgrading at some point but right now it is not an option because the client has too many apps using this version. Once i am finished with this I will be recompiling their apps with version 3.3.3.0 (the latest version we have tested and are using in our applications).

    Perhaps I wasnt totally clear. I want to have some seperation. If I were to set isNewPage=false I wouldn't have that seperation I am looking for, that is why I add a new section each time. Is there a way to have a single section and keep adding new pages with different headers and data table on each page?

     How it works now is I have a large query returning data that is ordered by the header on each page. I want all the pages that have the same header to be on the least amount of pages possible. The code that is doing the seperating of the data looks fine, I am creating only  7 sections and tables.
    The first few pages everything seems ok . Pages 5 and 6 should be able to combine to one page, Pages  9,10,11 and 12 should be on only 1 page, and the last 12 pages should be on one page. Where I have said they should be combined my code is only producing 1 section and 1 table. For some reason aspose.pdf is splitting those tables into multiple pages like you see in the pdf I posted earlier.

    Looking at the pdf can you see anything wrong ? Are the multiple header and footer margins adding up and shrinking the height for the body? This is driving me crazy because on larger amounts of data this is throwing a system out of memory exception and brings my clients server down. I need to get this fixed as soon as possible.

    Thank you for taking a look. Please let me know if you can figure out anything more or if you need to see some code.
    Thanks again
    Ray

     
  •  07-12-2007, 9:36 AM 83884 in reply to 83857

    Re: Multipage PDF generation problem

    Hi,

    It is difficult to judge. You can have mutiple header and footer with one section, but as per requirement, I don't think they will work. You can send me your code, but as you are saying that you get the data from database so, it is difficult for me to run and check the problems without having any database. But if you can provide me some runnable project then I can help you out. You can decrease the size of Header Margin to increase the number of rows rendering in one page. Similarly, you can also set another property "DistanceFromEdge" to reduced the distance and more rows will be displayed.

    Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html



     
  •  07-12-2007, 1:18 PM 83945 in reply to 83884

    Re: Multipage PDF generation problem

    Attachment: Present (inaccessible)
    I have a zip file attached. It is a project that contains only the needed files to run the classrpt page I am working on.
    Inside the folder there is also a testClass csv. This is the database file please import that to a table named testclass.
    The connection string is at the top of Classrpt.aspx
    Please let me know what you find.
    I have it using my license files right and using version 3.3.3.0 and it produces the same results.

    Thank you for looking into this,
    Ray

     
  •  07-12-2007, 3:36 PM 83963 in reply to 83945

    Re: Multipage PDF generation problem

    Hi,

    I will check it and will get back to you as soon as solution is found.

    Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

     
  •  07-15-2007, 5:09 AM 84180 in reply to 83963

    Re: Multipage PDF generation problem

    Hi,

    I have checked your code and I won't be able to find any Aspose.Pdf problem. There is some problem with the code but I am not been able to identify it. I think you need to recheck it yourself, because it is difficult for us to understand in full. Sorry for incovenience and hope you understand.

    Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

     
  •  07-16-2007, 8:36 AM 84259 in reply to 84180

    Re: Multipage PDF generation problem

    I have checked the code several times and know that it should be creating only 7 sections and tables, however the output is much more. If I could recheck it and find the problem with why Aspose.PDF is creating so many more pages, I wouldn't have asked for any help.  I will gladly clarify any code that I have sent you.

    No I really do not understand why it is so difficult to understand in full. It is not a very complex operation that I am trying to do and I have seen many more difficult things get answered quicker on this forum than my request has. I understand that it is most likely something in the way it is coded, but that is why I have sent the support request.
    If there is something I can do to aid in your understanding of the code, please let me know.
    Ray


     
  •  07-16-2007, 9:57 AM 84274 in reply to 84259

    Re: Multipage PDF generation problem

    Dear Ray,

    I have not installed SqlServer in my developing machine. Adeel has SqlServer installed but his is not familiar with the internal code. I will install the SqlServer and check this problem soon.


    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  07-16-2007, 10:42 AM 84280 in reply to 84274

    Re: Multipage PDF generation problem

    Thank you for all your help.
    Ray

     
  •  07-17-2007, 8:22 AM 84423 in reply to 84259

    Re: Multipage PDF generation problem

    Dear Ray,

    I tested your project and I still can't find any problem of Aspose.Pdf. You said it should be creating only 7 sections and tables, but when I trace the code I found 16 sections are added. You can easily check it to add breakpoint at the following lines (there is two of such lines in the code):

                pdf1.Sections.Add(sec1)

    You can also easily check the sections and rows of table by adding the following code before pdf1.Save:

                'debug
                Dim mes As String = ""

                Dim idx0, idx1 As Integer
                For idx0 = 1 To pdf1.Sections.Count
                    mes = mes & "    section " & idx0.ToString()
                    Dim tab As Table = pdf1.Sections(idx0 - 1).Paragraphs(0)
                    mes = mes & "- Rows:" & tab.Rows.Count.ToString()
                Next


    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  07-18-2007, 10:15 AM 84607 in reply to 84423

    Re: Multipage PDF generation problem

    Tommy
    Thank you for looking into this further.
    I have noticed I made a mistake in couting and it should be adding 8 Sections and tables.
    I see where you would get 16 from. When the savetype is set to OpenInBrowser IE will rerequest the page, thus doubling your count. If you change the save line to pdf1.Save("ClassRpt.pdf", SaveType.OpenInAcrobat, Response) this will no longer happen and you will see the 8 that I see.
    When I check pdf1.sections.count() right before my pdf1.save() I get 8, whether OpenInBrowser or OpenInAcrobat.
    Also adding your block of code above gives this output

    mes     section 1- Rows:21    section 2- Rows:36    section 3- Rows:2    section 4- Rows:25    section 5- Rows:2    section 6- Rows:11    section 7- Rows:22    section 8- Rows:25

    Still the 8 sections I should have.
    Please reply back with what you get when you run my code with that block you provided. You will see my code is only producing 8 sections and tables and that it is still getting split by aspose.pdf to 24 pages.

    Thank you
    Ray


     
  •  07-18-2007, 9:44 PM 84682 in reply to 84607

    Re: Multipage PDF generation problem

    Dear Ray,

    We made mistake when loading the data which make the row number is larger than it should be. Sorry for this. Now I have reproduced this error. The result is the same as yours. I will find the reason and try to fix it ASAP.


    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  07-19-2007, 4:26 AM 84728 in reply to 84682

    Re: Multipage PDF generation problem

    Attachment: Present (inaccessible)

    Dear Ray,

    We have fixed this bug. Please try the attachment before we publishing the hotfix.


    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  07-19-2007, 11:06 AM 84799 in reply to 84728

    Re: Multipage PDF generation problem

    Attachment: Present (inaccessible)
    Tommy
    Thank you for your quick work.
    This does fix the problem of it splitting into many extra pages. However it is losing the formatting I had
    Attached is 2 pdfs. 
    ClassRptGood.pdf is what I want it to look like. Which  I achieved by commenting out this line using version 3.3.3.0 and Earlier:

    sec1.PageInfo.Margin.Bottom = 25

    ClassRptBad.pdf is what it looks like when I run with the hotfix version you have posted. Notice how the column sizing is completly different.
    I am using this code to size the columns.

    'Size first column - First column is larger with Names need to see whole thing
    tab1.SetColumnWidth(0, tab1.GetMaxColumnWidth(0))

    'Size other columns - Use min to wrap column headers
     For j = 1 To dt.Columns.Count - 1

             tab1.SetColumnWidth(j, tab1.GetMinColumnWidth(j))
     Next
    Thanks again
    Ray

     
Page 1 of 2 (22 items)   1 2 Next >
View as RSS news feed in XML