pdf


Converting a doc to a pdf in a mvc c# environment


Hi I've got a c# MVC application running under a particular user (app.pool user).
I need to convert a doc or docx file to a pdf.
I thought a good option would be to use libreoffice to fire a process that would start this.
To make life easier for myself (and if libreoffice shouldn't work) I used a batch file.
echo on
SET var1=%2
IF "%var1:~-1%"=="\" SET var1=%var1:~0,-1%
cd %var1%
echo %1
echo %var1%
start /wait "" "C:\Program Files (x86)\LibreOffice 4\program\soffice" -headless -convert-to pdf %1 -outdir %var1%
My code for starting this is as follows.
var ba = #"C:\inetpub\wwwroot\apps\xxxxxxxxx\Services\convert.bat";
fullPath = #"C:\inetpub\wwwroot\apps\xxxxxxxxx\Files\Temp\636295920370843147.doc";
var tempPath = #"C:\inetpub\wwwroot\apps\xxxxxxxxx\Files\Temp";
string command = ba;
//Process.Start(command, fullPath + " " + tempPath);
var processInfo = new ProcessStartInfo("cmd.exe", "/c " + command + " "+ fullPath+ " "+ tempPath);
processInfo.CreateNoWindow = false;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
var process = Process.Start(processInfo);
process.OutputDataReceived += (object sender, DataReceivedEventArgs e) =>
Trace.WriteLine("output>>" + e.Data);
process.BeginOutputReadLine();
process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) =>
Trace.WriteLine("error>>" + e.Data);
process.BeginErrorReadLine();
process.WaitForExit();
Trace.WriteLine("ExitCode: {0}", process.ExitCode.ToString());
process.Close();
This does seem to work manually but when I run the code I can see the whole thing just stalls around the conversion. Looking at the threads and it seems to load the gdiplus.dll which I think is a graphics module which doesn't seem right.
The process though when I copy and paste that into my 'run' box in windows works fine and the pdf is made.
I've checked that the app.pool user has access to both libreoffice and also the folder with the files.
I've ran this as the app.pool user, in the c# it just stalls on the process.WaitForExit();
line. Until I kill the process.
Any ideas?
I've also tried many different ways of executing the soffice conversion. just straight from the c# - libreoffice 4,5.
I've seen some people use libreoffice as a service, is this an option? If so how?
Richard
EDIT
Ah, just changed the app Pool user to myself and now it works, so there is a permissions thing with the standard app pool user. How to find out what....
I added the user into the administrators group on the computer and restarted the machine, then it worked.
It might not be the best solution but after 2 days of trying to get this to work I'm not going to argue.
Richard

Related Links

Aligning two PDFs for a merge using Cairo and pyPDF
Solr ExtractingRequestHandler giving empty content for pdf documents
DOMPDF set font for entire page?
Best practices for TDD and reporting
Scribd Search Engine Optimization Features for PDF
How can I change the margins on a PDF document created by Doxygen?
parse pdf and identify page a phrase is on
Open Source, multi language / unicode fonts?
Using iText to selectively hide parts of a pdf
Functional PDF Testing (Automate Testing of PDF Content)
CGContextDrawPDFPage displays white or garbled text
What does this Apache FOP error mean?
Determine if a PDF is using subsetted fonts
Merge PDFs and retain their index (xref-Table?)
Weird problem, with ghostscript and pdf files
Embedding PDF documents into websites

Categories

HOME
vim
openlayers
hive
debugging
oracle11g
mfc
google-play
google-oauth
cmd
jpeg
slurm
export-to-csv
remote-access
event-handling
zebra-printers
jsprit
beyondcompare
crystal-reports-2008
xpages-ssjs
javacv
spark-jobserver
user-interaction
xacml
replaceall
compatibility
jspm
nat
bcd
key-value-observing
data-manipulation
oracle-fusion-middleware
subset-sum
mozilla
jmonkeyengine
overlap
devextreme
dartium
streamsets
leading-zero
temporary-files
mesos-chronos
isbn
outlook-api
netcdf4
prolog-setof
alphabet
rdfs
aurelia-validation
slickedit
typed-lambda-calculus
nbconvert
webdriverjs
yt-project
word-vba-mac
bstr
ready-api
asp.net5
wapiti
tcpserver
spim
icu4j
varargs
mono-embedding
unity5.2.3
umbraco6
python-green
c3
javafx-webengine
gulp-less
googlemock
document-classification
php-5.4
reactfx
gridfs
lcs
html-editor
specification-pattern
typoscript2
mhtml
sublist
bitsharp
datawindow
netbeans-6.9
punbb
adk
pydot
infobox
actionview
xfbml
lang
gallio
mozilla-prism
web-architecture
javap
adrotator
sustainable-pace
pascal-fc
zend-decorators
gacutil
spec#
defensive-programming
document-conversion

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App