Skip to main content
Participant
Sep 16, 2025 8:27 AM UTC
Question

Split Invoice PDF

Hi,

 

I'm currently studying on a project which I need to insert a single charge invoice PDF to the last page of some specific invoice PDF through Power Automate.  The source invoice PDF file includes many invoices which has different page counts. So what I plan to do is to split the whole PDF file into invidivual PDF. I have do some research on web and find a similar example.

 

https://medium.com/adobetech/split-pdfs-based-on-content-with-adobe-pdf-extract-service-with-microsoft-power-automate-a08dc5fbafaa

 

I try to follow the same workflow and change the searchArray logic. In our invoice, there is "Page 1 of X" will be shown on each page, so I try to use this to identify the page count.

 

 

 

However, when the flow run to the SearchArray, it got the below error. 

 

Action 'searchArray' failed: The execution of template action 'searchArray' failed: The evaluation of 'query' action 'where' expression '@startsWith(item()?['Text'],'PAGE 1 OF')' failed: 'The template language function 'startsWith' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#startswith for usage details.'.

 

I check the raw output of Parse_JSON, some of the "Text" is Chinese characters, symbols, or numeric characters. I'm not sure if these cause the error. Can anyone help? Thanks.

    This topic is closed to new replies. Start a new post to keep the conversation going.

    1 reply

    Participant
    Oct 23, 2026 9:40 PM UTC

    The Null isn't coming from the Chinese characters. Some elements in the Extract output have no Text field at all (figures and other non-text parts of the page come back without one), and startsWith fails on the first one it hits.

    Click "Edit in advanced mode" on the Filter array and use this instead, so a missing field becomes an empty string:

    @startsWith(toUpper(coalesce(item()?['Text'], '')), 'PAGE 1 OF')

    The toUpper also covers invoices that print "Page 1 of" in mixed case. If some invoices still get missed, switch startsWith to contains, because Extract sometimes merges "Page 1 of 3" with other text on the same line.

    Translate