Saturday, March 27, 2010

Converting PDF to Word Documents

Converting PDF to Word Documents

Summary: One way that documents are commonly shared with others is in the form of a PDF file. Getting information from a PDF file back into a Word format can be a challenge, however. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)


One of the most common ways of disseminating information is through PDF files. PDF, which stands for Portable Document Format, is the file format used by Adobe Acrobat. Many people receive information in PDF format, but then want to transfer that information to a Word document so they can work with it.
There are a couple of ways that you can get text from a PDF file to a Word document. Exactly which ones you can use depends on how the PDF file is protected. If the file is not protected, try these steps:
Open the PDF document and display the page that contains the text you want to copy to Word.
Click the Text tool on the toolbar.
Click and drag to select the text you want to copy, or (if you want to select all the text) click once in the text area and press Ctrl+A.
Press Ctrl+C to copy the selected text to the Clipboard.
Switch to your Word document.
Press Ctrl+V to paste the contents of the Clipboard into your document.
This transfers the text to your Word document. It is only the plain, unformatted text, but you can now work with it in Word.
If you have Adobe Acrobat 7 (or a later version) you can actually export a PDF document in either RTF or Word document format. (This won't work with Adobe Reader; you must have the full version of Acrobat.) Simply load the PDF and choose File | Save As. In the dialog box, choose Word document as the Save As Type. When you click Save, the document file is created.
If the PDF file is protected (authors can set security settings on PDF files so they are protected), then you won't be able to use either of the foregoing solutions. Instead, you will need to look to a third-party solution.
If you already have a scanner and OCR software, you can print the PDF file, then scan the document and use the OCR software to convert it to a Word document. One company has taken the OCR process a step further, allowing you to skip the scanning and instead convert directly from PDF. If you are interested in this product, it is called PDF Transformer, from ABBYY software:
http://www.abbyy.com/pdftransformer/
One thing that you should be aware of is that when you convert your PDF file to a Word document, that doesn't mean that the Word document will look like the original PDF looks. In most cases, the Word document will need a lot of formatting to make it look the way you want. The bottom line? You should only focus on getting the content from the PDF to Word, and not on the formatting; you can always do the formatting later.

How to Copy and Paste pdf format(file) into wort or any other file

When you need to convert only a part of the content in a PDF file to Microsoft Word, you can use the selection tools in Adobe Acrobat 6 Professional to copy and paste the required content without losing the formatting. You can copy text, tables, as well as images or parts of images, for pasting in Word. A note:THIS WILL NOT WORK IN THE FREE/BASIC VERSION OF ADOBE ACROBAT
editSteps

1To copy text from a PDF document
2Click the arrow on the Basic toolbar and select Select Text from the drop-down menu.
The pointer changes to a cursor shape.


3Select the text you want to copy.


4Press Ctrl + C to copy the selected text.
5In a Microsoft Word document, press Ctrl + V to paste the copied text.
The text is pasted in the Word document with loss of formatting.
6To copy a table from a PDF document
7Click the arrow on the Basic toolbar and select Select Table from the drop-down menu.
The pointer changes to a cross-hair shape [

].
8Drag the pointer to draw a border around the table you want to copy.


9Press Ctrl + C to copy the selected table.
10In a Microsoft Word document, press Ctrl + V to paste the copied table.
The table is pasted in the Word document with loss of formatting.
11To copy an image from a PDF document
12Click the arrow on the Basic toolbar and select Select Image from the drop-down menu.
When you move the pointer over an image in the PDF document, the pointer changes to a cross-hair shape [

Friday, December 18, 2009

Calender Extender CSS

Create a CSS stylesheet with name calendar.css and save to in the same directory having the asp.net web page in which you want to link it.

Copy and paste the following CSS code in calendar.css file.
CSS code:

.cal_Theme1 .ajax__calendar_container

{
background-color: #e2e2e2; border:solid 1px #cccccc;

}

.cal_Theme1 .ajax__calendar_header

{
background-color: #ffffff; margin-bottom: 4px;

}

.cal_Theme1 .ajax__calendar_title,

.cal_Theme1 .ajax__calendar_next,

.cal_Theme1 .ajax__calendar_prev

{
color: #004080; padding-top: 3px;

}

.cal_Theme1 .ajax__calendar_body

{
background-color: #e9e9e9; border: solid 1px #cccccc;

}

.cal_Theme1 .ajax__calendar_dayname

{
text-align:center; font-weight:bold; margin-bottom: 4px; margin-top: 2px;

}

.cal_Theme1 .ajax__calendar_day

{
text-align:center;

}

.cal_Theme1 .ajax__calendar_hover .ajax__calendar_day,

.cal_Theme1 .ajax__calendar_hover .ajax__calendar_month,

.cal_Theme1 .ajax__calendar_hover .ajax__calendar_year,

.cal_Theme1 .ajax__calendar_active

{
color: #004080; font-weight:bold; background-color: #ffffff;

}





.cal_Theme1 .ajax__calendar_today

{
font-weight:bold;

}





.cal_Theme1 .ajax__calendar_other,

.cal_Theme1 .ajax__calendar_hover .ajax__calendar_today,

.cal_Theme1 .ajax__calendar_hover .ajax__calendar_title

{
color: #bbbbbb;

}

Sunday, November 29, 2009

Code For Backspacing

You can substring your string to its length - 1, e.g.
String input = "Hello.."; String output = input.Substring(0, input.Length - 1);
Console.WriteLine(output);
-------------------------------------------------------------------------------------------------

protected void Button1_Click(object sender, EventArgs e)
{
string s = TextBox1.Text;
string o;
o=s.Substring(0, s.Length - 1);
TextBox1.Text = o;
if (TextBox1.Text == "")
{
TextBox1.Text = "0";
}

}

Tuesday, November 24, 2009

Downloading a File with a Save As Dialog in ASP.NET

This seems to be a common question that I hear frequently: How do I download a file from a Web site, but instead of displaying it in the browser see it as a file that can be saved (ie. see the Save As dialog)?
Normally when you link a file that file will always display inside of the browser because the browser loads it and automatically determines the content type based on the file extension. So when you click on a link like a jpg image the browser knows it's an image and will display that image. You can of course always use the browser short cut menu and use the Save Target As option to save the file to disk.
If you want to do this automatically when a link is clicked from the server side, you have to send the file back yourself rather and add a couple of custom headers to the output. The way to do this is to use Response.TransmitFile() to explicitly send the file from your ASP.NET application and then add the Content Type and Content-Disposition headers.
For example:
Response.ContentType = "image/jpeg";
Response.AppendHeader("Content-Disposition","attachment; filename=SailBig.jpg");
Response.TransmitFile( Server.MapPath("~/images/sailbig.jpg") );
Response.End();
This will cause a Open / Save As dialog box to pop up with the filename of SailBig.jpg as the default filename preset.
This of course assumes you're feeding a file that already exists. If you need to feed dynamically generated - say an image that was generated in memory - you can use Response.BinaryWrite() to stream a byte array or write the output directly in Response.OutputStream.
Bitmap bmp = wwWebUtils.CornerImage(backcolor, color, c, Radius, Height, Width);

Response.ContentType = "image/jpeg";
Response.AppendHeader("Content-Disposition","attachment; filename=LeftCorner.jpg");

bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
If at all possible though, use TransmitFile though especially if you plan on serving a file more than once. TransmitFile is very efficient because it basically offloads the file streaming to IIS including potentially causing the file to get cached in the Kernal cache (based on IIS's caching rules).

Code to Open pdf/doc/any file(Download)

Code to Open pdf/doc/any file(Download)
This post is for opening any document in website
// function to open file
protected void OpenDocument()
{
// Get the physical Path of the file(test.doc)
string filepath = Server.MapPath("Document Location");

// Create New instance of FileInfo class to get the properties of the file being downloaded
FileInfo file = new FileInfo(filepath);

// Checking if file exists
if (file.Exists)
{
// Clear the content of the response
Response.ClearContent();

// LINE1: Add the file name and attachment, which will force the open/cance/save dialog to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);

// Add the file size into the response header
Response.AddHeader("Content-Length", file.Length.ToString());

// Set the ContentType
Response.ContentType = ReturnExtension(file.Extension.ToLower());

// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
Response.TransmitFile(file.FullName);

// End the response
Response.End();
}
}
// Function to get extenstion of the file
private string ReturnExtension(string fileExtension)
{
switch (fileExtension)
{
case ".htm":
case ".html":
case ".log":
return "text/HTML";
case ".txt":
return "text/plain";
case ".doc":
return "application/ms-word";
case ".tiff":
case ".tif":
return "image/tiff";
case ".asf":
return "video/x-ms-asf";
case ".avi":
return "video/avi";
case ".zip":
return "application/zip";
case ".xls":
case ".csv":
return "application/vnd.ms-excel";
case ".gif":
return "image/gif";
case ".jpg":
case "jpeg":
return "image/jpeg";
case ".bmp":
return "image/bmp";
case ".wav":
return "audio/wav";
case ".mp3":
return "audio/mpeg3";
case ".mpg":
case "mpeg":
return "video/mpeg";
case ".rtf":
return "application/rtf";
case ".asp":
return "text/asp";
case ".pdf":
return "application/pdf";
case ".fdf":
return "application/vnd.fdf";
case ".ppt":
return "application/mspowerpoint";
case ".dwg":
return "image/vnd.dwg";
case ".msg":
return "application/msoutlook";
case ".xml":
case ".sdxl":
return "application/xml";
case ".xdp":
return "application/vnd.adobe.xdp+xml";
default:
return "application/octet-stream";
}
}