I got an email back from Andris at P&T with the following:
Hey Rowan.
Indexing generally refers to a bunch of files - seems to me that you'd
be doing that one file at a time. You should look into
Assets_lib->register_ee_file($filedir_id, $path);
Then if you have a Filedir with ID of, say, 8, that has a PDF file at
"some/other/folder/file.pdf" that you want Assets to know about, just
call ee()->assets_lib->register_ee_file(8, "some/other/file.pdf");
Also, make sure to load the lib beforehand.
$this->EE->load->add_package_path(PATH_THIRD.'assets/');
$this->EE->load->library('assets_lib');
I followed the instructions Andris gave me and with minimal effort, was able to register the files as needed.
So laser focused, i'm really happy with this solution!
In case anyone else is curious, here is some of my code for the PDF generation, imagick pdf to jpg generation, then Assets file registration.
<?php
$this->EE->load->add_package_path(PATH_THIRD.'assets/');
$this->EE->load->library('assets_lib');
// somewhere early in your project's loading, require the Composer autoloader
// see: http://getcomposer.org/doc/00-intro.md
require './site_assets/dompdf/vendor/autoload.php';
// disable DOMPDF's internal autoloader if you are using Composer
define('DOMPDF_ENABLE_AUTOLOAD', false);
// include DOMPDF's default configuration
require_once './site_assets/dompdf/dompdf_config.inc.php';
?>
... generate my $html code i want to turn into PDF ...
Handle the DOM2PDF etc.
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('letter','landscape');
$dompdf->render();
$pdf = $dompdf->output();
$dir = "/assets/uploads/trainee_attachments/";
$path_to_uploads = NSM_BASEPATH.$dir.$member_entry_id."/";
$url_to_uploads = "{path='".$dir."'}/".$member_entry_id."/";
if(!file_exists($path_to_uploads)){
mkdir($path_to_uploads,0777,true);
echo "created directory";
}
$cert_filename = $url_title."_".$format."_certificate_".$member_entry_id;
$cert_url_full = $path_to_uploads.$cert_filename;
if (file_put_contents($cert_url_full.".pdf",$pdf)){
echo "<p>PDF Generated!</p>";
}
echo ("<a href='".$url_to_uploads.$cert_filename.".pdf'>view pdf</a><br/>");
echo ("PDF URL: ".$url_to_uploads.$cert_filename.".pdf");
// display jpg of pdf
$imagick = new Imagick();
$imagick->setResolution(300,300);
$imagick->readImage($cert_url_full.".pdf");
$imagick->writeImages($path_to_uploads.$cert_filename.'.jpg', false);
ee()->assets_lib->register_ee_file(11, $member_entry_id."/".$cert_filename.".jpg");
ee()->assets_lib->register_ee_file(11, $member_entry_id."/".$cert_filename.".pdf");
echo ("<br/>JPG URL: ".$url_to_uploads.$cert_filename.'.jpg');
echo ("<br/><a href='".$url_to_uploads.$cert_filename.".jpg' class='fancybox'><img src='".$url_to_uploads.$cert_filename.".jpg' class='img-responsive col-md-3'/></a>");
?>