首页 \ 问答 \ 允许PDFium支持x86和x64(Allow PDFium to support x86 and x64)

允许PDFium支持x86和x64(Allow PDFium to support x86 and x64)

我已经构建了一个使用PDFium打印PDF文档的WinForms应用程序。 我从NuGet安装了PDFium,它在我的项目中创建了两个子文件夹 - x86和x64 - 正如预期的那样,每个都有pdfium.dll的相关版本。 我的应用程序的目标平台设置为Any CPU

当我在Windows 10 64位计算机上运行调试应用程序时,它运行正常。 但是,当我发布应用程序并在同一台计算机上安装它时,PDFium会抛出异常:

System.BadImageFormatException:尝试加载格式不正确的程序。 (HRESULT异常:0x8007000B)

在做了一些研究之后,我将应用程序的目标平台更改为x86,并从我的项目中删除了x64子文件夹。 该应用程序现在在发布后完美运行,因此问题得以解决。

但是,我想知道是否有一种方法可以让我的应用程序工作,以便它支持x86和x64,使用相应版本的PDFium作为目标计算机。 如果它能在支持它的机器上安装一个64位版本会很好(这是我们组织中的大多数,但我觉得如果必须选择一个或者我需要使用32位版本另一方面,确保兼容性)。


I've built a WinForms app which uses PDFium to print PDF documents. I installed PDFium from NuGet, and it created two subfolders in my project - x86 and x64 - as expected, each with the relevant version of pdfium.dll inside. My application's target platform is set to Any CPU.

When I run the application in debug on my Windows 10 64-bit machine it works perfectly. However, when I release the application and install it for real on the same computer, PDFium throws an exception:

System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

After doing some research, I changed my application's target platform to x86 and removed the x64 subfolder from my project. The application now works perfectly after release, so the problem is solved.

However, I'd like to know if there's a way that I can get my application to work so that it supports both x86 and x64, using the appropriate version of PDFium for the target computer. It'd be nice if it'd install a 64-bit version on machines which can support it (which is most of them within our organisation, but I feel that I need to go with 32-bit if I have to choose one or the other, to ensure compatibility).


原文:https://stackoverflow.com/questions/43046641
更新时间:2022-03-20 20:03

最满意答案

可以通过选择单元格并设置单元格的_text属性的文本来更新matplotlib表中的文本。 例如

the_table._cells[(2, 1)]._text.set_text("new text")

将更新第三行和第二列中的单元格。

一个动画示例:

import matplotlib.pyplot as plt
from  matplotlib.animation import FuncAnimation

fig, ax = plt.subplots(figsize=(4,2))
colLabels = ["Name", "Number"]
data = [["Peter", 1], ["Sara", 1], ["John", 1]]
the_table = ax.table(cellText=data,
                     colLabels=colLabels,
                     loc='center')

def update(i):
    the_table._cells[(1, 1)]._text.set_text(str(i))
    the_table._cells[(2, 1)]._text.set_text(str(i*2))
    the_table._cells[(3, 1)]._text.set_text(str(i*3))

ani = FuncAnimation(fig, update, frames=20, interval=400)
plt.show()

在此处输入图像描述

找出需要更新的单元格,最好使用数据而不是从表中读取数据。

inx = list(zip(*data))[0].index("Peter")

给你索引0,这样可以通过the_table._cells[(inx+1, 1)]访问单元格(注意+1 ,因为表格标题the_table._cells[(inx+1, 1)]在那里)。


The text in a matplotlib table can be updated by chosing the cell and set the text of the cell's _text attribute. E.g.

the_table.get_celld()[(2, 1)].get_text().set_text("new text")

will update the cell in the third row and second column.

An animated example:

import matplotlib.pyplot as plt
from  matplotlib.animation import FuncAnimation

fig, ax = plt.subplots(figsize=(4,2))
colLabels = ["Name", "Number"]
data = [["Peter", 1], ["Sara", 1], ["John", 1]]
the_table = ax.table(cellText=data,
                     colLabels=colLabels,
                     loc='center')

def update(i):
    the_table.get_celld()[(1, 1)].get_text().set_text(str(i))
    the_table.get_celld()[(2, 1)].get_text().set_text(str(i*2))
    the_table.get_celld()[(3, 1)].get_text().set_text(str(i*3))

