Cannot display Tamil correctly in generated PDF [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 months ago.
Improve this question
Currently we are using Aspose.NET library to generate excel and export to PDF.
The pdf consists of multiple language such as English, Chinese and Tamil.
For English and Chinese it work fine but for Tamil is having spelling issue.
For example the first and second letter for "போல்" will flipped.
We have tried "Latha" font and "Arial Unicode MS" font, the text is showing but the letter is flipped.
We have tried "InaiMathi" font as well but the text is not showing.
I have also try to use different pdf generator such as ITextSharp as suggested in this page: How to Create PDF file with Tamil Font by using itextsharp in C#?
But the text still flipped. From the page, they said that ITextSharp does not fully support indic language.
Are there any pdf generator that support indic langauge?

Hi Have you looked at Google wkhtmltopdf.exe. I have used this without any issue
wkhtmltopdf.exe System.Security.SecurityException on cloud web server. How can i override server security policy
Only problem with this is that you need full trust level. If it is for intranet then this is the good option. if you are looking for I have tried this for arabic as well so tamil is not an issue.
Regards

Please refer related answer here. Try Quest PDF which supports Tamil text as well.
Create a console application and install the Quest PDF library and use the sample (in .NET 6) to see POC.
dotnet add package QuestPDF
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
Document.Create(container =>
{
container.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(2, Unit.Centimetre);
page.PageColor(Colors.White);
page.DefaultTextStyle(x => x.FontSize(20));
page.DefaultTextStyle(x => x.FontFamily("Vijaya"));
page.Header()
.Text("தமிழ் PDF!")
.SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);
page.Content()
.PaddingVertical(1, Unit.Centimetre)
.Column(x =>
{
x.Spacing(20);
x.Item().Text("தமிழ் (Tamil language) தமிழர்களினதும் தமிழ் பேசும் பலரின் தாய்மொழி ஆகும். தமிழ், உலகின் உள்ள முதன்மையான மொழிகளில் ஒன்றும் செம்மொழியும் ஆகும்.");
});
page.Footer()
.AlignCenter()
.Text(x =>
{
x.Span("பக்கம் ");
x.CurrentPageNumber();
});
});
})
.GeneratePdf("தமிழ்.pdf");

Related

Extracting frames of a .avi file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am trying to write a c# code to extract each frame of a .avi file and save it into a provided directory. Do you know any suitable library to use for such purpose?
Note: The final release must work on all systems regardless of installed codec, or system architecture. It must not require the presence of another program (like MATLAB) on the machine.
Thanks in advance.
Tunc
This is not possible, unless you add some restrictions to your input avi files or have control over encoder used to create them. To get an image you will have to decode it first, and for that you will need an appropriate codec installed or deployed with your app. And i doubt its possible to account for every codec out there or install/deploy them all. So no, you won't be able to open just any avi file. You can, however, support the most popular (or common in your context) codecs.
The easiest way to do it is indeed using an FFMPEG, since its alredy includes some of the most common codecs (if you dont mind extra 30+Mb added to your app). As for wrappers, i used AForge wrapper in the past and really liked it, because of how simple it is to work with. Here is an example from its docs:
// create instance of video reader
VideoFileReader reader = new VideoFileReader( );
// open video file
reader.Open( "test.avi" );
// read 100 video frames out of it
for ( int i = 0; i < 100; i++ )
{
Bitmap videoFrame = reader.ReadVideoFrame( );
videoFrame.Save(i + ".bmp")
// dispose the frame when it is no longer required
videoFrame.Dispose( );
}
reader.Close( );
There is also a VfW (which is included in Windows by default) wrapper in AForge, if you want to keep it simple without involving external libraries. You will still need VfW compatible codecs installed tho (some of them are included in Windows by default, most are not).
You could have a look at FFmpeg: http://www.ffmpeg.org/
Some C# related info: Using FFmpeg in .net?
or: http://www.ffmpeg-csharp.com/

