c# - Unable to search a text in generated PDF from word -
we generating pdf word document, using "microsoft.office.interop.word.application" our code. problem when open generated pdf , search text , saying not found though text there. thinking content inside pdf coming image instead of text, other things displaying tables, images coming good. there way make pdf searchable?
i attaching code here. please let me know thoughts. appreciated.
thanks sri
code:
using system; using system.collections.generic; using system.collections; using system.diagnostics; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using word = microsoft.office.interop.word; using system.io; using microsoft.office.interop.word; namespace doctopdfconverter { public class doctopdfconverter { static int main(string[] args) { string inputfilename = args[0]; string outputfilename = args[1]; console.writeline("started converting word document pdf >> ....."); doctopdfconverter dc = new doctopdfconverter(); microsoft.office.interop.word.application application = new microsoft.office.interop.word.application(); dc.converttopdf(inputfilename, outputfilename, application); console.writeline("successfully done pdf conversion."); return 0; } public void converttopdf(string inputfilename, string outputfilename, microsoft.office.interop.word.application application) { object originalformat = null; object routedocument = false; object saveoption = null; word.bookmarks bookmarks = null; string bookmarknames = string.empty; string outname = string.empty; try { object missing = system.reflection.missing.value; object readonly = false; object isvisible = true; object inputsfilename = inputfilename; application.visible = true; application.defaultweboptions().alwayssaveindefaultencoding = true; word.document adoc = application.documents.open(ref inputsfilename, ref missing, ref readonly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isvisible); saveoption = word.wdsaveoptions.wddonotsavechanges; originalformat = word.wdoriginalformat.wdoriginaldocumentformat; object fileformat = wdsaveformat.wdformatpdf; object outputfilenames = outputfilename; if (adoc != null) { console.writeline("before export......."); adoc.exportasfixedformat( outputfilename, wdexportformat.wdexportformatpdf, false, wdexportoptimizefor.wdexportoptimizeforprint, wdexportrange.wdexportalldocument, 0, 0, wdexportitem.wdexportdocumentcontent, true, true, wdexportcreatebookmarks.wdexportcreateheadingbookmarks, true, true, false, ref missing); console.writeline("after export.............."); } } catch (exception e) { console.writeline(e); } { application.quit(ref saveoption, ref originalformat, ref routedocument); } } } }
Comments
Post a Comment