Telerik Forums
UI for WinForms Forum
1 answer
198 views
I'm creating a PDF file using the PdfStamper in iTextSharp and return the PDF as a memorystream object to the calling function, that is then used to display the PDF in Teleriks PDF Viewer Component for WinForms. That's the objective.Right now, creating the PDF works as it should, and it returns the data to the Calling function, and in the Calling function, should I write the memorystream contents to a file stream and then open it in Adobe Reader Everything looks just fine.However, if I choose to display the PDF in the PDF Viewer Control I just get an "Unsupported Stream type" error.Now, I figured something was wrong in the PDF data so I decided to create the PDF file, save it to disk, then read it to a memorystream in the Calling function and display that memorystream in the PDF Viewer and that, for some to me unknown reason, works.... I really can't get my head around this and need some help.

So, this won't work:

//The Calling function
    private void dlgViewPDF_Load(object sender, EventArgs e)
{
    MemoryStream ms = PDFcreator.GeneratePDFdata(id);
 
   rPdfView.LoadDocument(ms);
}
 
//The PDF generator
public static MemoryStream GeneratePDFdata(string id)
{
            MemoryStream ms = new MemoryStream();
 
            string sTemplate = string.Concat(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\template.pdf");
 
            PdfReader pdfReader = new PdfReader(sTemplate);
            PdfStamper pdfStamper = new PdfStamper(pdfReader, ms);
 
            PdfContentByte cb = pdfStamper.GetOverContent(1);
 
            BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
            BaseFont baseFontBold = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.EMBEDDED);
            cb.SetColorFill(iTextSharp.text.Color.BLACK);
            cb.SetFontAndSize(baseFontBold, 14);
 
            cb.BeginText();
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "TEST!!", 385, 750, 0);
            cb.EndText();
 
            cb.SetColorStroke(new CMYKColor(0f, 0f, 0f, 1f));
            cb.SetColorFill(new CMYKColor(0f, 0f, 0f, 1f));
 
            cb.MoveTo(139, 398);
            cb.LineTo(146, 398);
            cb.LineTo(146, 391);
            cb.LineTo(139, 391);
            cb.ClosePathEoFillStroke();
 
            pdfStamper.Close();
            pdfReader.Close();
 
            return ms;
}

But this WILL work:
//The Calling function
private void dlgViewPDF_Load(object sender, EventArgs e)
{
    MemoryStream ms = new MemoryStream();
 
    FileStream file = new FileStream(@"c:\temp\testfile.pdf", FileMode.Open, FileAccess.Read);
 
    byte[] bytes = new byte[file.Length];
    file.Read(bytes, 0, (int)file.Length);
    ms.Write(bytes, 0, (int)file.Length);
 
    rPdfView.LoadDocument(ms);
}
 
 
//The PDF generator
public static void GeneratePDFdata(string id)
{
            MemoryStream ms = new MemoryStream();
 
            string sTemplate = string.Concat(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\template.pdf");
 
            PdfReader pdfReader = new PdfReader(sTemplate);
 
            FileStream fs = new FileStream(@"c:\temp\testfile.pdf", FileMode.Create, FileAccess.Write, FileShare.None);
            PdfStamper pdfStamper = new PdfStamper(pdfReader, fs);
 
            PdfContentByte cb = pdfStamper.GetOverContent(1);
 
            BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
            BaseFont baseFontBold = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.EMBEDDED);
            cb.SetColorFill(iTextSharp.text.Color.BLACK);
            cb.SetFontAndSize(baseFontBold, 14);
 
            cb.BeginText();
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "TEST!!", 385, 750, 0);
            cb.EndText();
 
            cb.SetColorStroke(new CMYKColor(0f, 0f, 0f, 1f));
            cb.SetColorFill(new CMYKColor(0f, 0f, 0f, 1f));
 
            cb.MoveTo(139, 398);
            cb.LineTo(146, 398);
            cb.LineTo(146, 391);
            cb.LineTo(139, 391);
            cb.ClosePathEoFillStroke();
 
            pdfStamper.Close();
            pdfReader.Close();
}

But why? I'd rather keep it all in memory and let the user save the resulting PDF if he/she so wishes than having to write it to disk and then displaying it.
Am I missing some crucial step here?


Johannes
Top achievements
Rank 1
 answered on 21 Aug 2014
2 answers
143 views
Hi,

I have a stacked100 bar chart.  It "seems" to be structured the way I want it structured, it's just the colors aren't contrasting.

I did a mouseover on the "Jan 2014" so you can see it is indeed breaking it into the percentages properly (see attached).

How do I get the colors to contrast or did I simply structure the code incorrectly? (admittedly series and categories confuse me at times)

Thanks for your help.

