This file is indexed.

/usr/bin/pdf-slices is in slic3r 1.2.9+dfsg-2build1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
#!/usr/bin/perl
# This script exports model slices to a PDF file as solid fills, one per page

use strict;
use warnings;

BEGIN {
    use FindBin;
    use lib "$FindBin::Bin/../lib";
}

use Getopt::Long qw(:config no_auto_abbrev);
use PDF::API2;
use Slic3r;
use Slic3r::Geometry qw(scale unscale X Y);

use constant mm => 25.4 / 72;

my %opt = ();
{
    my %options = (
        'help'                  => sub { usage() },
        'output|o=s'            => \$opt{output_file},
        'layer-height|h=f'      => \$opt{layer_height},
    );
    GetOptions(%options) or usage(1);
    $ARGV[0] or usage(1);
}

{
    # prepare config
    my $config = Slic3r::Config->new;
    $config->set('layer_height', $opt{layer_height}) if $opt{layer_height};
    
    # read model
    my $model = Slic3r::Model->read_from_file(my $input_file = $ARGV[0]);
    
    # init print object
    my $sprint = Slic3r::Print::Simple->new(
        print_center => [0,0],
    );
    $sprint->apply_config($config);
    $sprint->set_model($model);
    my $print = $sprint->_print;
    
    # compute sizes
    my $bb = $print->bounding_box;
    my $size = $bb->size;
    my $mediabox = [ map unscale($_)/mm, @{$size} ];
    
    # init PDF
    my $pdf = PDF::API2->new();
    my $color = $pdf->colorspace_separation('RDG_GLOSS', 'darkblue');
    
    # slice and build output geometry
    $_->slice for @{$print->objects};
    foreach my $object (@{ $print->objects }) {
        my $shift = $object->_shifted_copies->[0];
        $shift->translate(map $_/2, @$size);
        
        foreach my $layer (@{ $object->layers }) {
            my $page = $pdf->page();
            $page->mediabox(@$mediabox);
            my $content = $page->gfx;
            $content->fillcolor($color, 1);
        
            foreach my $expolygon (@{$layer->slices}) {
                $expolygon = $expolygon->clone;
                $expolygon->translate(@$shift);
                $content->poly(map { unscale($_->x)/mm, unscale($_->y)/mm } @{$expolygon->contour});  #)
                $content->close;
                foreach my $hole (@{$expolygon->holes}) {
                    $content->poly(map { unscale($_->x)/mm, unscale($_->y)/mm } @$hole);  #)
                    $content->close;
                }
                $content->fill;  # non-zero by default
            }
        }
    }
    
    # write output file
    my $output_file = $opt{output_file};
    if (!defined $output_file) {
        $output_file = $input_file;
        $output_file =~ s/\.(?:stl)$/.pdf/i;
    }
    $pdf->saveas($output_file);
    printf "PDF file written to %s\n", $output_file;
}

sub usage {
    my ($exit_code) = @_;
    
    print <<"EOF";
Usage: pdf-slices.pl [ OPTIONS ] file.stl

    --help              Output this usage screen and exit
    --output, -o        Write to the specified file
    --layer-height, -h  Use the specified layer height
    
EOF
    exit ($exit_code || 0);
}

__END__