|
| 1 | +# PDF |
| 2 | + |
| 3 | +This is in a very early state and not tested thoroughly. |
| 4 | + |
| 5 | +It includes: |
| 6 | +- Reading PDF data types from stream. |
| 7 | +- Opening a PDF file and extracting file objects. |
| 8 | + - Everything is done via streams but some parts require seeking in the file. |
| 9 | + - **What is missing:** |
| 10 | + - Support for linearized files |
| 11 | + - Support for cross-reference stream |
| 12 | + - Updated files? |
| 13 | +- Extracting information from the PDF file objects. |
| 14 | + - We can construct a page tree and link to annotations and resources. |
| 15 | + - **What is missing:** |
| 16 | + - Properly parse annotation information |
| 17 | + - Properly parse font information |
| 18 | + |
| 19 | +## Discussion: HTML translation |
| 20 | + |
| 21 | +The primer problem of translating PDF to HTML will be to map glyph IDs to Unicode characters. |
| 22 | +There can be mapping information in the PDF and in the font but both is not guaranteed. |
| 23 | +HTML and SVG do not support drawing characters based on glyph IDs, so we are forced to use Unicode mappings. |
| 24 | +If there is no Unicode mapping in the font we would have to transform the font and make up mappings. |
| 25 | +This would require the ability of reading and writing font files which may not be trivial and there are a couple of different formats with different versions. |
| 26 | + |
| 27 | +Ultimately it also depends on how often this really happens that we do not have any Unicode mappings at all. |
| 28 | + |
| 29 | +Another problem might be the font support from the browser. Googling suggests that not all formats are supported by popular browsers. |
| 30 | + |
| 31 | +After all this is solved the questions is if we can place text the same way in HTML as it is done in PDF. |
| 32 | +PDF has the ability to continue text where it left of or move down a line which could be tricky in HTML. |
| 33 | +Apart from that PDF can also modify the spacing between the characters for example which we might be able to translate to CSS positioning. |
| 34 | + |
| 35 | +## References |
| 36 | +- https://en.wikipedia.org/wiki/PDF |
| 37 | +- File Format |
| 38 | + - Objects https://www.oreilly.com/library/view/developing-with-pdf/9781449327903/ch01.html |
| 39 | + - https://resources.infosecinstitute.com/topics/hacking/pdf-file-format-basic-structure/ |
| 40 | +- Structure |
| 41 | + - Document Structure https://www.oreilly.com/library/view/pdf-explained/9781449321581/ch04.html |
| 42 | + - Cross-reference stream https://www.verypdf.com/document/pdf-format-reference/pg_0106.htm |
| 43 | +- Graphics Operators |
| 44 | + - https://gendignoux.com/blog/images/pdf-graphics/cheat-sheet-by-nc-sa.png |
| 45 | + - https://pdfa.org/wp-content/uploads/2023/08/PDF-Operators-CheatSheet.pdf |
| 46 | + - General https://gendignoux.com/blog/2017/01/05/pdf-graphics.html |
| 47 | + - Text https://www.syncfusion.com/succinctly-free-ebooks/pdf/text-operators |
| 48 | + - Drawing https://www.syncfusion.com/succinctly-free-ebooks/pdf/graphics-operators |
| 49 | +- CMap https://blog.idrsolutions.com/how-are-embedded-cmap-tables-in-pdf-file/ |
| 50 | +- Related projects |
| 51 | + - https://github.com/qpdf/qpdf |
| 52 | + - https://github.com/caradoc-org/caradoc |
| 53 | +- Nasty test files https://github.com/angea/PDF101 |
0 commit comments