linkedinfacebooktwittermenuarrow-up

GemBox Support Forum

Show multiple pages when converting to PDF

Hey ppl!

I’m struggling a bit with the free version of the API, I have a form that writes in an excel template, and depending on how many lines are inside a cell, it stretches the cell to fit all the content, is there a way to make the cell continue in another page?

ExcelFile workbook = ExcelFile.Load("GPOF.xlsx");
var worksheet = workbook.Worksheets[0];

// the code of what it will do in the template, and below the end of it

string adress;
string adress1;
adress = "C:\\GPOF\\" + tbNome.Text + " " + tbAno.Text + " " + tbTurno.Text + " " + DateTime.Now.ToString("ddMMyyHHmmsstt") + ".pdf";
adress1 = "C:\\GPOF\\" + tbNome.Text + " " + tbAno.Text + " " + tbTurno.Text + " " + DateTime.Now.ToString("ddMMyyHHmmsstt") + ".xlsx";
workbook.Save(adress);
workbook.Save(adress1);

I tried a few options like print options but didn’t get to work.

Any hints?

I appreciate.

Hi Ricardo,

That should be the default behavior, if the cell’s content cannot fit on one page, it will be split.

What exactly is the problem you’re experiencing?
Can you try explaining it again, perhaps send us a screenshot?

Anyway, I’m afraid you cannot specify where in the cell the page break will occur.
What you can specify is on what row you want the page break to occur (using ExcelWorksheet.HorizontalPageBreaks collection).

Regards,
Mario

Hi!

Sorry for taking so long to respond, the personal life issues, but everything is ok.

The problem was that, i had to put some line limits at my textbox because after a numebr of line, if i print in PDF, it would cut everything outside the cell size area, instead of going to the other page, ill check that command to see it works. Ill update here if it worked!

Thanks a lot!

Its me again :smiley:

Let me explain what im trying to do, i have an excel template that i load in my c# program, i populate it with data from the winform, including lot of richtextbox multiple rows, and then i print on PDF. The thing is, instead of the row streaching to the next page, when i print the PDF, it just cut out the text at certain line and show only one page. I tried that collection but i couldnt make it work.

So what im trying to code is, if the content that populate the row get too long, it continue on a second page and print all those pages in PDF.

I appreciate any insight.

Hi Ricardo,

Can you please send us a small project that reproduces your issue so that we can investigate it?

I’m afraid that without reproducing your issue it’s hard to imagine what problem you have exactly.
Maybe you just need to set CellStyle.WrapText to true.

Anyway, I’ll investigate your repro project and let you know how to solve the issue.

Regards,
Mario

Hi!

Thanks for answering!
I started to investigate some properties in excel template and i discovered that it was rigged to use just one page, so when converting it to PDF, wasn’t creating other pages to fit the content of the cell. Now i changed it to automatic and it started to create more than one pages.

image

Sorry for this silly mistake, but now i got another problem that i tried to fix without success, ill be creating another post so more people will be able to find it easier.

Thanks for the support.