C#調用OpenOffice轉換多格式文件到PDF

protected void GiveMePDFButton_Click(object sender, EventArgs e)
{
        // Initialize Receiver in GenericSender
        OpenOfficeService.Objects.GenericSender.Init(
                "tcp://localhost:6543/OpenOfficeServiceReceiver");

        // Translate path and load up file in byte array, convert it
        string source = Server.MapPath("~/SomeWordML.xml");
        byte[] wordML = File.ReadAllBytes(source);

        byte[] result =    
            OpenOfficeService.Objects.GenericSender.Receiver.ConvertToPDF(wordML);

        // Write response to client
        Response.AddHeader("content-type", "application/pdf");
        Response.AddHeader("Content-Disposition", "p_w_upload; filename=result.pdf");

        Response.BinaryWrite(result);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章