Free Support Forum - aspose.com

Save to PDF errors with cell borders

I’m finding errors with my PDF conversion of a workbook. I save to XML, bind the pdf then save to a pdf file as per the wiki instructions. What I am finding is, with certain cells that have coloured borders, every second row is missing it’s left border.

I did some digging and found the error is in the XML file that Aspose.Cells generates. I confirmed the XML fault by finding a cell that had a missing border in the XML file and added a Border Tag with a left Border and the PDF then saved properly from that.

I also notice that the left border and top border of a cell didn’t align properly in the corner.

Has anyone else had these problems? Would it be useful to provide the XML file and pdf for demonstrative or debugging purposes?

Hi,

Thanks for considering Aspose.

Please post your template excel file, output .pdf file with sample code here. We will check and figure out your issue soon. And by the way which version of Aspose.Cells and Aspose.Pdf you are using.

Thank you.

Thanks for the fast reply Amjad.

Aspose.Cells.dll File Version: 4.4.05

Aspose.pdf.dll File Version: 3.6.1.0

OK, here is my VB.NET code block:

'Open Workbook from template

Dim workbook As New Aspose.Cells.Workbook

workbook.Open("Z:\Z_Personal\Invoicetest\temp.xls")

Dim xmlfile As String = System.IO.Path.GetRandomFileName & ".xml"

Dim tempdir As String = System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath + "aspose\").FullName

Dim pdf As New Aspose.Pdf.Pdf()

' define print area so PDF fills the page nicely

workbook.Worksheets(0).PageSetup.PrintArea = "A1:O55"

' save as PDF XML

workbook.Save(tempdir & xmlfile, Aspose.Cells.FileFormatType.AsposePdf)

' Open as PDF from XML

pdf.BindXML(tempdir & xmlfile, Nothing)

' Write to Network share

pdf.Save("Z:\Z_Personal\Invoicetest\temp.pdf")

' Cleanup the temp dir

System.IO.Directory.Delete(tempdir, True)

Attached is the temp.xls. As you can see in the PDF that gets generated, the left borders for the orange boxes aren't being shown. Also note the top corners for cell C20 and the bottom corner for cell C22 are not square.

I tried fiddling with the template to make the borders appear, with mixed results. Here is what I observed:

1. If I put text in the cells with missing borders, the borders would then appear in the PDF. The corners for C20 and C22 would still be wrong though

2. If I set the borders to appear for cells C20, 21 and 22, the borders would appear complete and correct in the PDF. But obviously, I don't want -all- the borders to show.

3. Making the borders on the right, top and bottom side of the cells appear but with the same colour as the cell background would make the borders appear in the PDF, but they would -cut in- to the darker border.

Hopefully thats all clear.

Attached to this post is the PDF my code is generating.

Hi,

Thanks for the files.

We have checked your issue and will figure it out soon.

Thank you.

Awesome!!

I tell ya, the sooner I can put a bullet into Excel and get it off my apps server the better.

Hi,

Please try this fix.

Quick question, will this fix include other fixes already made for other people?

I have a co-worker who also had a bug fixed for Cells (saving as a tab delimited text file without CrLf characters).

I don’t want to overwrite his fixes because our applications will be hosted on the same server.

Hi,

Of course, it contains all previous fixes.

Well first, the good news, the borders are appearing. Hurrah!

The bad news is, the corners to the left at the top are still being ‘chipped’ off. Please see the attached image for an example.

I tried in Development and production and both show the problem.

Just as a sanity check,
I copied the dll you provided me into the C:\Program Files\Aspose\Aspose.Cells\Bin\Net2.0 directory.
I removed the existing Aspose.cells reference from my prioject.
I added the reference to my application by manually browsing to the dll file.

Is that the correct procedure? I have since rebooted the machine as well.

Thank you.

Hi,

Thanks for the details,

We will figure out the corner issue soon.

And you procedure for referencing Aspose.Cells fix is correct.

Thank you.

Hi,

Aspose.Pdf will fix it soon. Thanks for your patience.

Hi,

The bug has been fixed. Please try the attachment.

Best regards.

Great, that works perfectly.

What a nice Christmas present to come back to work with :slight_smile: