Convert Word files to PostScript files by using Word library and Distiller library

I use Word library 11.0 (Word 2003), Distiller library 1.0 (Acrobat Professioanl 6.0), Windows Server 2003 and Visual Studio .NET 2003 Academic Edition to develop a web application which is used to convert  Word files to PostScript files. The codes (C# and VB.NET) can work very well in Console Application. But they don't work in Web Application or Web Service. Please tell me how to solve the problem. Thanks! Theare are C# source code and VB.NET source code:

C#
if(strCommandName == "PDF")
ac.ActivePrinter="Adobe PDF";
else
ac.ActivePrinter="Microsoft Office Document Image Writer";
ac.ScreenUpdating=false;
ac.DisplayAlerts=Word.WdAlertLevel.wdAlertsNone;
object objOpenFileName=Server.MapPath("")+@"\TempFold\Word.doc";
object objReadOnly=true;
object objIsVisible=false;
object objMissing=Type.Missing;
Word.Document doc = ac.Documents.Open(ref objOpenFileName, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objIsVisible,
ref objMissing, ref objMissing, ref objMissing, ref objMissing);

object objBackground = true;
object objAppend = false;
object objOutputFileName;
if(strCommandName == "PDF")
objOutputFileName = Server.MapPath("")+@"\TempFold\Word.ps";
else
objOutputFileName = Server.MapPath("")+@"\TempFold\Word.prn";
object objPrintToFile = true;
try
{
doc.Activate();
doc.PrintPostScriptOverText=true;
doc.PrintOut(ref objBackground, ref objAppend, ref objMissing, ref objOutputFileName, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objPrintToFile, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objMissing);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
object objIsSaveChanges = Word.WdSaveOptions.wdSaveChanges;
doc.Close(ref objIsSaveChanges, ref objMissing, ref objMissing);
ac.ActivePrinter=strPreviousPrinter;
ac.Quit(ref objIsSaveChanges, ref objMissing, ref objMissing);
}

VB.NET
Sub ConvertWord2PS()
Dim ac As Microsoft.Office.Interop.Word.ApplicationClass
ac = New Microsoft.Office.Interop.Word.ApplicationClass
ac.Visible = False
Dim strPreviousPrinter As String = ac.ActivePrinter
ac.ActivePrinter = "Adobe PDF"
ac.ScreenUpdating = False
ac.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone
Dim objOpenFileName As Object
Dim objReadOnly As Object
Dim objIsVisible As Object
Dim doc As Microsoft.Office.Interop.Word.Document
objOpenFileName = "D:\Inetpub\wwwroot\vbWord2PDFWebApp\bin\Word.doc"
objReadOnly = True
objIsVisible = False
doc = ac.Documents.Open(objOpenFileName)
Dim objBackground As Object
Dim objAppend As Object
Dim objOutputFileName As Object
Dim objPrintToFile As Object
objBackground = True
objAppend = False
objOutputFileName = "D:\Inetpub\wwwroot\vbWord2PDFWebApp\bin\Word.ps"
objPrintToFile = True
Try
doc.Activate()
doc.PrintOut(objBackground, objAppend, , objOutputFileName, , , , , , , objPrintToFile)
Catch ex As Exception
Finally
doc.Close()
End Try
End Sub
0
qcharlie
10/22/2004 4:49:51 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

1 Replies
1067 Views

Similar Articles

[PageSpeed] 21

You haven't specified what's not working.

At a guess though, I'd suggest that the ASPNET worker account does not have sufficient privileges to execute against the COM+ objects. You may need to employ Impersonation or something else. (Security is not my thing, so I cannot provide guidance.)
You should perhaps have a look through the archives of the following two forums:
Enterprise Services
Security
You will find valuable information about working with COM+ objects in both of those forums.

Alister
0
SomeNewKid
10/23/2004 4:19:18 AM
Reply:

Similar Artilces:

web services used to convert Word files to PDF files
My professor asked me to design a web services which convert Microsoft's word files to PDF files. by use VS.NET and Windows Server 2003. After I installe Adode Acrobat 6.0 Professional, I can find some Acrobat components, Acrobat Distiller, Acrobat Web Capture 1.0 Type Library, etc. Please tell me which one can be used for my project and how to use it. Or please tell me popular free components of third parts. Thanks!...

Merging data into Word file ? Or Creating a Word file ?
Hi I need to write to a word file data drawn from a database. 1. Is it possible to use a template and then open it, replace some words (name, firstname, etc) by data, save the file with new name. or 2. Create word file from scrach Is Word 2003 necessary on the server ? My provider does not have it installed. Is there a way to do it with other versions ? As you can see, I'm investigating, and I'm lost ... Thanks JohannWebsite - Weblog There is a company named ASPOSE that has a componet that does just that... ASPOSE WORD Hope that helps... Many Thanks, Dann...

Help!! Problem accessing a WORD file in web server using C#.NET
Hi experts, I am trying to open the content of a WORD file from C#.NET which resides in the REMOTE SERVER, however I get an error:"System.Runtime.InteropServices.COMException: Server execution failed" when declaring new Word.ApplicationClass(). string fileName = this.btnWorkOrder1.Value;object readOnly = false;object isVisible = false;object saveChanges = false;object missing = System.Reflection.Missing.Value;object dynamic = 2; //error here:Word.ApplicationClass oWordApp = new Word.ApplicationClass(); Word.Document oWordDoc = oWordApp.Documents.Open(ref file, ref missing, ref readOnly,...

Why we use Web.Config File for connection string wether we can use class Library for get connection for whole web Application
 Why we use Web.Config File for connection string wether we can use class Library for get connection for whole web Application  please help me? Friend, Web.config has its own advantages. 1) Web.Config is used to store the important information like connections strings etc...so that it can be modified even after the code has been    deployed to the server without compiling the entire application again. 2) Since it is a XML file, there is no need of building the project of you are going to change the connection strings.   If you go for the class files,...

