I want to rearrange the position of subtotal,shipment,tax in pdf invoice.
I want to move "tax" before grand total.
The sorting of the totals in the pdf is driven by the sort order assigned in the pdf.xml files. To for example change the sort order of tax create a new custom module and place into it the following etc/pdf.xml file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Sales:etc/pdf_file.xsd">
<totals>
<total name="tax">
<sort_order>650</sort_order>
</total>
</totals>
</config>
You also want to provide a sequence in your module so that it gets sorted after Magento_Tax.