Telerik Forums
Telerik Document Processing Forum
3 answers
178 views
Language: VB.NET

Hello,

I'm looking to use CompressedStream solution without really understanding its use.

What I am trying to do:
1. compress file.
2. Insert the compressed file into my Database.
3. Retrieve compressed file to unzip it.
4. Read file.

How can I efficiently compress the file ?
Which method should I use ?
What type of variable should I deal with ? (String, Byte ()?)

Would you have a functional example in .net to help me ?

Thanks for your help
Tanya
Telerik team
 answered on 07 Sep 2018
1 answer
594 views

Hello!

I'm trying to add fields from a database into a pdf like the image attached shows. I already read the FormFieldCollection documentation, but I'm lacking the knowledge to make it work.

 

Can someone please include a code example on how to do this ?

Polya
Telerik team
 answered on 07 Sep 2018
2 answers
104 views

Hi,

I have form fields that are set to "Visible but doesn't print" but it does not seem to have any effect on the PDF after setting the values using the library.

Not sure if I am doing something wrong.

Thanks.

Haron
Top achievements
Rank 1
 answered on 05 Sep 2018
9 answers
552 views

Hi Guys,

I'm finding a solution for two questions using PdfProcessor:

1 - There is a way to convert a pdf document to GrayScale ?

2 - There is a way to compress a existing pdf document ?

 

Regards,

Cleidson.

 

 

Tanya
Telerik team
 answered on 31 Aug 2018
3 answers
434 views
is there a way to convert a div and all its inner html to a pdf.
Peter Milchev
Telerik team
 answered on 23 Aug 2018
1 answer
360 views
Is there a mechanism to flatten AcroForm fields? Meaning I want to remove the controls and have the visual representation of the form. I am automatically filling an AcroForm and want to merge many together to create one document (many pages) of the same AcroForm with the data on each page being different. Users will print the documents and shouldn't be able to change them via the form fields.This seems to be pretty standard for pdf libraries but I can't seem to find it in this one.
Boby
Telerik team
 answered on 22 Aug 2018
1 answer
86 views

Hi,

I need to get the the number of occurrences of a text into word document page wise. Is telerik wordProcessing supports searching for a text into word document  page wise? i.e. to search for a text into document page by page and find the number of occurrences.

I would appreciate if you can help me with this.

Thanks,
Savi

Tanya
Telerik team
 answered on 03 Aug 2018
1 answer
465 views
I'm working on a program that creates DOCX file from JSON data using Telerik word processing library. This file uses RTL language scripts.The problem is there is no way to set font style for complex script (not Latin) in styles. for example I set the font size to 11 but when I set the Run's FlowDirection to RightToLeft, the library ignores the font size and uses the default size (the size  for Latin script).  How can I set font size for complex scripts (like Arabic or Persian) ?
Tanya
Telerik team
 answered on 01 Aug 2018
1 answer
347 views

Hi, I'm using the Spread Stream Processing to generate an excel file with 93 columns. All the columns are formatted as strings with an average size of approximately 10-20 characters. I implemented this feature because I need to create excel files of approximately 60k - 80k rows. Currently, I receive an exception when exporting data with 695 rows or more. 

This is the exception I receive: 

Data: System.Collections.ListDictionaryInternal
Message: The Writer is closed or in error state.
Source: System.Xml 
Stack Trace: at System.Xml.XmlWellFormedWriter.AdvanceState(Token token) at System.Xml.XmlWellFormedWriter.WriteEndElement() at Telerik.Documents.SpreadsheetStreaming.ImportExport.Core.ConsecutiveElementBase.EndWriteElement() at Telerik.Documents.SpreadsheetStreaming.ImportExport.Core.ConsecutiveElementBase.EnsureWritingEnded() at Telerik.Documents.SpreadsheetStreaming.ImportExport.Core.ConsecutiveElementBase.EnsureWritingEnded() at Telerik.Documents.SpreadsheetStreaming.ImportExport.Core.ConsecutivePartWriterBase`1.EndWrite() at Telerik.Documents.SpreadsheetStreaming.ImportExport.Core.ConsecutivePartWriterBase`1.CompleteWriteOverride() at Telerik.Documents.SpreadsheetStreaming.Core.EntityBase.Dispose(Boolean disposing) at Telerik.Documents.SpreadsheetStreaming.XlsxWorksheetExporter.DisposeOverride() at Telerik.Documents.SpreadsheetStreaming.Core.EntityBase.Dispose(Boolean disposing) at Telerik.Documents.SpreadsheetStreaming.Core.EntityBase.Dispose() at ERMgtProgram.Controllers.DigitalMerchandising.ViewAllExportController.<GenerateDocument>d__4.MoveNext() in C:\Users\erit12u\source\repos\ERMgtProgram\ERMgtProgram\Controllers\DigitalMerchandising\Import\ViewAllExportController.cs:line 107
Target Site: Void AdvanceState(Token)

 

This is the code that generates the exception: 

01.// When this code is called for the 695th time it throws an exception at line 2
02.using (IRowExporter rowExporter = worksheetExporter.CreateRowExporter())
03.{
04.    rowExporter.SetHeightInPoints(rowHeight);
05. 
06.    foreach(var column in template)
07.    {
08.        using (ICellExporter cellExporter = rowExporter.CreateCellExporter())
09.        {
10.            var val = entities[rowIndex].Properties.Keys.Contains(column.FinalColumnName) ? entities[rowIndex].Properties[column.FinalColumnName].StringValue : string.Empty;
11.            cellExporter.SetValue(val);
12.            cellExporter.SetFormat(normalFormat);
13.        }
14.    }
15.}

 

 

This is all of my relevant source code: 

