OpenOffice .xls 导出为 PDF 导致复选框重叠

发布于 2024-07-11 14:08:26 字数 3323 浏览 6 评论 0原文

OpenOffice Excel 文件导出为 PDF 是以编程方式完成的,我想知道是否有解决此问题的方法可能是在转换过程中传递某种标志或其他内容,这将使 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

以及一些代码,它是带有 Java 2.5 的 Jython 2.2.1。

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)

OpenOffice Excel file export to PDF is being done programmatically and I wish to know if there is a way to resolve this issue by maybe passing some kind of flag or something during the conversion process which will make the cell background transparent in the PDF document.

Please note an example PDF output. The original Excel file does not overlapping edges at all: http://www.freeimagehosting.net/uploads/4ab8dd9af0.jpg

This is the original Excel file before PDF export: http://www.freeimagehosting.net/uploads/0cdcaad47a.jpg

Both OpenOffice 2.4 and 3.0 have this same defect.

Suggestions would be most welcome, this is the last thing holding this project up.

Follow this link for an example on the OpenOffice website: http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=13528

Here is the issue tracker link: http://www.openoffice.org/issues/show_bug.cgi?id=97856

And some code for you, it is Jython 2.2.1 with 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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七秒鱼° 2024-07-18 14:08:26

您是否可以将包含超大复选框的行设置得更大一点?

这将是一种黑客行为,而不是您所要求的,但它可能会在比等待修复更短的时间内产生结果。

我检查了 Office 2003 和 OpenOffice 3 中的复选框,发现虽然 Office 允许对象上有透明背景,但 OpenOffice 不允许。 在 2.4 的发行说明中提到了表单对象的透明背景,但我找不到在复选框上指定这一点的方法。

据我所知,“正常打印”和打印预览中的透明复选框背景甚至可能是一种黑客行为,因为似乎没有指示透明背景的属性(背景颜色是默认颜色,而办公室有背景透明)。

然而,积极的是打印没问题。 打印到可以定义文件名的基于文件的打印机将是解决方案。 也许 Cups 有打印到 pdf 文件的打印机? (在这种情况下,您不会使用 PDF 导出,而是使用打印)。

Is it possible for you to make the row containing the oversized checkbox a bit larger?

That would be a hack, and not what you asked for, but it might yield results in a shorter timeframe than waiting for a fix.

I have checked the checkboxes in both Office 2003 and OpenOffice 3 and found that while Office allows a Transparent background on objects, OpenOffice does not . In the release notes of 2.4 Transparant backgrounds are mentioned for form objects, but I could not find a way to specify this on the checkbox.

As far as I can see it could even be that the transparent checkbox background in "normal print" and print preview is a hack, as there does not seem to be a property indicating a transparent background (the background color is Default whereas office has a background transparent).

What is positive, however, is that printing is OK. Printing to a file-based printer where you can define the filename would be the solution. Perhaps Cups has a print-to-pdf-file printer? (In that case you would not use PDF export but Print).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文