# `import_streams` Import and apply modified content streams ## Usage > pdftl `` `import_streams` `[normalize=true]` `` `output` `` ## Details The `import_streams` operation reads a text file containing PDF content streams and applies them directly into the target PDF document. It is designed to perfectly round-trip the output from [`dump_streams`](). The primary workflow is to dump a document's streams to text, use standard Unix text tools (like `sed`, `awk`, or manual text editing) to modify the PDF operators, and then pipe the resulting text file back into `pdftl` using `import_streams`. ### Addressing Mechanism The operation strictly targets semantic paths described in the headers, ignoring any internal Object IDs (`(4:0)`). * `=== Page 1 / Contents` overwrites the main content stream of Page 1. * `=== Page 2 / XObject /Fm1` overwrites the stream of the XObject mapped as `/Fm1` within Page 2's resources. * `=== Page 1 / XObject /Fm1 / XObject /Fm0` overwrites the nested XObject `/Fm0`. Because it relies on semantic paths, you can easily use text tools to migrate streams across entirely different PDF documents by simply swapping the header paths (e.g. using `sed` to rename the target XObject). ### Options * `normalize=true` (default) — Before writing the stream into the PDF, `pdftl` uses `pikepdf`'s internal engine to parse and normalize the syntax. This automatically strips any `%` comments (such as those generated by `dump_streams annotate`), cleans up whitespace, and validates the PDF syntax. Pass `normalize=false` if you want to force raw text byte injection. ## Examples > Dump, patch, and re-import Page 1's content stream using a Unix pipe ``` pdftl in.pdf dump_streams 1 | sed -e 's/Apple/Banana/' | pdftl in.pdf import_streams - output out.pdf ``` > Apply modifications from a saved text file back into the document ``` pdftl in.pdf import_streams patched_streams.txt output out.pdf ``` > Inject stream text verbatim, without parsing or stripping comments ``` pdftl in.pdf import_streams normalize=false streams.txt output out.pdf ``` **Tags**: in_place, content_stream, dangerous *Source: pdftl.operations.import_streams* *Read online: [https://pdftl.readthedocs.io/en/stable/operations/import_streams.html](https://pdftl.readthedocs.io/en/stable/operations/import_streams.html)* *Type: Operation*