001.[HttpPost]
002.public async Task<ActionResult> GenerateDocument()
003.{
004.    byte[] renderedBytes = null;
005.    var mimeType = "application / vnd.openxmlformats - officedocument.spreadsheetml.sheet"; ;
006.    var fileExtension = "xlsx";
007.    try
008.    {
009.        // retrieve database data
010.        var tableName = _dmP3AzTableName;
011.        // retrieve all entities in azure table
012.        CloudStorageAccount storageAccount = _storageConn.GetStorageConnection();
013.        CloudTable table = storageAccount.CreateCloudTableClient().GetTableReference(tableName);
014.        table.CreateIfNotExists();
015.        var entities = await AzureOperation.RetrieveEntitiesAsync(table, null, 1000);
016.        if (entities == null)
017.        {
018.            TempData["ErrorMessage"] = "Unable to retrieve records. Please try again later.";
019.            return RedirectToAction("Index", "ImportPhaseThree");
020.        }
021.        var template = new List<TemplateSupport>();
022.        using (var db = new DataMgtEntities())
023.        {
024.            template = db.TemplateSupports.OrderBy(p => p.PageOrder).ToList();
025.        }
026.        var headerRowHeight = 15;
027.        var columnHeaders = template.Select(p => p.ImportColumnName).ToArray();
028.        var columnWidthsList = new List<double>();
029.        foreach (var header in columnHeaders)
030.        {
031.            columnWidthsList.Add(25.0);
032.        }
033.        var columnWidths = columnWidthsList.ToArray();
034.        var rowHeight = 15;
035.        MemoryStream documentStream = new MemoryStream();
036.        //documentStream.SetLength(int.MaxValue/10);
037.        var selectedDocumentFormat = SpreadDocumentFormat.Xlsx;
038. 
039.        using (IWorkbookExporter workbookExporter = SpreadExporter.CreateWorkbookExporter(selectedDocumentFormat, documentStream))
040.        {
041.            using (IWorksheetExporter worksheetExporter = workbookExporter.CreateWorksheetExporter("Phase 3 All Records"))
042.            {
043.                for (int i = 0; i < columnWidths.Length; i++)
044.                {
045.                    using (IColumnExporter columnExporter = worksheetExporter.CreateColumnExporter())
046.                    {
047.                        columnExporter.SetWidthInCharacters(columnWidths[i]);
048.                    }
049.                }
050. 
051.                ExportHeaderRows(worksheetExporter, headerRowHeight, columnHeaders);
052.                SpreadCellFormat normalFormat = new SpreadCellFormat
053.                {
054.                    FontSize = 11,
055.                    VerticalAlignment = SpreadVerticalAlignment.Bottom,
056.                    HorizontalAlignment = SpreadHorizontalAlignment.Left
057.                };
058. 
059.                for (var rowIndex = 0; rowIndex < entities.Count(); rowIndex++)
060.                {
061.                    using (IRowExporter rowExporter = worksheetExporter.CreateRowExporter())
062.                    {
063.                        rowExporter.SetHeightInPoints(rowHeight);
064. 
065.                        foreach(var column in template)
066.                        {
067.                            using (ICellExporter cellExporter = rowExporter.CreateCellExporter())
068.                            {
069.                                var val = entities[rowIndex].Properties.Keys.Contains(column.FinalColumnName) ?
070.                                    entities[rowIndex].Properties[column.FinalColumnName].StringValue : string.Empty;
071.                                cellExporter.SetValue(val);
072.                                cellExporter.SetFormat(normalFormat);
073.                            }
074.                        }
075.                    }
076.                }
077.            }
078.        }
079.        renderedBytes = documentStream.ToArray();
080.    }
081.    catch (Exception ex)
082.    {
083.        TempData["ErrorMessage"] = "An exception occurred. Please see error log for details, and try again later.";
084.        ErrLog.LogError(ex, "ViewAllExport.GenerateDocument");
085.        return RedirectToAction("ViewAll", "ImportPhaseThreeExports");
086.    }
087.    return File(renderedBytes, mimeType, "Phase3AllData." + fileExtension);
088.}
089. 
090.private void ExportHeaderRows(IWorksheetExporter worksheetExporter, int HeaderRowHeight, string[] ColumnHeaders)
091.{
092.    try
093.    {
094.        using (IRowExporter rowExporter = worksheetExporter.CreateRowExporter())
095.        {
096.            rowExporter.SetHeightInPoints(HeaderRowHeight);
097. 
098.            SpreadCellFormat format = new SpreadCellFormat
099.            {
100.                FontSize = 11,
101.                Fill = SpreadPatternFill.CreateSolidFill(new SpreadColor(122, 122, 122)),
102.                ForeColor = new SpreadThemableColor(new SpreadColor(255, 255, 255)),
103.                HorizontalAlignment = SpreadHorizontalAlignment.Left,
104.                VerticalAlignment = SpreadVerticalAlignment.Bottom
105.            };
106. 
107.            for (int i = 0; i < ColumnHeaders.Length; i++)
108.            {
109.                using (ICellExporter cellExporter = rowExporter.CreateCellExporter())
110.                {
111.                    cellExporter.SetFormat(format);
112.                    cellExporter.SetValue(ColumnHeaders[i]);
113.                }
114.            }
115.        }
116.    }
117.    catch(Exception ex)
118.    {
119.        ErrLog.LogError(ex, "ViewAllExport.ExportHeaderRows");
120.    }
121.}

 

Any and all help is appreciated. This is a time sensitive concern as I have to find a solution for this issue ASAP. Thank you for your time.

Best,

Ruben

Tanya
Telerik team
 answered on 31 Jul 2018
5 answers
275 views

I have A  xlsx file as  Data Template。

for     

Peshito
Telerik team
 answered on 25 Jul 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?