Print excel file to pdf in landscape mode using C# -


i have project should print check bill in both excel , pdf format. use npoi print excel , spire print pdf using excel file:

public hssfworkbook workbook; public void saveexcelfile(string filepath) {     this.autosizecolumn();     filepath = filepath == "" ? appdomain.currentdomain.basedirectory + "sample.xls" : filepath;     var file = new filestream(filepath, filemode.create);     workbook.write(file);     file.close(); }  public void savepdffilefromexcel(string excelfilepath, string pdffilepath) {     workbook pdfworkbook = new workbook();     pdfworkbook.loadfromfile(excelfilepath);     pdfworkbook.savetofile(pdffilepath, spire.xls.fileformat.pdf);  } 

but spire print pdf in portrait, , bill small , ugly. want know if there's way can print pdf in landscape.

or should use itext create pdf format self?

try this:

public void excellandscapeformat() {  try   {      ((microsoft.office.interop.excel._worksheet)       excelwbook.activesheet).pagesetup.orientation =       microsoft.office.interop.excel.xlpageorientation.xllandscape;      excelwbook.exportasfixedformat(xlfixedformattype.xltypepdf,       path.getdirectoryname(assembly.getexecutingassembly().location) + "\\" + output);   }   catch  { } } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -