I am trying to use ExportToPdf to generate a .pdf document from a RadGrid. Here's a simplified version of my grid. The labels export to the .pdf, but the table with "TGIF" does not. I need to use HTML formatting to arrange the labels. What am I doing wrong? Thanks!
<telerik:RadGrid ID="gridTest" runat="server" AutoGenerateColumns="False"
Skin="Default" Width="800px"
OnItemCreated="gridTest_ItemCreated" >
<ExportSettings
IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="False">
<Pdf PaperSize="Letter"></Pdf>
</ExportSettings>
<MasterTableView ShowHeader="false">
<Columns>
<telerik:GridTemplateColumn DataField="strCaseID" UniqueName="strCaseID" ShowFilterIcon="false" >
<ItemTemplate>
<table>
<tr>
<td>
TGIF!
</td>
</tr>
</table>
<asp:Label ID="lbName" runat="server" Text='<%#Eval("strEmployeeFName")%>' ></asp:Label><br />
<asp:Label ID="lbAddressStreet1" runat="server" Text='<%#Eval("strEmployeeAddressStreet1")%>' ></asp:Label><br />
<asp:Label ID="lbAddressStreet2" runat="server" Text='<%#Eval("strEmployeeAddressStreet2")%>' ></asp:Label><br />
<asp:Label ID="lbAddressCity" runat="server" Text='<%#Eval("strEmployeeAddressCity")%>' ></asp:Label><br />
<asp:Label ID="lbAddressState" runat="server" Text='<%#Eval("strEmployeeAddressState")%>' ></asp:Label><br />
<asp:Label ID="lbAddressZip" runat="server" Text='<%#Eval("strEmployeeAddressZip")%>' ></asp:Label><br />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
in Page_Load...
PopulateGrid(gridTest);
ConfigureGridBeforeExportToPdf();
gridTest.MasterTableView.ExportToPdf();
protected void gridTest_ItemCreated(object sender, GridItemEventArgs e)
{
try
{
ConfigureGridItem(e.Item);
}
catch (Exception ex)
{
// do stuff
}
}
protected void ConfigureGridItem(GridItem item)
{
// ***** THIS IS FOR - each Item
item.Style["color"] = "purple"; // font color
if (item is GridHeaderItem)
{
item.Visible = false;
}
else if (item is GridDataItem)
{
item.Style["vertical-align"] = "middle";
item.Style["text-align"] = "left";
}
switch (item.ItemType)
{
case GridItemType.Item: item.Style["background-color"] = "lightyellow"; break;
case GridItemType.AlternatingItem: item.Style["background-color"] = "mistyrose"; break;
}
}
public void ConfigureGridBeforeExportToPdf()
{
// ***** THIS IS FOR - entire Grid
// format - Pdf Settings
gridTest.ExportSettings.Pdf.BorderType = GridPdfSettings.GridPdfBorderType.OuterBorders;
gridTest.ExportSettings.Pdf.BorderStyle = GridPdfSettings.GridPdfBorderStyle.Thick;
gridTest.ExportSettings.Pdf.BorderColor = System.Drawing.Color.HotPink;
gridTest.ExportSettings.Pdf.PaperSize = GridPaperSize.Letter;
gridTest.ExportSettings.Pdf.PageHeight = Unit.Parse("162mm");
gridTest.ExportSettings.Pdf.PageWidth = Unit.Parse("600mm");
// format - header
GridItem headerItem = gridTest.MasterTableView.GetItems(GridItemType.Header)[0];
headerItem.Visible = false;
// format - footer
gridTest.ExportSettings.Pdf.PageFooter.MiddleCell.Text = "<?page-number?>";
gridTest.ExportSettings.Pdf.PageFooter.MiddleCell.TextAlign = GridPdfPageHeaderFooterCell.CellTextAlign.Center;
}
Hi,
I have several PDFViewer in different pages of my application, contained in div that can be collapsed.
Depending of the pages the div can be collapsed or not at loading of the page.
For the ones that are not collapsed, the PDFViewer scale is set to "Fit to Width" and the scaling is ok.
However, for the ones that are in collapsed div, the "Fit to Width" setting is not processed.
Attached is a project with the described behavior.
Is there a way to manage the scaling properly on collapsed PDFViewer ?
I want to add a watermark to the pdf file to be displayed in pdfviewer.
Please inquire if it is possible.
We switched from using your DLLs directly to pulling from Nuget.
We were originally targeting the .NET Framework version of your libraries and planned to continue to do so.
However in the conversion it was realized that Telerik.Web.Spreadsheet is only available as Standard in your Nuget. Therefore due to this ONE missing library I had to convert everything to Standard.
This was fine until we realized that Standard isn't capable of embedding subset fonts into PDFs like Framework, leading to larger files.
I attempted to do a mix of the two and failed but I'd really rather not do that anyway.
Could you please properly update your Nuget to include the Framework version of Telerik.Web.Spreadsheet? I know it exists because I used it before moving to Nuget.
Thank you
Hi,
I can get my pdf file from sql svr database to view on browser:
DataRow dr = dsFile.Tables[0].Rows[0];
Byte[] fileBuffer = (byte[])dr["DocumentBinary"];
if (fileBuffer != null)
{
radviewPdf.PdfjsProcessingSettings.FileSettings.Data = Convert.ToBase64String(fileBuffer);
}
How to view the PDF without saving to a folder (say ..\Download)?
On MS Edge, browser asks to click Open file but it also saved to Download.
On Chrome, browser asks to save file.
Thanks,
DT
Hey all, l was wondering how I would go about removing these huge gaps on my <li> upon export. I'm placing dynamic values from state. I attached the before and after images.
</li>
</ol>
Hello, I have a RadPdfViewer in one of my pages but no matter the way I try to load a PDF, it stays hanging in the loading stage indefinitely.
It stays that way even if I try to load a Pdf by simply clicking open.
What can I do to fix this ?
I have a PDF with a number of text fields that have a number format. I am updating them with calculated values:
If PDFdocument.AcroForm.FormFields.Contains(row.Item("XMLField").ToString()) Then
field = PDFdocument.AcroForm.FormFields.Item(row.Item("XMLField").ToString())
Select Case field.FieldType
Case FormFieldType.TextBox
ModifyTextBox(CType(field, TextBoxField), OutText)
Case FormFieldType.CheckBox
Try
ModifyCheckBox(CType(field, CheckBoxField), New String() {row.Item("OutText").ToString()})
Catch
End Try
End Select
End If
When this executes the number format is over written and I see 1222777.00 instead of 1,222,777.00.
Is there a way to either not lose the number format or reset the number format for the PDF Text field.?
Hi,
I am using a RadPdfViewer control and i have a PDF with forms fiels but, when render the pdf file, Form fields don't appear.