ssimms / pdfapi2

Create, modify, and examine PDF files in Perl
Other
15 stars 20 forks source link

Creating a PDF destroys existing file #41

Closed sciurius closed 2 years ago

sciurius commented 2 years ago

Creating a PDF object immedeately writes PDF header to disk.

$pdf = PDF::API2->new( file => "tl.pdf" );

I am not sure this is intentional, I'd expect that the file is not created/written until save is performed.

ssimms commented 2 years ago

Yes, that's intentional and documented. Writing the file immediately allows for lower memory usage, though I don't recall if that's actually happening in the current code.

If you don't want to overwrite the file immediately, wait to pass the filename until you call save.