Good job on the Excel to PDF programming! This is really a needed product and I’m very impressed with the work just released. Unfortunately during testing I ran into a problem that you may be able to help us out with.
I am executing code (listed below) that takes a preexisting XLS file and converts them using the ASPOSE Excel and PDF components to convert the XLS to a PDF file. The problem that I encountered is that the original print area in the spreadsheet is set at Landscape and when converting it to PDF it does not recognized it’s orientation and does not output the document as Landscape. At this juncture, I’ll even pass a Boolean to the function to make sure the output is printed and PDF’d correctly. Is there a way to make sure the printing orientation is correct based on input. If not, how can we make sure that PDF saves it as Landscape.
Thanks for you help,
David
Public Function RPMExcelXslToPDF(ByVal inUNC As String, ByVal outUNC As String, ByVal strUserLogon As String, ByVal PrintLandscape As Boolean) As String Dim RtnVal As String = String.Empty Dim InPath As String = inUNC.Trim If Not File.Exists(InPath) Then If strUserLogon.Trim.Length = 0 Then 'Determine if ASPOSE License is avalible for use; otherwise watermarked output will be created (for testing servers) Dim PDFLicense As String = GetWebConfigAppValue("ASPOSEPDFLicenseFile") 'Delete Temp Work file Dim DirName As String = fi.DirectoryName If File.Exists(FileName) Then File.Delete(FileName) Try Dim objDocument As EXCEL.Excel = New EXCEL.Excel
Dim objPDF As PDF.Pdf = New PDF.Pdf If PDFLicense.Length > 0 Then
'Add Timestamp Note. 'Attach Timestamp to file Dim sec1 As PDF.Section = objPDF.Sections.Add() If PrintLandscape = True Then sec1.IsLandscape = True Dim table1 As PDF.Table = New PDF.Table Dim row1 As PDF.Row = table1.Rows.Add() Dim cell1Row1 As PDF.Cell = row1.Cells.Add(strTimestamp) If File.Exists(OutPath) Then objPDF.Save(OutPath) If Not File.Exists(OutPath) Then Catch ex As Exception Try Return RtnVal End Function |