ani = FuncAnimation(fig, update, frames=20, interval=400)
plt.show()

enter image description here

Finding out which cell needs to be updated, would probably best be done using the data instead of reading it from the table.

inx = list(zip(*data))[0].index("Peter")

gives you the index 0, such that the cell can be accessed via the_table.get_celld()[(inx+1, 1)] (note the +1, which is there because of the table headline).

相关问答

更多
  • 另一种舍入到4位小数的方法是: '%0.4f' % float(1.239857) ,其中输出为1.2399 。 对于你的问题 - 因为我有足够的时间〜 - ,你可以使用/参考: def get_coordinates(infile, delimiter): new_list = [] with open(infile, 'r') as f: for line in f: x, y = [float(i) for i in line.strip().s ...
  • glob.glob返回一个序列。 而不是将此序列附加到cFilesFull列表,而是扩展列表。 cFilesFull.extend(glob.glob(mypath + f)) glob.glob returns a sequence. Instead of appending this sequence to your cFilesFull list, extend the list instead. cFilesFull.extend(glob.glob(mypath + f))
  • 使用列表理解: def capitalize(s, applyToAll=False): if applyToAll: l = [w.capitalize() for w in s.split()] return " ".join(l) else: return s.capitalize() 你们在python中用什么来调试? 复杂的代码片段的print语句,其他任何东西的交互式解释器。 我写了很多测试,并用鼻子运行它们。 Use a lis ...
  • 这与此处针对R脚本描述的挑战相同。 该设置也适用于Python。 但是,我发现approcah有一个缺点:它将新的连接或计算表存储为以前表之一的编辑版本。 以下建议将演示如何在不更改输入表的情况下生成全新的计算表(除非因此而将Date列的数据类型从Date更改为Text 。) 简短回答: 在Power Query editor ,请按照下列步骤操作: 将两列中Date columns的数据类型更改为Text 。 单击Enter Data 。 只需单击“ OK 激活新的Table3并使用Transform > ...
  • 要选择哪种XML解析器取决于你,但是这里是你如何用xml.etree.ElementTree来解决这个问题:想法是迭代所有data节点,从.attrib字典中获取name属性值,找到value元素内部并适当地设置.text : import xml.etree.ElementTree as ET data = """ Text 1
  • 由于HTML文件只是一个纯文本文件,因此可以通过python打开它,而无需任何额外的库等。 只需打开文件,编辑您需要的内容并进行编写即可。 查看以下链接: http : //www.pythonforbeginners.com/files/reading-and-writing-files-in-python Since an HTML file is just a plain text file it can be opened by python without the need for any ext ...
  • def Buttons(): global button1 button1=Rectangle(Point(1,1),Point(100,100)) button1.setFill('gold') button.draw(keyPad) 会使它在函数外部可访问...但实际上你应该将逻辑封装在类中 def Buttons(): global button1 button1=Rectangle(Point(1,1),Point(100,100)) but ...
  • 我不得不将我的PATH设置更改为使用Python 3.2而不是2.7。 我可以将我的run-command保留为: %(python) "-u" "%F" 它使用默认(3.2)解释器。 可以通过编辑,首选项,环境从Komodo Edit中更改路径。 尽管出现了,但我不相信可以在Komodo Edit 7中切换Python版本而不更改默认解释器。 但是,只需要一个简单的PATH更改。 [甚至可能创建一个批处理文件来切换两个版本之间的路径。] 我希望这些信息对其他人有用。 安迪。 I had to chang ...
  • 如果它们真的相似,您可以编写工厂来为您动态创建Table类: def table_factory(Model, name): class Table(tables.Table) edit = ButtonColumn('Edit', 'mapsets_' + name + '_edit') mappings = ButtonColumn('Mappings', 'mapsets_' + name + '_mappings') class Meta: ...
  • 可以通过选择单元格并设置单元格的_text属性的文本来更新matplotlib表中的文本。 例如 the_table._cells[(2, 1)]._text.set_text("new text") 将更新第三行和第二列中的单元格。 一个动画示例: import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation fig, ax = plt.subplots(figsize=(4,2)) colLabels ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)