Code:
            DataTable dt = new DataTable();
            dt = f.CallStoredProcedure("rptHitRate_Chart");
            
            BarSeries b1 = new Telerik.WinControls.UI.BarSeries();
            BarSeries b2 = new Telerik.WinControls.UI.BarSeries();

            b1.CombineMode = ChartSeriesCombineMode.Stack100;
            //b2.CombineMode = ChartSeriesCombineMode.Stack100;        

            chartHitRate_Monthly.Series.Add(b1);

            foreach (DataRow dr in dt.Rows)
            {
                CategoricalDataPoint cdp = new CategoricalDataPoint((double)dr["ApprovalRate"], dr["DateGroup"]);
                CategoricalDataPoint cdp2 = new CategoricalDataPoint((double)dr["DeclineRate"], dr["DateGroup"]);

                b1.DataPoints.Add(cdp);
                b1.DataPoints.Add(cdp2);
            }  

data layout:
DateGroup  ApprovalRate DeclineRate
Jan 2014 0.368421052631579 0.631578947368421
Feb 2014 0.75 0.25
Mar 2014 0.568965517241379 0.431034482758621
Apr 2014  0.423728813559322 0.576271186440678
May 2014 0.392857142857143 0.607142857142857
Jun 2014 0.457627118644068 0.542372881355932
Jul 2014 0.433962264150943 0.566037735849057
Aug 2014 0.315789473684211 0.684210526315789

Stefan
Telerik team
 answered on 21 Aug 2014
4 answers
130 views
I know this may seem like a ridiculous question, I may be missing something, but can someone explain to me what the point of the "Download..." and "Browse..." buttons are in the Solution Upgrade Wizard?

There's two things I can think of:

    a) the browse button is meant for me to select a new location then click the download button to download the new version, or
    b) the browse button is for me to select a folder where the assemblies currently exist and upgrade them with the download button

Here's why (in it's current form) it doesn't make sense or is just very unintuitive:

In both cases, the flow of the form is really strange.  Typically entry fields would go from top-down, left-right - or - left-right, top-down.  This upgrade form goes right-to-left.

That's not the real issue (but for a company who provides controls for helping with UX, you would think UX would be important in their own forms ;-) ... ).

I assumed I could click Browse, create a folder (why else would there be a "New Folder" option in the Folder Browse dialog?), and then download the assemblies to that location.  Is that assumption correct?

If that assumption is correct, then I think there's a bug or something, because I created a new folder, clicked the download button (which tells me it was already up to date), and my folder is empty.  See attached screenshots ...

Thank you
Dyanko
Telerik team
 answered on 20 Aug 2014
1 answer
92 views
When I import text into my rich text control (2014.2.715), the custom dictionary is lost.

I'm using the following code:
var provider = new RtfFormatProvider();
rtf.Document = provider.Import(value);

I'm using the following to set my custom dictionary:
var culture = CultureInfo.GetCultureInfo("en-AU");
var checker = (DocumentSpellChecker)rtf.SpellChecker;
if (!(checker.GetDictionary(culture) is AustralianDictionary))
{
checker.AddDictionary(new AustralianDictionary(), culture);
}
rtf.SpellChecker.SpellCheckingCulture = culture;

Am I doing something wrong?  What is the correct way to set a custom dictionary?


Dimitar
Telerik team
 answered on 20 Aug 2014
1 answer
177 views
Hello Again...

I want to be able to hide a Group in the Group By.

I am binding the grid to a custom business object.  For example:

​class PermissionBinding
{
     public string PermissionName { get; set; }
     public string PermissionGroup { get; set; }
}

