The text is blurred on the PDF generated with aspose.cells 5.3.1.5.
Public Shared Function WorkbookToPDFFile_Aspose4x(ByVal pWorkBook As Aspose.Cells.Workbook, ByVal pFilename As String, Optional ByVal CreateBookmarks As Boolean = True) As String
Dim retVal As New System.IO.MemoryStream
Dim pSectionNames As IList(Of String) = New List(Of String)
For Each s As Worksheet In pWorkBook.Worksheets
'If s.IsVisible = True Then
pSectionNames.Add(s.Name)
'End If
Next
Dim stream As IO.MemoryStream = New IO.MemoryStream
pWorkBook.Save(stream, FileFormatType.AsposePdf)
'pWorkBook.Save(stream, SaveFormat.Pdf)
stream.Seek(0, IO.SeekOrigin.Begin) '// Reset the pointer to the beginning of the stream
'// Load the document as raw XML
Dim xmlDoc As Xml.XmlDocument = New Xml.XmlDocument
xmlDoc.Load(stream)
stream.Close()
stream.Dispose()
stream = Nothing
'Read the file in Aspose.Pdf.Xml format into Aspose.Pdf
Dim pdf1 As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()
pdf1.IsTruetypeFontMapCached = False
'pdf1.IsTruetypeFontMapCached = True
'pdf1.TruetypeFontMapPath = IO.Path.GetDirectoryName(pReportName) 'pourrait ralentir la génération du rapport…
pdf1.IsImagesInXmlDeleteNeeded = True
'Bind the XML file (containing spreadsheet data) with the Pdf object
pdf1.BindXML(xmlDoc, Nothing)
'patch, il semble que les hpagebreak soient considéré comme des sections
'pour éviter de créer des bookmarks, nous allons les trouver
Dim SectionList As New List(Of ePDFSectionType)
For Each SingleWorksheet As Aspose.Cells.Worksheet In pWorkBook.Worksheets
If SingleWorksheet.IsVisible = True Then
SectionList.Add(ePDFSectionType.Worksheet)
For i As Integer = 1 To SingleWorksheet.HorizontalPageBreaks.Count
SectionList.Add(ePDFSectionType.PageBreak)
Next
End If
Next
Dim intSection As Integer = 0
Dim SheetCounter As Integer = 0
For Each sec As Aspose.Pdf.Section In pdf1.Sections
If SectionList.Item(intSection) = ePDFSectionType.Worksheet Then
Dim heading1 As Aspose.Pdf.Heading = New Aspose.Pdf.Heading(pdf1, sec, 1)
Dim segment1 As Aspose.Pdf.Segment = New Aspose.Pdf.Segment(heading1)
heading1.Segments.Add(segment1)
'heading1.IsAutoSequence = True
'If intSection + 1 > pSectionNames.Count Then
If SheetCounter > pSectionNames.Count Then
segment1.Content = “??”
Else
segment1.Content = pSectionNames(SheetCounter)
End If
segment1.TextInfo.FontSize = 0.1 'to make it invisible
sec.Paragraphs.Insert(Nothing, heading1)
SheetCounter += 1
End If
intSection += 1
Next
pdf1.IsBookmarked = True
'pdf1.IsBookmarked = False 'quick fix 2009-11-26
pdf1.BookMarkLevel = 1
'Create the PDF document by calling its Save method
'strReportName = pReportName + “.pdf”
pdf1.Save(pFilename)
pdf1 = Nothing
If IO.File.Exists(pFilename) = False Then
Throw New Exception("Failed to save the document: " & pFilename)
End If
Return pFilename
End Function