API reference › Import & Output APIs
pdfBalanceContentStream
Repair an uneven q/Q nesting in the current page's content.
Purpose — Repair an uneven q/Q nesting in the current page's content.
Description — Counts q and Q operators; appends the missing Qs at the end (more saves than restores) or prepends the missing qs at the start (more restores than saves). Useful after editing third-party content streams.
C
int32_t __stdcall pdfBalanceContentStream(PPDF IPDF);
Return value — 1 on success; 0 if no page is open.
C# (P/Invoke)
wrappers/dotnet/LumasPdf.cs
public static extern int pdfBalanceContentStream(IntPtr IPDF);
Area
Import & Output APIs
Category
Core
Exported names
pdfBalanceContentStream
String variants
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
See working code
Worked examples — complete programs in ten languages.