have to extract data from a word file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a peculiar problem in that I have to extract information from a word file. Say for example I have a resume and need to extract name, email address, phone no., address, university,Experience etc.
Every other person may be having their resume in a different format.So is there any way by which I can programmatically extract the information I need?
I need this information to fill-up a form for registration.
Even if at first you might be attracted by the idea of using Com Interop and Asp.net, don't do it.
http://support.microsoft.com/kb/257757
That said, it's important to know which version of word are we talking about. Newer formats allow treat them as a zip containing xml files and there are good&free libraries.
http://docx.codeplex.com/
Convert the word document to html, with aspose .net.
Then you can use regular expressions to search the word and/or pdf documents.
Or you can use HTMLAgilityPack to parse the created HTML documents, and search for specific sections/paths.
PS:
If you have a regex for email that's shorter than one page, then the regex is incorrect.
Phone should be manageable, as long as you have to support only one country.
As for name and address, good luck with that.
Edit:
Like this
VB.NET:
Dim doc As New Aspose.Words.Document("filename.docORdocx")
doc.Save("filename.html", Aspose.Words.SaveFormat.Html)
C#:
Aspose.Words.Document doc = new Aspose.Words.Document("filename.docORdocx");
doc.Save("filename.html", Aspose.Words.SaveFormat.Html);
The component is here:
http://www.aspose.com/.net/word-component.aspx
To find out what a valid email address is, read RFC 822:
http://www.faqs.org/rfcs/rfc822.html

Convert Group 3 compressed TIFF to png or pdf in .net [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I search a way to convert a Group 3 compressed TIFF to png or for best in pdf with c#.net.
Try LibTiff.Net library for this.
The library comes with tiff2pdf utility (you would need to build it yourselves) that probably does exactly what you need. You may even incorporate the code of the utility in your application.
The library and utility are free and open-source. License (New BSD License) allows any modifications. You can use the library and utility in commercial applications.
Disclaimer: I am one of the maintainers of the library.
TIFF to PNG:
System.Drawing.Image will allow you to open a Group3 TIFF and save it as PNG simply by loading the TIFF as a normal image (e.g. Image.FromFile, Image.FromStream, etc.) and then saving it using the Image.Save method with the ImageFormat.Png argument. As TIFFs vary widely, on occasion I have encountered an obscure TIFF that System.Drawing won't open, but that is unusual. If it happens, you'll need to seek out a third party library from opensource (e.g. iText has a sophisticated image library) or there are commercial options such as Lead Tools or Atalasoft.
TIFF to PDF:
iTextSharp is a great library for doing this. I even found some articles on this specific topic with a google search. This one seems to be a good one to start with for your needs.
(disclaimer - I work for Atalasoft)
If you use dotImage for this, both conversions are trivial.
for tiff to pdf:
using (outputStream = new FileStream(pathToPdf, FileMode.Create)) {
PdfEncoder encoder = new PdfEncoder();
encoder.Save(outputStream, new FileSystemImageSource(pathToTiff, true), null); // true = do all pages
}
for tiff to png:
FileSystemImageSource source = new FileSystemImageSource(pathToTiff, true);
int page = 0;
while (source.HasMoreImages()) {
AtalaImage image = source[page];
using (FileStream stm = new FileStream("output_page_" + page + ".png", FileMode.Create)) {
PngEncoder encoder = new PngEncoder();
encoder.Save(stm, image, null);
}
source.Release(image);
}
Use ghostscript, i used to extract images from a PDF and create thumbnails, the lib also convert from images to PDF and it's open source.
A guy create a wrapper for the ghostscript API:
http://www.mattephraim.com/blog/2009/01/06/a-simple-c-wrapper-for-ghostscript/

Edit Metadata of PDF File with C# [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
i searching for methods or libarys to edit metadata of a pdf file like the programm becypdfmetaedit.
I want to write a program and i need this opton in this program.
Perhaps you have some samples for c#.
Thanks
Using PDF Sharp works like this:
using System;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main (string[] args)
{
Program p = new Program();
p.Test();
}
public void Test ()
{
PdfDocument document = PdfReader.Open ("Test.pdf");
document.Info.Author = "ME";
document.Save ("Result");
}
}
}
For PDFSharp:
If you would like to change/add the metadata on the Custom Properties of a PDF you can use the PdfDocument.Info.Elements object.
String filename = #"d:\temp\Hugo-input.pdf";
String outputfile = #"d:\temp\Hugo-output.pdf";
PdfDocument document = PdfReader.Open(filename);
document.Info.Elements.Add(new KeyValuePair<String,PdfItem>("/MyKey",new PdfString("MyValue")));
document.Save(outputfile);
Always start a custom key with a slash!
You can find the key and value when you open this document in Adobe Acrobat Reader -> File -> Properties -> Custom.
This works with PDFSharp 1.32
I suppose you can do it with iTextSharp.
Does the PdfDocumentInformation class from PDF Sharp fulfill your requirements.
Pimping here - my company, Atalasoft, makes .NET components for working with images. Part of the suite includes the ability to read/write PDF document metadata. It's not free, but it is run-time royalty free for desktop applications.
The code for reading is simple:
PdfDocumentMetadata metadata = PdfDocumentMetadata.FromStream(sourceStream);
to edit it and write it back to the same stream:
meta.Title = "Knicholas Knickleby";
meta.Author = "Edmund Wells";
sourceStream.Seek(0, SeekOrigin.Begin);
meta.Append(sourceStream, false); // false means don't merge - overwrite
Custom fields are supported through a hashtable.
Aspose.PDF or Aspose.PDF.Kit can do this for you.

