We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Picture disappears when saving to a PDF

Hi

I create a workbook from scratch to which I add 4 worksheets.

On each worksheet, I add a jpeg at the top (company logo) using this code:

Private Function CreateNAVWorksheetHeader(ByVal pSheet As Worksheet) As Integer
Dim strRoot As String = Application.StartupPath
Dim intPicture As Integer = pSheet.Pictures.Add(0, 0, strRoot + "\Data\Images\LOGO.JPG")
pSheet.Cells.Merge(0, 0, 1, 5)
pSheet.Cells.SetRowHeightPixel(0, 75)

Dim objPicture As Aspose.Cells.Picture = pSheet.Pictures(intPicture)
objPicture.IsLockAspectRatio = True
objPicture.HeightInch = 0.64
objPicture.WidthInch = 4.02

objPicture.Placement = PlacementType.FreeFloating

Return intPicture
End Function

When I save the workbook as a Excel file, I can see the picture on each worksheet.

When I save it as a PDF, the image does not appear on the third worksheet (always the same). This is the code I use to save:

Private Sub SaveWorkbook()
Select Case Me.OutputType
Case cReport.enuOutputType.Native
mWorkbook.Save(ReportName)
Case cReport.enuOutputType.PDF
'save as PDF

'TODO Create a temp file and delete it when done
Dim strTempFile As String = "MySpreadsheet.xml"
'Save the document in Aspose.Pdf.Xml format
mWorkbook.Save(strTempFile, FileFormatType.AsposePdf)

'Read the file in Aspose.Pdf.Xml format into Aspose.Pdf
Dim pdf1 As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()

'Bind the XML file (containing spreadsheet data) with the Pdf object
pdf1.BindXML(strTempFile, Nothing)

'Create the PDF document by calling its Save method
pdf1.Save(ReportName)

Case cReport.enuOutputType.HTML
Throw New NotImplementedException
'https://forum.aspose.com/t/93322

Case Else
Throw New NotImplementedException
End Select
End Sub

Any ideas on how to fix that?

Hi,

Thanks for considering Aspose.

Could you post your produced output excel (.xls) file, .xml file (Aspose.Pdf integrated) etc. here, we want to check the conversion (Excel2Pdf) for your issue.

And by the way which versions of Aspose.Cells and Aspose.Pdf you are using? Kindly try the latest versions of Aspose.Cells (4.4.1. downloading @: http://www.aspose.com/Community/Files/51/aspose.cells/entry111612.aspx) and Aspose.Pdf.

thank you.

You will find attached a zip containing the required files.

As per the version of components, it is:

  • Aspose.Cells = 4.4.1
  • Aspose.Pdf = 3.6.1

Hi,

Thanks for the template files.

We found the problem after some initial testation, the logo is not displayed for Fund 2 worksheet in the output .pdf file. We will figure it out soon.

Thank you.

Hi,

Please try this fix.

We have fixed this bug.

Hi

The first few tests I made indicates that your fix is working. Any ideas when it will be made officially available in the downloads section?

Thanks

Hi,

Well, you may use this fix without any problem in our dev. or server environment, it will behave like the official release. However we will release our next official version soon.

Thank you.