2009-01-08 121 views
3

OpenOffice將Excel文件導出爲PDF是以編程方式完成的,我希望知道是否有辦法通過在轉換過程中傳遞某種標誌或某種內容來解決此問題這個過程可以使單元背景在PDF文檔中透明。OpenOffice .xls導出爲PDF會導致複選框重疊

請注意PDF輸出示例。原來的Excel文件完全不重疊的邊緣:http://www.freeimagehosting.net/uploads/4ab8dd9af0.jpg

這是PDF導出之前的原始Excel文件:http://www.freeimagehosting.net/uploads/0cdcaad47a.jpg

雙方的OpenOffice 2.4和3.0有此相同的缺陷。

建議將是最受歡迎的,這是舉辦這個項目的最後一件事。

按照OpenOffice的網站上的此鏈接的例子:http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=13528

這裏是問題跟蹤鏈接:http://www.openoffice.org/issues/show_bug.cgi?id=97856

而且一些代碼對你來說,這是Jython 2.2.1與Java 2.5。

def _save_as_pdf(self, docSource): 
    dirName=os.path.dirname(docSource) 
    baseName=os.path.basename(docSource) 
    baseName, ext=os.path.splitext(baseName) 
    dirTmpPdfConverted=os.path.join(dirName + DIR + PDF_TEMP_CONVERT_DIR) 
    if not os.path.exists(dirTmpPdfConverted): 
     os.makedirs(dirTmpPdfConverted) 
    pdfDest=os.path.join(dirTmpPdfConverted + DIR + baseName + ".pdf") 
    url_save=self._create_UNO_File_URL(pdfDest) 
    properties=self._create_properties(ext) 
    try: 
     try: 
      self._xstorable=UnoRuntime.queryInterface(XStorable, self._doc) 
      self._xstorable.storeToURL(url_save, properties) 
     except AttributeError,e: 
       self.logger.info("saving as pdf has problem: (" + str(e) + ")") 
       raise e 
     except: 
      self.logger.info("storeToURL exception") 
      raise 
    finally: 
     self.logger.info("converted document " + baseName + ext) 
     if not self._doc: 
      xCloseable = UnoRuntime.queryInterface(XCloseable, self._doc) 
      if not xCloseable: 
       try: 
        xCloseable.close(false) 
       except CloseVetoException, (ex): 
        xComp = UnoRuntime.queryInterface(XComponent, self._doc) 
        xComp.dispose() 
     else: 
      xComp = UnoRuntime.queryInterface(XComponent, self._doc) 
      xComp.dispose() 
     self._doc=None 

def _create_properties(self,ext): 
    properties=[] 
    p=PropertyValue() 
    p.Name="Overwrite" 
    p.Value=True 
    properties.append(p) 
    p=PropertyValue() 
    p.Name="FilterName" 
    if ext==".doc": 
     p.Value='writer_pdf_Export' 
    elif ext==".rtf": 
     p.Value='writer_pdf_Export' 
    elif ext==".html": 
     p.Value='writer_pdf_Export' 
    elif ext==".htm": 
     p.Value='writer_pdf_Export' 
    elif ext==".xls": 
     p.Value='calc_pdf_Export' 
    elif ext==".tif": 
     p.Value='draw_pdf_Export' 
    elif ext==".tiff": 
     p.Value='draw_pdf_Export' 
    properties.append(p) 
    return tuple(properties) 
+3

爲什麼不用OOo提出一個實際的BUG(我知道你已經在他們的論壇上提出過)。 – paxdiablo 2009-01-08 02:55:11

+0

另外,您可以發佈代碼和/或電子表格嗎?我剛注意到這是一個XLS文件(來自Excel)而不是ODS? – paxdiablo 2009-01-08 02:58:16

回答

2

是否有可能讓包含超大複選框的行變大一點?

這將是一個破解,而不是你所要求的,但它可能會產生比等待修復更短的時間。

我檢查了Office 2003和OpenOffice 3中的複選框,發現雖然Office允許在對象上使用透明背景,但OpenOffice不支持。在2.4的發行說明中,透明背景被稱爲表單對象,但是我找不到在複選框上指定它的方法。

就我所見,它甚至可能是「正常打印」和打印預覽中的透明覆選框背景是黑客,因爲似乎沒有指示透明背景的屬性(背景顏色是Default而辦公室則具有透明背景)。

然而,什麼是積極的是印刷是好的。打印到可以定義文件名的文件打印機將是解決方案。也許杯具有一個打印到PDF文件打印機? (在這種情況下,您不會使用PDF導出,而是打印)。