Commit 359999a59cc1befdc94115d3cd17cb95a0ebdb49
1 parent
88706995
note
git-svn-id: svn+q:///qpdf/trunk@1033 71b93d88-0707-0410-a8cf-f5a4172ac649
Showing
1 changed file
with
38 additions
and
0 deletions
TODO
| 1 | +2.2.1 | |
| 2 | +===== | |
| 3 | + | |
| 4 | +Add interface for working with in-memory PDF files. Here's some code | |
| 5 | +to work with. | |
| 6 | + | |
| 7 | + Pl_Buffer b("b"); | |
| 8 | + FILE* f = QUtil::fopen_wrapper(std::string("open ") + filename, | |
| 9 | + fopen(filename, "rb")); | |
| 10 | + unsigned char buf[1024]; | |
| 11 | + size_t bytes_read = 0; | |
| 12 | + while (true) | |
| 13 | + { | |
| 14 | + size_t len = fread(buf, 1, sizeof(buf), f); | |
| 15 | + if (len == 0) | |
| 16 | + { | |
| 17 | + if (ferror(f)) | |
| 18 | + { | |
| 19 | + throw QPDFExc(qpdf_e_system, | |
| 20 | + filename, "", | |
| 21 | + 0, | |
| 22 | + "read"); | |
| 23 | + } | |
| 24 | + else | |
| 25 | + { | |
| 26 | + b.finish(); | |
| 27 | + break; | |
| 28 | + } | |
| 29 | + } | |
| 30 | + else | |
| 31 | + { | |
| 32 | + b.write(buf, len); | |
| 33 | + bytes_read += len; | |
| 34 | + } | |
| 35 | + } | |
| 36 | + fclose(f); | |
| 37 | + this->file = new BufferInputSource(filename, b.getBuffer()); | |
| 38 | + | |
| 1 | 39 | General |
| 2 | 40 | ======= |
| 3 | 41 | ... | ... |