HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [hylafax-users] Last Page Blank When Case Is Multiple Attachments & One Attachment Has Only One Page



Pan man,

Will this script work with multiple attachments?

The reason why I ask is because I think Hylafax parses each attachment through the mime decoder handler you specify. When an attachment is docoded, the result is stored in a temporary file. Only after all attachments are parsed is the last "showpage" operator added.

If the above is correct, hylafax pipes the pdf attachment data to pdftops. pdftops pipes the postscript data to your script. The showpage removal script counts the number of "showpage"operators in the data it was handed and removes the last one. Then this scripts pipes the data back to hylafax which stores it in a temporary file, leaves a pointer at the file's end for more data, and processes the next attachment. This process repeats until all attachments have been done.

Each attachment will have the last showpage operator removed, not just the last one?

So, if Lee modified the hylafax source code to not add the showpage operator at all, then this is the best solution in my opinion.

Correct me if I'm wrong. I'm just trying to understand this.

Davie

If my thinking is correct, then each attachment is piped from pdftops to the showpageremoval script and the last "showpage" is removed from each attachment. This result is then piped to hylafax for storage into a temporary file until all attachments have been decoded.

pan man wrote:
I see you did post it, ok, this line seems troubling in what you posted
       if($count == $num)
since I dont have a copy of the email i posted with the origional script
here it is again:

-------------------------------------------script-----------------------------------------
#!/usr/bin/perl
# Read from the standard input
@text=<STDIN>;
$size=@text;

# Count the number of "showpage"
$count=0;
for($i=0;$i<=$size;$i++){if($text[$i] =~ /showpage/){$count++;}}

# Discard the last line that contain "showpage"
$num=1;
for($i=0;$i<=$size;$i++){
       if($text[$i] =~ /showpage/){
               if($num!=$count){$num++;}
               else{$text[$i]=~s/showpage//g;}
       }

               print $text[$i];
}
-------------------------------------end
script-----------------------------------------
and I'm using pdftops not pdf2ps, seems to work better.

-------------------------mimetype/application/pdf-------------------------------
/usr/bin/pdftops $1 - | /var/spool/hylafax/mimetype/showpageremoval.pl
-------------------end
mimetype/application/pdf------------------------------
this script is still working on hylafax 4.4, and was installed on 4.3
however this is only a testing box. I have hylafax+ on the running
server box, mainly due to the fact that Lee is providing actual support
for hylafax+


On Aug 30, 2007 09:59 AM, Davie Lynn <davielynn@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

I'm using Hylafax version 4.3.4 . The below script is based on panman's
script (Thanks Panman) works for me with some minor changes.

When I tried the original script, I kept getting "Error:
/invalidrestore
in /restore" errors and figured this was caused by faxmail adding its
own trailer/eof to the resulting postscript. , I just modified the
script to delete not only the last "showpage" operator, but also "the
trailer/eof".

It works fine except when:

1. There are multiple pdf attachments.
2. One of those pdf attachments, not the last, has only 1 page.

What happens then is even though the blank page is not printed, the one
page pdf is also not printed.

Below is the modified script based on the one Panman posted earlier:

#!/usr/bin/perl
#Read from standard input

@text=<STDIN>;

$size=@text;

# Count the number of "showpage"
$count=0;

for($i=0; $i<=$size; $i++)
{
if($text[$i] =~ /showpage/)
{
$count++;
}

}

$num=1;

for($i=0; $i<=$size; $i++)
{

if($text[$i] =~ /showpage/)
{
if($count == $num)
{
$text[$i] =~ s/showpage//i;
for($j=$i+1; $j<$i+20; $j++)
{
$text[$j] =~ s/%%PageTrailer*//g;
$text[$j] =~ s/%%Trailer*//g;
$text[$j] =~ s/%%Pages:\s\d*//g;
$text[$j] =~ s/%%EOF//g;
}

}
$num++;
}


}



print @text;





Does anybody have a better solution or any suggestions?


Thanks,

--

Davie Lynn



____________________ HylaFAX(tm) Users Mailing List
_______________________
To subscribe/unsubscribe, click
http://lists.hylafax.org/cgi-bin/lsg2.cgi
On UNIX: mail -s unsubscribe hylafax-users-request@xxxxxxxxxxx <
/dev/null
*To learn about commercial HylaFAX(tm) support, mail sales@xxxxxxxxx*




____________________ HylaFAX(tm) Users Mailing List _______________________
 To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi
On UNIX: mail -s unsubscribe hylafax-users-request@xxxxxxxxxxx < /dev/null
 *To learn about commercial HylaFAX(tm) support, mail sales@xxxxxxxxx*




Project hosted by iFAX Solutions