Net下的OF Microsoft.Office.Interop.Publisher的使用 [英] Using OF Microsoft.Office.Interop.Publisher under.Net

查看:77
本文介绍了Net下的OF Microsoft.Office.Interop.Publisher的使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

请我有Word文档,并且需要使用Microsoft Assemply "Microsoft.Office.Interop.Publisher"导入此Word文件并将其转换为发布者

任何人都可以提供帮助.

最好的问候&&预先感谢

Ab Abulubbad

Dear All,

Please i have word document and need to use microsoft assemply "Microsoft.Office.Interop.Publisher" to import the this word file and convert it to publisher

any one can help .

Best regards && thanx in advance

Ab Abulubbad

推荐答案

大家好,没人回答我,
我写这段代码可能对任何人都有用.

问候
ab abulubbad

hey all , no one answer me ,
i write this code may be it will be helpfull to any one .

regards
ab abulubbad

string psnames = string.Empty;
         string[] RequestsIDs = ViewState["requestIDs"].ToString().Remove(ViewState["requestIDs"].ToString().LastIndexOf('','')).Split('','');
         try
         {
             Microsoft.Office.Interop.Publisher._Application pub = new Microsoft.Office.Interop.Publisher.ApplicationClass();
             Microsoft.Office.Interop.Publisher.Document doc =
             pub.NewDocument(Microsoft.Office.Interop.Publisher.PbWizard.pbWizardNone, -1);
             Microsoft.Office.Interop.Publisher.PageSizes pageSizes = doc.PageSetup.AvailablePageSizes;
             foreach (Microsoft.Office.Interop.Publisher.PageSize ps in pageSizes)
             {
                 psnames += ps.Name + "\\n";
                 if (ps.Name == "A4 (Portrait)")
                 {
                     doc.PageSetup.PageSize = ps;
                     break;
                 }
             }
             int pageNumber = 0;

             foreach (string reqID in RequestsIDs)
             {
                 doc.Pages.Add(1, pageNumber, -1, false);
                 FillPageData(doc.Pages[pageNumber + 1], reqID);
                 pageNumber++;
             }
             doc.Pages[pageNumber+1].Delete();
             string SaveLink = MapPath("~/PublishingDocs/Announce_") + Guid.NewGuid() + ".pub";
             doc.SaveAs(SaveLink, Microsoft.Office.Interop.Publisher.PbFileFormat.pbFilePublication, true);
             doc.Close();
             pub.Quit();
             FileInfo info = new FileInfo(SaveLink);
             string link = "<a href=\"../PublishingDocs/" + info.Name
                 + "\" target=\"_self\" >" +
                 (Session["lang"].ToString() == "ar" ? "لتحميل الملف اضغط هنا" : "To Download The File Click Here")
                 + "</a>";
             lnkPrintSuccess.Enabled = true;
             RadPopUp(link, popUpTitles.DownloadLink);


<pre lang="midl">page.Shapes.AddTextbox(Microsoft.Office.Interop.Publisher.PbTextOrientation.pbTextOrientationRightToLeft,
          250, "0.373\"", "1.875\"", "0.313\"");
       page.Shapes[1].TextFrame.TextRange.Text = "بسم الله الرحمن الرحيم";
       page.Shapes[1].TextFrame.TextRange.ParagraphFormat.Alignment =
           Microsoft.Office.Interop.Publisher.PbParagraphAlignmentType.pbParagraphAlignmentCenter;
       page.Shapes[1].TextFrame.TextRange.Font.BoldBi = Microsoft.Office.Core.MsoTriState.msoTrue;
       page.Shapes[1].TextFrame.TextRange.Font.SizeBi = 14;
       /**********************************Righ Text**********************************************/
       page.Shapes.AddTextbox(Microsoft.Office.Interop.Publisher.PbTextOrientation.pbTextOrientationRightToLeft,
        450, "0.787\"", "1.875\"", "0.775\"");
       page.Shapes[2].TextFrame.TextRange.Text =
           "المملكة العربية السعودية\nوزارة التجارة والصناعة\nإدارة العلامات التجارية";
       page.Shapes[2].TextFrame.TextRange.ParagraphFormat.Alignment =
           Microsoft.Office.Interop.Publisher.PbParagraphAlignmentType.pbParagraphAlignmentCenter;
       page.Shapes[2].TextFrame.TextRange.Font.BoldBi = Microsoft.Office.Core.MsoTriState.msoTrue;
       page.Shapes[2].TextFrame.TextRange.Font.SizeBi = 14;

       /**********************************Content Text**********************************************/
       page.Shapes.AddTextbox(Microsoft.Office.Interop.Publisher.PbTextOrientation.pbTextOrientationRightToLeft,
       "1.563\"", "3.375\"", "5.097\"", "7.25\"");

       page.Shapes[3].TextFrame.TextRange.Text = GetRequestAnnounceText(reqID);
       page.Shapes[3].TextFrame.TextRange.ParagraphFormat.Alignment =
           Microsoft.Office.Interop.Publisher.PbParagraphAlignmentType.pbParagraphAlignmentRight;
       page.Shapes[3].TextFrame.TextRange.Font.SizeBi = 14;
       /**********************************Image Or Text**********************************************/
       GetRequestTextOrImage(page, reqID);









private void GetRequestTextOrImage(Microsoft.Office.Interop.Publisher.Page page,string reqID)
{
    DataTable dt = ViewState["Requests"] as DataTable;
    DataRow dr = dt.Select("Request_ID=" + reqID)[0];
    if (dr[9].ToString() == "1")
    {
        page.Shapes.AddTextbox(Microsoft.Office.Interop.Publisher.PbTextOrientation.pbTextOrientationRightToLeft,
          "1.563\"", "3.375\"", "5.097\"", "0.25\"");
        page.Shapes[4].TextFrame.TextRange.Text = dr[10].ToString();
        page.Shapes[4].TextFrame.TextRange.ParagraphFormat.Alignment =
            Microsoft.Office.Interop.Publisher.PbParagraphAlignmentType.pbParagraphAlignmentCenter;
        page.Shapes[4].TextFrame.TextRange.Font.SizeBi = 14;
    }
    else
    {
        page.Shapes.AddPicture(Server.MapPath("~/UploadedFiles/RequestMarks/" + dr[10].ToString()), Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue,
            "3.438\"", "2.110\"", "1.251\"", "1.251\"");
    }
}
private string GetRequestAnnounceText(string reqID)
{
    try
    {

    string AnncounceText = AnnounceText;
    req = new Requests();
    req.Request_IDs = ViewState["requestIDs"].ToString();
    DataTable dt = ViewState["Requests"] == null ? req.GetRequestDataForAnnounce() : ViewState["Requests"] as DataTable;
    ViewState["Requests"] = dt;
    DataRow dr = GetDataRow(dt.Select("Request_ID=" + reqID)[0]);
    AnncounceText = string.Format(AnncounceText, dr.ItemArray);
    return Common.arabicNumber( AnncounceText);
    }
    catch (Exception)
    {

        throw;
    }
}


这篇关于Net下的OF Microsoft.Office.Interop.Publisher的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