And the data in a BindingList<PermissionBinding> (#id, Permission Name, Permission Group) has:
#0:    Create, Group 1
#1:    Edit, Group 1
#2:    View, Group 1
#3:    Delete, Group 1
​#4:    Create, Group 2
#5:    Edit, Group 2
#6:    View, Group 2
#7:    Delete, Group 2

... and so on.

So I bind the list to the grid via a BindingSource (all set up via the designer).  But I create my list and set it to the binding source using:

_permissions = CreatePermissionBinding();
this.permissionBindingBindingSource.DataSource = _permissions;

I use Custom Grouping to group the rows under each Permission group nicely using the following:

Field Members (used to order the Groups and format the group name)
private const string GroupSortFormat = "{0:D4}. {1}|{1}";
        private Dictionary<string, int> _groupOrder = new Dictionary<string, int>()
        {
            { "Group 1", 1 },
            { "Group 2", 2 },
            { "Group 3", 3 },
       };

Form Constructor
this.PermissionGridView.CustomGrouping += PermissionGridView_CustomGrouping;
this.PermissionGridView.GroupSummaryEvaluate += PermissionGridView_GroupSummaryEvaluate;
this.PermissionGridView.EnableCustomGrouping = true;            
this.PermissionGridView.GroupDescriptors.Add(new Telerik.WinControls.Data.GroupDescriptor("PermissionGroup"));

Event Handlers

        private void PermissionGridView_GroupSummaryEvaluate(object sender, Telerik.WinControls.UI.GroupSummaryEvaluationEventArgs e)
        {
            if (e.Value == null)
            {
                e.FormatString = e.Group.Key.ToString().Split('|')[1]; // strip out the order from the format string to show the group name
            }
        }
        
        private void PermissionGridView_CustomGrouping(object sender, Telerik.WinControls.UI.GridViewCustomGroupingEventArgs e)
        {
            var obj = (PermissionBinding)e.Row.DataBoundItem;
            e.GroupKey = string.Format(GroupSortFormat, _groupOrder[obj.PermissionGroup], obj.PermissionGroup); // make sure group is ordrered via string format
        }

Now suppose I want to hide Group 2.  Can I do it?

I have tried the following which only hides the rows in a group - it still shows the grouping Group 2:
foreach (var row in this.PermissionGridView.Rows)
{
        row.IsVisible = groups.Contains((row.DataBoundItem as PermissionBinding).PermissionGroup) ? true : false;


I have successfully done it by removing the groups from the binding source BindingList<PermissionBinding>.  But I see this as a view/filter on the data - suppose this is triggered by a user clicking a button.  I really don't want to create the data source each time as it is populated through the database.  Although it is not a major issue.  I could maintain 2 lists - one main list and one filtered.  But I was wondering if there was something in the Grid I had obviously missed to do this.

NOTE:  Telerik is seriously kicking a competitors product into touch the more I do with it ;)!

Thanks,

Andez
Dimitar
Telerik team
 answered on 20 Aug 2014
2 answers
132 views
Hi,

I have the following

provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "DispatchDate", GroupComparer = new GroupNameComparer() });
provider.ColumnGroupDescriptions[0].SortOrder = Telerik.Pivot.Core.SortOrder.Ascending;

DispatchDate is a Datetime field.

So far so good.

But can I format the date field to read MM YY (May 14) in the column header?

I tried to change the DispatchDate to a string, but that messes up the sort, so if I could format the date field that would be great.

Thanks
Shaun.





Shaun
Top achievements
Rank 1
 answered on 19 Aug 2014
1 answer
81 views
Hi,

When creating a new solution with an empty RadForm, the initial memory usage is around 30-40MB.
Is there anyway to reduce this memory usage?

Thanks in advance.

~ Erez
Dimitar
Telerik team
 answered on 19 Aug 2014
2 answers
337 views
Hello, I just wanted to know if there is any difference between the SelectedPageChanging and PageIndexChanging events.  I can't think of a single scenario where one would be used but not the other. 

Is there one that is suggested over the other? 

Is one deprecated but not the other? 

Thanks

PS, see attached screenshot - looks like some API Documentation may need some updating...
Stefan
Telerik team
 answered on 19 Aug 2014
5 answers
307 views
Dear Telerik Team

         see the screen dump
         how to set orange border of new RadButton disappear as old RadButton do.
because orange border will make theme of dialog look no perfect.

Regards
DiWu
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 19 Aug 2014
3 answers
74 views
Telerik Members:

How can I click date number to change to day view mode in month view mode?

Thank you.
Stefan
Telerik team
 answered on 19 Aug 2014
Narrow your results
Selected tags
Tags
GridView
General Discussions
Scheduler and Reminder
Treeview
Dock
RibbonBar
Themes and Visual Style Builder
ChartView
Calendar, DateTimePicker, TimePicker and Clock
DropDownList
Buttons, RadioButton, CheckBox, etc
ListView
ComboBox and ListBox (obsolete as of Q2 2010)
Chart (obsolete as of Q1 2013)
Form
PageView
MultiColumn ComboBox
TextBox
RichTextEditor
PropertyGrid
Menu
RichTextBox (obsolete as of Q3 2014 SP1)
Panelbar (obsolete as of Q2 2010)
PivotGrid and PivotFieldList
Tabstrip (obsolete as of Q2 2010)
MaskedEditBox
CommandBar
PdfViewer and PdfViewerNavigator
ListControl
Carousel
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
Documentation
SplitContainer
Map
DesktopAlert
CheckedDropDownList
ProgressBar
TrackBar
MessageBox
Rotator
SpinEditor
CheckedListBox
StatusStrip
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
CollapsiblePanel
TabbedForm
CAB Enabling Kit
GroupBox
WaitingBar
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
Styling
Barcode
BindingNavigator
PopupEditor
RibbonForm
TaskBoard
Callout
ColorBox
PictureBox
FilterView
NavigationView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
ButtonTextBox
FontDropDownList
BarcodeView
BreadCrumb
Security
LocalizationProvider
Dictionary
Overlay
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
SplashScreen
ToolbarForm
NotifyIcon
DateOnlyPicker
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?