Convert Rtf to HTML [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
We have a crystal report that we need to send out as an e-mail, but the HTML generated from the crystal report is pretty much just plain ugly and causes issues with some e-mail clients. I wanted to export it as rich text and convert that to HTML if it's possible.
Any suggestions?
I would check out this tool on CodeProject RTFConverter. This guy gives a great breakdown of how the program works along with details of the conversion.
Writing Your Own RTF Converter
There is also a sample on the MSDN Code Samples gallery called Converting between RTF and HTML which allows you to convert between HTML, RTF and XAML.
Mike Stall posted the code for one he wrote in c# here :
https://learn.microsoft.com/en-us/archive/blogs/jmstall/writing-an-rtf-to-html-converter-posting-code-in-blogs
UPDATED:
I got home and tried the below code and it does not work. For anyone wondering, the clipboard does not just magically convert stuff like I'd hoped. Rather, it allows an application to sort of "upload" a data object with a variety of paste formats, and then then you paste (which in my metaphor would be the "download") the program being pasted into specifies its preferred format. I personally ended up using this code, which has been recommended previously, and it was enormously easy to use and very effective. After you have imported the code (in VStudio, Project -> Add Existing Files) you then just go html to rtf like this:
return HtmlToRtfConverter.ConvertHtmlToRtf(myRtfString);
or the opposite direction:
return RtfToHtmlConverter.ConvertHtmlToRtf(myHtmlString);
(below is my previous incorrect answer, in case anyone is interested in the chronology of this answer haha)
Most if not all of the above answers provide comprehensive, often Library-based solutions to the problem at hand.
I am away from my computer and thus cannot test the idea, but one alternative, cheap and vaguely hack-y method would be the following.
private string HTMLFromRtf(string rtfString)
{
Clipboard.SetData(DataFormats.Rtf, rtfString);
return Clipboard.GetData(DataFormats.Html);
}
Again, not totally sure if this would work, but just messing around with some html on my iPhone I suspect it would. Documentation is here. More in depth explanation/docs RE the getting and setting of data models in the clipboard can be found here.
(Yes I am fully aware I'm here years later, but I assume this question is one which some people still want answered).
If you don't mind getting your hands dirty, it isn't that difficult to write an RTF to HTML converter.
Writing a general purpose RTF->HTML converter would be somewhat complicated because you would need to deal with hundreds of RTF verbs. However, in your case you are only dealing with those verbs used specifically by Crystal Reports. I'll bet the standard RTF coding generated by Crystal doesn't vary much from report to report.
I wrote an RTF to HTML converter in C++, but it only deals with basic formatting like fonts, paragraph alignments, etc. My translator basically strips out any specialized formatting that it isn't prepared to deal with. It took about 400 lines of C++. It basically scans the text for RTF tags and replaces them with equivalent HTML tags. RTF tags that aren't in my list are simply stripped out. A regex function is really helpful when writing such a converter.
I think you can load it in a Word document object by using .NET office programmability support and Visual Studio tools for office.
And then use the document instance to re-save as an HTML document.
I am not sure how but I believe it is possible entirely in .NET without any 3rd party library.
I am not aware of any libraries to do this (but I am sure there are many that can) but if you can already create HTML from the crystal report why not use XSLT to clean up the markup?
You can try to upload it to google docs, and download it as HTML.

Categories