15,906,558 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 11968223 (Top 5 by date)
Member 11968223
12-Jan-17 11:06am
View
Yes. Thank you. Could you please answer my question.
Member 11968223
12-Jan-17 10:17am
View
No that was my mistake. Actually i want to SharePoint 2007 Add-in in Visual Studio 2015. Not SDK. My apologies.
Member 11968223
12-Jan-17 9:11am
View
Hi,
Thanks for your reply, your link which says "We are sorry, the page you requested cannot be found". May i know the issue.
Member 11968223
8-Dec-16 4:03am
View
Thank you
Member 11968223
1-Dec-16 8:29am
View
Below is the code for converting word files to pdf. In my client location this application is working fine for single user. They are using this app in citrix server. It is working for only single user. But it should work for 15 users at a time.
Error is : Word file is being used by another user.
They are not able to convert the word file to pdf for 15 users at a time.
Please let me know if you need any further information.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using iTextSharp.text;
using iTextSharp.text.pdf;
using com.itextpdf.text.pdf;
using System.IO;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;
using System.Data;
using System.ComponentModel;
using Microsoft.Office.Interop.Word;
namespace PDF_Generator
{
public partial class PDF_Generator : Form
{
string singleFilePath = string.Empty;
string singleFile = string.Empty;
string multiplefiles = string.Empty;
string sourcePdf;
OpenFileDialog x;
public PDF_Generator()
{
InitializeComponent();
}
#region Button_Click Events
private void btnGenerate_Click(object sender, EventArgs e)
{
try
{
int FileSize;
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
word.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
object Missing = System.Reflection.Missing.Value;
object filename = (Object)singleFile;
object refFalse = false;
object refTrue = true;
FileInfo f = new FileInfo(singleFile);
FileSize = Convert.ToInt32(f.Length);
if ((f.Length / (1024 * 1024)) > 10)
{
MessageBox.Show("File size is more than 10MB. Please do not close the window.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
string selectedFileName = Path.GetFileNameWithoutExtension(singleFile) + ".pdf";
Object process = (Object)Convert.ToString(txtSelectDestination.Text) + "\\" + selectedFileName;
object fileFormat = WdSaveFormat.wdFormatPDF;
string ext = System.IO.Path.GetExtension(singleFile);
try
{
word.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
Microsoft.Office.Interop.Word.Document doc = word.Documents.Open(ref filename, ref refFalse, ref refTrue, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing);
btnGenerate.Enabled = true;
progressBar1.Style = ProgressBarStyle.Marquee;
progressBar1.MarqueeAnimationSpeed = 50;
Cursor.Current = Cursors.WaitCursor;
doc.SaveAs(ref process, ref fileFormat, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing);
object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
((_Document)doc).Close(ref saveChanges, ref Missing, ref Missing);
doc = null;
((_Application)word).Quit(ref Missing, ref Missing, ref Missing);
word = null;
sourcePdf = txtSelectDestination.Text + "\\" + selectedFileName;
string Password = txtProtectedPass.Text;
string InputFile = sourcePdf;
string OutputFile = @txtSelectDestination.Text + "\\" + " " + selectedFileName;
if (txtProtectedPass.Text != "")
{
using (Stream input = new FileStream(InputFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (Stream output = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
{
PdfReader reader = new PdfReader(input);
PdfEncryptor.Encrypt(reader, output, true, Password, Password, PdfWriter.ALLOW_SCREENREADERS);
}
}
File.Delete(sourcePdf);
}
Cursor.Current = Cursors.AppStarting;
txtProtectedPass.Text = "";
txtProtectedPass.Focus();
}
}
}
}