Hacker News new | ask | show | jobs
by crazygringo 2276 days ago
Wow that's insane. It never would have even occurred to me to use Photopea for editing PDF's.

But it does indeed import each element of the PDF as a separate layer, and you have PDF export with options to leave text as-is, rasterize text, or vectorize it.

Two questions:

1) Does it set the resolution of the Photopea file, and the default resolution to re-export the PDF, to trying to detect the original resolution of images in the PDF? So that by importing and exporting, you're going to have a PDF of approximately the same quality and filesize?

2) Are you able to handle embedded fonts, including subsetted fonts? I assume that in that case you would vectorize it and wouldn't be able to type new characters... just want to know if I'm wrong in assuming that?

Thanks again a million times over for Photopea. It remains my absolute #1 inspiration of what one developer on their own can do. Never ceases to amaze. :)

1 comments

1) In a PDF file, the measure units are Inches. The page size is in inches. Any dimension is in Inches. There can be a bitmap having 200x200 pixels placed at 3x3 inches. Next to it can be a bitmap of 5x5 pixels placed at 5x5 inches.

That means, that PDF does not contain any DPI information. It is not needed at all. PDF rasterizer (e.g. a raster printer) can render it at any DPI. Photopea decodes and saves back bitmaps inside PDF in the original resolution. The rest is vector graphics.

2) For now, Photopea ignores embedded fonts. But it extracts the font name and in 98 % of cases, we already have the required font in our database of fonts, so we can render it identically.

Don't you mean points, not inches?

That's why page dimensions are things like "/CropBox [0.0 0.0 595.27576 841.89001]". PDF points are the same as Postscript points, 1/72 of an inch, that is 25.4/72 mm. So those numbers mean a page 210mm wide and 297mm high: A4.

Yes, the actual values are points, and one point is 1/72 of an inch, which is the same, as if the values were in inches. I just wanted to point out, that the units are physical (unlike "logical" units in an SVG or in a webpage).