cristofayre has asked for the wisdom of the Perl Monks concerning the following question:

I'm tearing my hair out!!

I generated a PDF with AP12. If I click the file locally, it loads into reader fine. But no matter what I do in perl, it stops loading data at around 4K of a 212K file. (Reading the data sent to page in a text editor, it seems to stop at %%EOF)

I have tried the usual "While(<xx>)" and "@file=<ZZ>", and even tried the "local $/" to set to undefined size ... but still it stops reading at 4K / %%EOF

<< /Info 4 0 R /Root 1 0 R /Size 815 >> startxref 207080 %%EOF

So I can't even 'grab' it to send it to a zip file, (everything is code based from generating file to delivery) 'cos I can't read the entire file ... My ultimate aim is to get the file to the browser, or to a save prompt - but can't do either.

Annoying thing is, I've got it to work before using the "Content-disposition" "content-type: application/pdf" ... but I suspect those files are less than the buffer size (??)

I even tried it with another file (8MB) Whilst I got the correct number of pages after 20 seconds - and having to switch to an older reader ... there was no text on any page!!

I can't even email it to people ... cos I can't read the entire file to memory.

Final try:

open (QR, "<QR_labels.pdf"); binmode(QR); print "Content-type: application/pdf\n\n"; print 'Content-Disposition', "attachment; filename=Booth_guide.pdf\n\n +"; while(read(QR,$buffer,10000)){ print $buffer; } close(QR);

Same thing. Only 4K delivered to browser from 212K, and breaking as shown above. This has me beaten! I don't know what to try next

Replies are listed 'Best First'.
Re: HELP: Problem with PDF
by poj (Abbot) on Feb 26, 2015 at 21:23 UTC
    What is Booth_guide.pdf ?

    Try
    #!/perl use strict; use warnings; print "Content-type: application/pdf\n\n"; open QR, "/path/to/QR_labels.pdf" or die "could not open PDF [$!]"; binmode STDOUT; while (read(QR,my $buffer,10000)){ print $buffer; } close QR;
Re: HELP: Problem with PDF
by LanX (Saint) on Feb 26, 2015 at 19:09 UTC