Spire.DataExport for .NET is a 100% pure data .NET library suit for exporting data into MS Word, Excel, RTF, Access, PDF, XPS, HTML, XML, Text, CSV, DBF, SYLK, SQL Script, DIF, Clipboard, etc.
Wed Jan 31, 2018 3:02 pm
Hello,
I have the following question.
I'm working to build an application to create a PDF with data export.
Is there any possibility to make de PDF "fit to page" or with a percentage zoom factor?
This is de code i have:
- Code: Select all
using (OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
{
DataTable dt = new DataTable();
da.Fill(dt);
Spire.DataExport.PDF.PDFExport PDFExport = new Spire.DataExport.PDF.PDFExport();
PDFExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
PDFExport.PDFOptions.PageOptions.MarginLeft = 0.5;
PDFExport.PDFOptions.PageOptions.MarginTop = 0.5;
PDFExport.PDFOptions.PageOptions.MarginBottom = 0.5;
PDFExport.DataFormats.NullString = string.Empty;
PDFExport.PDFOptions.PageOptions.Orientation = Spire.DataExport.Common.PageOrientation.Landscape;
//PDFExport.PDFOptions.DataFont.FontName.
PDFExport.PDFOptions.PageOptions.Format = Spire.DataExport.PDF.PageFormat.Fanfold;
PDFExport.DataTable = dt as DataTable;
PDFExport.SaveToFile(GlobalVar.LoggingPDFPath + GlobalVar.LoggingPDFName);
}
warm regards Arjan Lagemaat
-
ArjanLagemaat
-
- Posts: 4
- Joined: Fri Dec 15, 2017 10:47 am
Thu Feb 01, 2018 5:57 am
Hello,
Thanks for your inquiry.
Sorry our Spire.DataExport doesn't support setting FitToPage and Zoom factor properties. But another product
Spire.XLS Pack(Hotfix) Version:7.12.144 can meet your needs. You could export datatable to excel from database and set FitToPage property, then convert the excel to pdf file. Below is sample code for your kind reference.
- Code: Select all
//Connect database
OleDbConnection connection = new OleDbConnection();
connection.ConnectionString =@"Provider=""Microsoft.Jet.OLEDB.4.0"";Data Source=""demo.mdb"";User Id=;Password=";
OleDbCommand command = new OleDbCommand();
command.CommandText = "select * from parts";
DataSet dataSet = new System.Data.DataSet();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(command.CommandText,connection);
dataAdapter.Fill(dataSet);
DataTable t = dataSet.Tables[0];
//Export datatable to excel
Workbook book = new Workbook();
book.CreateEmptySheets(1);
Worksheet sheet = book.Worksheets[0];
sheet.InsertDataTable(t, true, 1, 1);
//Set orientation
sheet.PageSetup.Orientation = PageOrientationType.Landscape;
//Fit to page
sheet.PageSetup.IsFitToPage = true;
//Save to pdf file
sheet.SaveToPdf("result.pdf");
If there is any question, welcome to get it back to us.
Sincerely,
Nina
E-iceblue support team
-
Nina.Tang
-
- Posts: 1195
- Joined: Tue Sep 27, 2016 1:06 am
Mon Feb 05, 2018 8:10 am
Hello,
Greetings from E-iceblue.
Did we resolve your issue?
Thanks in advance for your valuable feedback and time.
Best wishes,
Nina
E-iceblue support team
-
Nina.Tang
-
- Posts: 1195
- Joined: Tue Sep 27, 2016 1:06 am
Tue Feb 27, 2018 6:38 am
Dear Nina,
Sorry for de late response.
There was a project between which I was unable to test it.
But I have now been able to test and it works well.
The only thing is that there is now an E-Iceblue watermark in the PDF what we have with the data connector not.
Thank you for the support.
Best wishes,
Arjan Lagemaat
-
ArjanLagemaat
-
- Posts: 4
- Joined: Fri Dec 15, 2017 10:47 am
Tue Feb 27, 2018 7:57 am
Hello,
Thanks for your feedback.
The reason for the watermark is that you didn't apply a license of our commercial Spire.XLS in your project. We have sent a temporary license file (one month free) for you via email, please apply it to remove the watermark and have a better evaluation on our Spire.Xls.
How to Apply the License by license keySincerely,
Nina
E-iceblue support team
-
Nina.Tang
-
- Posts: 1195
- Joined: Tue Sep 27, 2016 1:06 am