javascript Google Docs 像素到英寸

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10229109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 09:07:56  来源:igfitidea点击:

Google Docs Pixels to Inches

javascriptgoogle-docsgoogle-docs-api

提问by Haroon

Is anyone aware of the formula google docs use to convert pixels to inches?

有人知道谷歌文档用来将像素转换为英寸的公式吗?

Right click on a cell and click table properties then you get the image below, note I have opened up firebug and you can clearly see each td is set with a px width. I can work with inches or mm or equivalent for printing to pdf but pixels is not so accurate.

右键单击一个单元格并单击表格属性,然后您会看到下面的图像,注意我打开了萤火虫,您可以清楚地看到每个 td 都设置了 px 宽度。我可以使用英寸或毫米或等效物来打印为 pdf,但像素不太准确。

This is all done on client side hence the javascript tag...

这一切都是在客户端完成的,因此 javascript 标签......

enter image description here

在此处输入图片说明

回答by jon

Haroon, I'm not sure what you're trying to do, but PC displays are generally 96DPI and I think google have emulated this with the zoom level they have set in their documents webapp.

Haroon,我不确定你要做什么,但 PC 显示器通常是 96DPI,我认为谷歌已经用他们在文档 web 应用程序中设置的缩放级别模拟了这一点。

We can confirm it's close, by taking a screenshot of googledocs and pasting it into paint, and then measuring the document width.

我们可以通过截取 googledocs 的屏幕截图并将其粘贴到 Paint 中,然后测量文档宽度来确认它已关闭。

I got 796 pixels from my select tool in paint. I am using A4 portrait pages that are 210mm wide. This means we can do 796/210 to get our pixel density.

我从油漆中的选择工具中获得了 796 像素。我使用的是 210 毫米宽的 A4 纵向页面。这意味着我们可以做 796/210 来获得我们的像素密度。

1 millimetre = 3.79 pixels

1 millimetre = 3.79 pixels

multiply by 2.54

乘以 2.54

1 inch = 96 pixels

1 inch = 96 pixels

I don't know if this will remain consistent with other monitor resolutions or paper sizes, but I would expect it would be close!

我不知道这是否会与其他显示器分辨率或纸张尺寸保持一致,但我希望它会很接近!

回答by James Kissel

Old question and the same old answer but from a different source. I've been trying to get images to display the "correct" size when they have been inserted into a google document. They always were too small. So I inserted one of known size and printed it and manually checked the size. From those dimensions I can confirm that Google does indeed use 96 DPI.

旧问题和相同的旧答案,但来自不同的来源。当图像插入谷歌文档时,我一直试图让图像显示“正确”的大小。他们总是太小了。所以我插入了一个已知尺寸并打印出来并手动检查了尺寸。从这些维度我可以确认谷歌确实使用了 96 DPI。