How to display the "markdown" in windows 8 apps? - c#

I have markdown, how i can display formatted text in win 8 apps?
Things i have tried, that may or may not be useful to any answer
I tried converting markdown to rtf and show result in RichTextBlock, but I have problem with markdown to rtf converting.

Hmmm. Trickier than I suspected...
I'd suggest using markdownsharp to derive html from your markdown and to display that in an html view. (of which I'm sure "Windows 8 apps" have at least one)
EDIT
You can then either show this in a WebView or follow this article to convert to rtf.

I wrote this Markdown parser in C#, which exports to HTML and XAML. If you generate XAML, you can access it by using the XamlReader class and display it in a WPF application. (You can also display the HTML version if you choose to.)
https://github.com/PeterWaher/IoTGateway/tree/master/Content/Waher.Content.Markdown
It's part of a larger project:
https://github.com/PeterWaher/IoTGateway/

Related

Alternative for Word-wrap property in CSS for ITextSharp application

I am trying to wrap textual content within a specific width , but wasn't able to wrap the content within limit. Does anyone have an alternative to achieve word-wrap?
You should show us what you've already done,
give us some code.
You can also try out pdfHTML (it's the newest iText add-on that converts HTML to pdf).
http://itextpdf.com/itext7/pdfHTML
pdfHTML also allows you to convert html code to iText IElement implementations, which you can then style like regular iText objects. We have some good tutorials that show you how to work with the basic building blocks.
http://developers.itextpdf.com/content/itext-7-building-blocks/examples

Need helping exporting HTML or Block data as a document in WinRT

I'm running into a problem that I can't seem to figure out. The scenario is:
Download a bunch of text data as an HTML string
Use an HTML-to-Xaml converter to parse the HTML string and create a List<Block> (Windows.UI.Xaml.Documents.Block).
Display the collection of Blocks as a RichTextBlock control that's available in WinRT.
All of that works well. The problem is, I want to export this data as either a doc/docx or pdf file. Is there a way to export either the RichTextBlock directly or add these Blocks to a RichEditBox or even use the original HTML string to export to the file?
I looked at the Syncfusion Essential Studio, that offers the RichTextBoxAdv control, that's used as:
xmlns:rtba="using:Syncfusion.UI.Xaml.RichTextBoxAdv">
<Grid>
<rtba:SfRichTextBoxAdv>
</rtba:SfRichTextBoxAdv>
</Grid>
But so far as I can tell, there is no way to import Block data or use an HTML string. The latter used to exist in WPF but it's not there anymore. Any suggestions?
Syncfusion SfRichTextBoxAdv control for WinRT supports importing and exporting HTML document, Word document, Rich Text Format document and Text document. With the help of this functionality, you can easily achieve your requirement by using Syncfusion SfRichTextBoxAdv control. Please do find the sample from below link.
Sample link:
http://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample-2055612463
Kindly go through the online KB from following link, to know more information about binding HTML string to SfRichTextBoxAdv control.
https://www.syncfusion.com/kb/5415/how-to-bind-html-text-in-sfrichtextboxadv-control
Regards,
Arumuga Perumal S.

Creating PDFs Online

We are using Report Definition laguage (RDL) templates to define various reports in one of our Sharepoint applications. These reports are (then) saved as PDFs into various SharePoint Document Library's. One report in-particular renders, but is considered to be "failing" due to the styling needs of the report. So it appears RDL only understand "very simple" HTML.
For Example:
Trademark characters are not rendering as superscript (they render as normal text instead)
The ability to assign Line Height fails
The ability to assign Word Spacing fails (so printers "leading" requirements fail)
Both of these point to various marked Microsoft limitation for RDL's to interprint various HTML...of which we are now aware.
So...
I need a better tool...and we are scratching our heads on this one!
QUESTION:
What tools take-in HTML, understand CSS (well!) and can generate PDFs from C-Sharp objects?
Please keep in-mind I need the to PDF generator tools you recommend (below) to understand CSS and HTML.
NOTE:
I looked at the various other StackEchange sites to see if there is a better forum for this particular question, but this one was the only one that seemed to fit-the-bill. If you are a mediator, and feel this question is mis-placed, please feel free to move this question.
This HTML to PDF converter has the most accurate conversion of a complex html/css page. There is also a demo to try the conversion with your html
Maybe you can give Amyuni WebkitPDF a try. It is a Free component for converting HTML+CSS into PDF files. From the home page:
Directly convert HTML files into PDF without the use of a web browser or a printer driver
Convert HTML files into XAML/XPS for rendering within Silverlight
Integrate and deploy the HTML conversion feature within your applications
Generate either a single continuous PDF page or split the HTML into multiple PDF pages
Amyuni WebkitPDF is distributed as a library with a sample application, and sample code for C++ and C#.
Disclaimer: I currently work as software developer at Amyuni Technologies.
I only know a workaround for the "leading space" issue. This example "leads" the value with 10 spaces:
=space(10) & Fields!FieldName.Value
This should work for any renderer, I'll update this if I come around other tricks.
Have a look at Aspose.Pdf for .NET: http://www.aspose.com/categories/.net-components/aspose.pdf-for-.net/default.aspx

Richtextbox to iTextSharp

Context
What we need is to capture some user input (formatted text) from a WPF application and output a PDF with some stored images AND the user input on the last page.
What we've tried
We create the WPF app, add the iTextSharp library, recover the images from the DB and add it to the PDF. That's working. Now, for the user input we added a RichTextBox control from the Extended WPF Toolkit. We added this control mainly because of its binding properties and formatters. Basically we can bind the rich content of the control to a property. That binding is working. We already have the RTF format, as (in example):
"{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0 \cf0\ql{\f2 {\ltrch This is the }{\b\ltrch RichTextBox}\li0\ri0\sa0\sb0\fi0\ql\par}}}"
Problem
The thing is, the actual output of the PDF is precisely that previously shown RTF, but the expected output (for the example) must be:
"This is the **RichTextBox**\r\n"
This is happening obviously because we are inserting the binded RTF from the control as it comes to the PDF, the thing is: How can we add that content and specify its RTF?
PS. If you have other working idea or solution (without using a richtextbox, or something like that) it's welcome. Thanks in advance.
Unfortunately, iTextSharp does not directly support RTF format anymore. I would suggest to convert the RTF fragment to XHTML first and then import the resulting XHTML into the final document (it seems that the official HTML support is gone away, so XHTML is the only alternative in this case).
In short, I would suggest to:
convert the RTF fragment into XHTML;
place the XHTML stream into a new iTextSharp document (or directly into the final document, if you wish);
add the content of the aforementioned document into the target document you are going to export as PDF.
UPDATE
There is no built-in mechanism to convert from RTF to XHTML but many open source project exist; I would start coupling this RTF to HTML converter with the HTML Agility Pack (which will in turn convert your HTML to XHTML).
Frankly, however, the whole flow is a bit complex to follow and I would perhaps opt for a simpler solution, maybe by using an HTML editor (alternative) directly in your project or by reverting to the FlowDocument as others have suggested.
WPF already had a good FlowDocument and it does good rendering. So we created Xaml to PDF converter, its in beta, but most String, Table and Images are converted to PDF successfully, its an open source project available at, http://xamltopdf.codeplex.com/ , RTF can give you FlowDocument and you can convert it to XAML and pass it on to XamlToPDF converter.

Converting pdf to text

I need to create a C# or C++ (MFC) application that converts pdf files to txt. I need not only to convert, but remove headers, footers, some garbage characters on the left margin etc. Thus the application shold allow the user to set page margins to cut off what is not needed. I actually have already created such an application using xpdf, but it gives me some problems when I am trying to insert custom tags into the extracted text to preserve italics and bold. Maybe somebody could suggest something useful?
Thanks.
There are shareware and freeware utilities out there. Try fetching their source code, or perhaps use them the way they are.
A public version of the PDF specification can be found here: Adobe PDF Specification
PDF Shareware readers can be found: PDF Reader source code # SourceForge
Please look at Podofo. It's a LGPL-licensed library that has many powerful editing features. One of it's examples, txt2pdf IIRC, is a good start: it shows basic text-extraction; From there you can check if pre (in pdf engine) or post (in text) filtering suffices to your goals. I didn't get to use Pdf Hummus, but it's supposed to have these capabilities too, although it's less straightforward.

Categories