How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
HI allI have a urgent requirement i want to convert .tiff image to .pdf file Thanks in advance Regards RaviPlease click "mark as answer" if this post helped you. I dont think its possible without doing a lot of code or using third party tools, but if you  are looking for a free tool you can try a combination of http://blog.codebeach.com/2008/02/convert-multipage-tiff-to-pdf-in-net.htmland  http://www.codeproject.com/KB/aspnet/Creating_PDF_documents_in.aspx Thanks and RegardsS.K.Vignesh----------------------Do remember to "Mark as answer" for this pos...

Looking for: A component to Convert Word files to RTF files
Hello Everyone, I have the need to be able to print Word content (ie files stored in a database blob) in a Report Builder report. One way I thought to do this is to first convert it to RTF - and then RB can deal with that. Does anyone know of code or a component that will convert Word files to RTF files? I know I could OLE - but I am hoping to be able to do this without having Word installed on a machine. I know of http://www.scalabium.com/ - but unless I misunderstand - it only converts the word documents to TEXT. (which is a valid fall back) Any thoughts or suggestio...

How to convert a word .doc file into .tif file in c#?
Thank you for answer. this.brain=null;MSN+EMAIL: vincent90152900@gmail.com...

Converting Word HTML File Back to Native Word
Hi All, I have faced the following problem: I have a word document saved to html webpage. The document includes header and footer. After replacing some strings in html file, I want to covnert back to native Word format. The problem is that WordApplication.Documents.Open method opens the html file with no header/footer. Having tried Document.Reload brings the header/footer back but then I loose some references to pictures in the document. The problem does not show up when opening the html file directly from Word or programmatically from VBA. Any ideas? BR, Janusz > {quot...

urgent----Converting Excel,Word,txt files to an image file
hi mates,      I want to convert an excel,word or a text file or a pdf to its corresponding image files such as in a tiff format.If u have any ideas regardign this please share.    cheers mate     vijayvijay Is this a .net related post?Do you want to use .net to this? You could use a screen shot function which converts a web page into an image:http://www.codegod.de/WebAppCodeGod/screenshot-of-webpage-with-aspnet-AID398.aspxHope this helps! Regards, Curt hi mate, I dont want the entire page to be saved as an image.  I want to conve...

Convert different file types (Word, Works, ...) to RTF File?
Hi, I want let the application open different kinds of Files and CONVERT it to an RTF File. Is it possible to use some DLLs, APIs from MS-Office to do this ? thanks in advance. ...

Convert Word DOC File to Adobe Acrobat PDF file
Hello, Does anyone knows a component to convert an Word DOC File to Adobe Acrobat PDF file? I am creating a web site where people upload word  Word DOC files to the server. I need to convert the Word Doc files into PDF files as they are uploaded. Thanks, Miguel shapper--Regarding this... shapper wrote:...Does anyone knows a component to convert an Word DOC File to Adobe Acrobat PDF file?......I am creating a web site where people upload word  Word DOC files to the server. I need to convert the Word Doc files into PDF files as they are uploaded.......one should ...

convert html file to word file whent user download it
have aproblem in dowen load afile in hte html format to be saved in clients in .doc format i do all programming correvtely but hte .doc file open as i make edit for html file contain all html tags if any one can help me , thanks to all ...

Open file(text,word,etc) file using fileupload control
hi in my project i want to open my file in my project,in click event i want to open file and file path is fileupload control's text box path,how can i do that example like fileupload.open(filepath) that open my file waiting for replay thanksNothing is really over,untill the moment stop trying for it...Amitsp(MCTS,MCP)sqlreporting.blogspot.com...

Merging Files with only word files
Hello Friend's i have a some word document  and all word document files for merging only one file create. how to merge two word document and more document then also merge. i think u can understand my question.  as soon as possible with one example. thx,   regarding, Tushar Poshiya...

Web resources about - Convert Word files to PostScript files by using Word library and Distiller library - asp.net.web-forms

PostScript - Wikipedia, the free encyclopedia
The concepts of the PostScript language were seeded in 1976 when John Warnock was working at Evans & Sutherland , a computer graphics company. ...

John Eligon - A postscript to my interview with white... - Facebook
A postscript to my interview with white nationalist, Paul Craig Cobb ... I had knocked on doors in high-crime neighborhoods, spent time interviewing... ...

Flickr: PostScript.EdmontonJournal's Photostream
Explore PostScript.EdmontonJournal's photostream on Flickr. This user has 138 photos on Flickr.

Admire Rakti death a sad Cup postscript
... and died after finishing last in the Melbourne Cup. Favourite Admire Rakti collapsed and died after the Melbourne Cup, adding a sad postscript ...

A postscript to 'The Killing Season': Was there a coup d'etat over mining tax?
Sarah Ferguson's ABC series left one crucial question unanswered.


TFS Kanban talk in Indianapolis, postscript
I've been wanting to write this since giving a talk last week at the Indianapolis TFS user group. Paul Hacker started this group and leads the ...

Pitch Perfect 2 is an encore, a postscript, and a fresh start all at once
The movie sometimes feels like half a season of Pitch Perfect: The Series edited down to feature length.

Postscript from Albany at Johns Hopkins
Postscript from Albany at Johns Hopkins

Sunday Classics postscript: Poor Arthur Sullivan never knew how well he had succeeded as a "serious" ...
... waste your time and mine with bad performances, but at some point we may have to do it. I thought about doing it again for this little "postscript," ...

Resources last updated: 11/21/2015 1:43:32 AM