To copy a file to a new file you create a new file with a new PDFWriter. then create a pdf copying context for the source file.
then you can start copying element to the new file.
the pdf copying contenxt has a useful parser object, simiilar to the modification scenario.
if you want to try to do the same thing with a new file, here is what i suggest:
1. Start a new pdf with a new pdfwriter. let's call it "target"
note that a new instance of copying context has a parser available via GetSourceDocumentParser().
3. use the "source" file parser to construct the new content stream string, as you did before in the modification scenario
4. create a new stream object with the string as its contents in the target file. remember the object ID for this stream. as you did in the modification scenarion
5. use the copying context ReplaceSourceObjects(), placing as a single entry in the map the new object ID with the source document Content object ID. this would cause a future copying to avoid copying the old contents, and use the one already in the target file, which we created in 4.
6. import the page from the source document to the new one. use AppendPDFPageFromPDF(inIndex) of the copying context, where inIndex is the page index in the source document
7. repeat the process with any other pages that you want to replace the content for, or just import any other page that you want using AppendPDFPageFromPDF(inIndex).
This should do the trick.
Gal.