Hi,
We have a threaded service where we export excel documents to PDF documents (using Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider.Export) and then merge the PDF with other PDF documents (using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.Import and RadFixedDocument.Merge). We make sure to dispose the Workbook of the excel document and the MemoryStream from exporting to PDF.
After some time we start getting the following error, until we restart the service.
One or more errors occurred.
at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Telerik.Windows.Documents.Utilities.TasksHelper.DoAsync(Action[] actions)
at Telerik.Windows.Documents.Spreadsheet.Layout.RadWorksheetLayout.CalculateCellContentSizes(List`1 cellsToCalculateContentSize, CellProperties[] cellsFontProperties)
at Telerik.Windows.Documents.Spreadsheet.Layout.RadWorksheetLayout.UpdateCellContentSizesCache()
at Telerik.Windows.Documents.Spreadsheet.Layout.RadWorksheetLayout.Measure()
at Telerik.Windows.Documents.Spreadsheet.Model.Workbook.UpdateWorksheetLayout(RadWorksheetLayout worksheetLayout, Worksheet worksheet, Boolean isForPrinting)
at Telerik.Windows.Documents.Spreadsheet.Model.Shapes.ShapeCollection.GetTopLeftPoint()
at Telerik.Windows.Documents.Spreadsheet.Model.Shapes.ShapeCollection.GetTopLeftCellIndex()
at Telerik.Windows.Documents.Spreadsheet.Model.Shapes.ShapeCollection.RecalculateUsedCellRange()
at Telerik.Windows.Documents.Spreadsheet.Model.Worksheet.get_TotalUsedCellRange()
at Telerik.Windows.Documents.Spreadsheet.Layout.PageLayout.AddPages(Worksheet worksheet, Boolean ignorePrintArea)
at Telerik.Windows.Documents.Spreadsheet.Layout.PageLayout.PreparePages(Workbook workbook, Boolean ignorePrintArea)
at Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(Workbook workbook, Stream output)
...
...
Inner exception: The operation completed successfully
at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d)
at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
at System.Windows.Threading.Dispatcher..ctor()
at System.Windows.Threading.Dispatcher.get_CurrentDispatcher()
at System.Windows.Media.TextFormatting.TextFormatter.FromCurrentDispatcher(TextFormattingMode textFormattingMode)
at System.Windows.Media.FormattedText.LineEnumerator..ctor(FormattedText text)
at System.Windows.Media.FormattedText.DrawAndCalculateMetrics(DrawingContext dc, Point drawingOffset, Boolean getBlackBoxMetrics)
at System.Windows.Media.FormattedText.get_Metrics()
at Telerik.Windows.Documents.Core.TextMeasurer.RadTextMeasurer.MeasureTextWithWrapping(TextProperties textProperties, FontProperties fontProperties, Double wrappingWidth)
at Telerik.Windows.Documents.Spreadsheet.Measurement.RadTextMeasurer.Measure(String text, FontProperties fontProperties, Nullable`1 wrappingWidth)
at Telerik.Windows.Documents.Spreadsheet.Measurement.RadTextMeasurer.MeasureMultiline(String text, FontProperties fontProperties, Nullable`1 wrappingWidth)
at Telerik.Windows.Documents.Spreadsheet.Layout.LayoutHelper.DefaultTextMeasuringMethod(String text, FontProperties fontProperties, Nullable`1 wrappingWidth)
at Telerik.Windows.Documents.Spreadsheet.Layout.LayoutHelper.CalculateCellContentSize(ICellValue cellValue, CellValueFormat format, FontProperties fontProperties, Double cellIndent, Nullable`1 wrappingWidth, Func`4 measureMultilineText)
at Telerik.Windows.Documents.Spreadsheet.Layout.RadWorksheetLayout.<>c__DisplayClass4.<
CalculateCellContentSizes
>b__1()
at System.Threading.Tasks.Task.Execute()
Any help on why this happens and how we can fix it would be appreciated.
I am trying to export my document but I am getting the error attached to the thread.
I can fix this by going into the properties of the document and checking the unblock box. Is there a way to do this in the export to be able to just open the document without having to go into its properties? I get the same error on the demo page for generating word documents https://demos.telerik.com/aspnet-ajax/wordsprocessing/generate-documents/defaultcs.aspx
Here is my code for export
RadFlowDocument document = report.GenerateDoc();
DocxFormatProvider provider = new DocxFormatProvider();
MemoryStream ms = new MemoryStream();
provider.Export(document, ms);
byte[] byteArray = ms.ToArray();
ms.Dispose();
return File(byteArray, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "AAR.docx");
Hello, tell me please, can I do such a thing as merge/group cells in table with the same values when I export datatable from SQL base to word document
if so answer with code example
what exactly I want represent on attached files
When writing to a FileStream with PdfStreamWriter.WritePage, either implicitly or after the PdfStreamWriter loses scope... A PDF document gets created correctly specifically with the ending portion of the PDF document that handles the %EOF and the portions just prior to that.
When this same process is done with a MemoryStream (not a file) for the purposes of taking that "PDF DOCUMENT" and saving the byte() to a database, that ending part of the PDF document doesn't get created... and thus it becomes a corrupt (unreadable) PDF file. This ending portion of the PDF document that I'm referring to looks like this: (example):
xref
0 26
0000000000 65535 f
0000350400 00000 n
0000350089 00000 n
0000000017 00000 n
0000000204 00000 n
0000000440 00000 n
0000000699 00000 n
0000150134 00000 n
0000150319 00000 n
0000150473 00000 n
0000150732 00000 n
0000232360 00000 n
0000232502 00000 n
0000232814 00000 n
0000232842 00000 n
0000233014 00000 n
0000233544 00000 n
0000233799 00000 n
0000346061 00000 n
0000346138 00000 n
0000346322 00000 n
0000346637 00000 n
0000346892 00000 n
0000350305 00000 n
0000350459 00000 n
0000350528 00000 n
trailer
<</Size 26 /Root 24 0 R /ID [<b3a969414ce82cc43f271ef24e965a21> <b3a969414ce82cc43f271ef24e965a21>] >>
startxref
350975
%%EOF
What do I have to do after .WritePage with a backing MemoryStream... to eventually grab that byte() with a complete PDF document that includes the %%EOF piece... like for example:
Dim
contentLength
As
Int64 = msOutputStream.Length
Dim
aryBuffer(contentLength - 1)
As
Byte
aryBuffer = msOutputStream.ToArray
After the WritePage, the above will NOT include that ending segment of the PDF document/file.
I can't really .Close the MemoryStream, because then it isn't accessible at all... Does it need to be a part of a USING statement in some way? I have the PdfStreamWriter in a USING... and I do NOT need to have the FileStream as part of a USING and it works correctly.
Some full sample code:
Dim
documentsToMerge
As
String
() = {
"d:\SignaturePageToAppend.pdf"
}
Dim
msOutputStream
As
MemoryStream =
New
MemoryStream()
Using memoryWriter
As
Pdf.Streaming.PdfStreamWriter =
New
Pdf.Streaming.PdfStreamWriter(msOutputStream)
Dim
pdfOutputProv
As
Pdf.PdfFormatProvider =
New
Pdf.PdfFormatProvider(msOutputStream)
For
Each
documentName
As
String
In
documentsToMerge
'This is initializing the MemoryStream with a good Byte() PDF from a DB
Dim
msAddedPagePDF
As
MemoryStream =
New
MemoryStream(docAddedPage.FSDocument)
Using fileToMerge
As
Pdf.Streaming.PdfFileSource =
New
Pdf.Streaming.PdfFileSource(msAddedPagePDF)
Dim
pdfAddedPage1
As
Pdf.Streaming.PdfPageSource = fileToMerge.Pages.FirstOrDefault
memoryWriter.WritePage(pdfAddedPage1)
End
Using
'TBD
Dim
contentLength
As
Int64 = msOutputStream.Length
Dim
aryBuffer(contentLength - 1)
As
Byte
aryBuffer = msOutputStream.ToArray
'aryBuffer will NOT include the ending PDF segment to complete the PDF document
'Saving Byte() to DB
'docSource.FSDocument = aryBuffer
'trDocumentRepository.Update(docSource)
'trDocumentRepository.FlushAndSaveChanges()
Next
End
Using
Hi Admin,
With using RadFixedDocument, I tried to import a PDF AcroForm that have signature
then fill data then export to byte array.
But It's always throw exception when use function export
Can you support?
Thank you
Hi admin,
With Telerik reporting (RadPdfProcessing), could we able to do bellow?
1. Load existed an AcroForm as template
2. Auto fill data to this template with data in the database
3. Generate to new non editable PDF file
If can do, please post the guideline
Thank you for supporting
Best regards,
How do you add symbols, specifically "registered" and "copyright" to the pdf export? Id displays in Visual Studio when creating the text, but it doesn't display after the PDF is generated.
Thanks!
Hi all,
Does Telerik RadFlowDocument or RadFlowDocumentEditor support Track Changes & Lock Tracking of Microsoft Office files(.DOCX)?
Is there any alternative for the same?
Dear Concerned,
I am successfully able to merge multiple documents (.DOCX) in to a single document using RadFlowDocument.Merge function.
Now I want to split this document back into multiple documents. please suggest how to proceed?
Hi Team,
I was able to convert a word document to PDF using telerik wordsprocessing (https://demos.telerik.com/aspnet-ajax/wordsprocessing/exporttopdf/defaultvb.aspx?show-source=true),this works excellent for simple word documents and not for documents like certificates or a background image with text on it.
Does Telerik WordsProcessing support conversion of word document such as certificates or any documents with background image and text on top of it?
If not , will this be fixed in next update?
Is there any other control or way to convert word( like certificates) to pdf ?
SAMPLE CERTIFICATE: https://omextemplates.content.office.net/support/templates/en-us/tf03982379.dotx (convert this to docx)