Query |
Response | |
When i set pdfDocument.PageSettings.Size = new SizeF(1500,800) instead of 1500 as width, the height is set as 1500 and width is set as 800. I am not sure why it is being always reversed. |
Since the default orientation of the PDF document will be “portrait” when the size to the document is given the higher value in size will be set as height and lower value will be set as width, this the natural behaviour in our library in order to achieve your requirement, the document orientation should be set as “landscape” refer the below code snippet:
| |
I need to export table of data with 11 columns to pdf resulting total width of 1500 points, witth custom width for every pdfcolumn in pdflighttable. |
We have created a work around code snippet for your requirement this can be found below this table | |
Is it possible to have first row with 5 columns and second row with 6 columns and limit the page size to A4. ie i want to span the columns to next row when the column position goes beyond the a4 size width. How do i achive this.
|
PdflightTable do not have support for spanning the columns and drawing in the next line, but PdfGrid has the support to span the columns to the next page, the code snippet for this can be referred from the below KB link :
|
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Set Orientation and page Size
doc.PageSettings.Orientation = PdfPageOrientation.Landscape;
doc.PageSettings.Size = new SizeF(1500, 800);
//Add a page.
PdfPage page = doc.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 14);
pdfLightTable.Style.DefaultStyle = new PdfCellStyle(font, PdfBrushes.Black, PdfPens.Black);
//Assign data source.
pdfLightTable.DataSourceType = PdfLightTableDataSourceType.TableDirect;
//Include columns to the Table.
for (int i = 0; i < 11; i++)
pdfLightTable.Columns.Add(new PdfColumn("column" + i));
//Include rows to the Table.
for (int i = 0; i < 5; i++)
{
pdfLightTable.Rows.Add(new string[] { "abc", "21", "row", "TestValue1", "TestValue2", "TestValue3", "TestValue4", "TestValue5", "TestValue6", "TestValue7", "TestValue8" });
pdfLightTable.Rows.Add(new string[] { "abcabc", "21", "row-data", "TestValue1-Value", "TestValue2", "TestValue3-Value", "TestValue4", "TestValue5-Value", "TestValue6", "TestValue7", "TestValue8-Value" });
}
float colWidth = 0;
//This loop will set the column width by measuring string values in the column
for (int col = 0; col < pdfLightTable.Columns.Count; col++)
{
for (int row = 0; row < pdfLightTable.Rows.Count; row++)
{
string value = (pdfLightTable.Rows[row].Values[col]).ToString();
if (colWidth == 0 || colWidth < font.MeasureString(value).Width)
colWidth = font.MeasureString(value).Width;
}
pdfLightTable.Columns[col].Width = colWidth;
colWidth = 0;
}
//Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0));
MemoryStream ms = new MemoryStream();
doc.Save(ms);
//Close the document
doc.Close(true); |
Query |
Response |
It seems to be the nuget pacakge is not compatible with .net standard 1.6. So i am not able to use the provided nuget packages.
Please add support for .net standard in nuget packages. |
You may use “Syncfusion.Pdf.Portable” assembly if you need .Net Standard 1.6 compatible nugget packages.
Which can be referenced from below link:
|
Regarding the nuget package how can i ignore dependencies in visual studio for max or xamarin studio.
|
For Xamarin Studio we should use the PowerShell commands to utilize the ignore dependencies option while installing the NuGet. Before that we need to update the Package manager extension. The details are explained clearly in below link,
After installing the package manager extension, install the Syncfusion Xamarin NuGet packages by using below installation command with the IgnoreDependencies parameter. Please refer the below screenshot for your reference.
PM> install-Package Syncfusion.Xamarin.Pdf -IgnoreDependencies
Also Powershell command structures are explained in below link,
For MAC we have updated the packages installation using console in detail in below UG link,
|