Example #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                string file = "Report.lst";
                if (!File.Exists(file))
                {
                    file = ChooseFile();
                }

                if (File.Exists(file))
                {
                    ExportConfiguration config = new ExportConfiguration(LlExportTarget.Pdf, Path.Combine(Path.GetTempPath(), "statistics.pdf"), file);
                    config.ShowResult = true;
                    config.BoxType    = LlBoxType.NormalMeter;
                    InitDataSource();
                    _lL.Export(config);
                }
            }
            catch (ListLabelException)
            {
            }
            catch (DbException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        public static void ExportAsPdf(string labelDefinition, IEnumerable <Object> data, string parentEntity, string targetFilePath)
        {
            using (var listLabel = new ListLabel())
            {
                listLabel.LicensingInfo = ListLabelLicenseString;

                // Set up the dataset
                listLabel.DataSource = new ObjectDataProvider(data)
                {
                    FlattenStructure = true,
                };
                listLabel.DataMember     = parentEntity;
                listLabel.AutoMasterMode = LlAutoMasterMode.AsVariables;

                // Configure the designer to read the report design from a memoryStream
                var memoryStream = new MemoryStream();
                if (labelDefinition != null)
                {
                    var stringBytes = Encoding.Unicode.GetBytes(labelDefinition);
                    memoryStream.Write(stringBytes, 0, stringBytes.Length);
                }

                // Launch the designer
                var exportConfiguration = new ExportConfiguration(
                    LlExportTarget.Pdf,
                    targetFilePath,
                    memoryStream)
                {
                    ShowResult = false,
                };
                listLabel.Export(exportConfiguration);
            }
        }