Could you help me please to solve my problem. I have to use zend Framework to generate Pdf files. i choose to use FPDF library to do it. When i try to generate Pdf, i get the message below :
%PDF-1.3 3 0 obj <> endobj 4 0 obj <> stream x???Mn۰ ???,:&? ?s ?h?? ?e6?Ŧlː? ?U??[t Ų-ۚD+IC~|߮ f ??E! ??Q ?'2? ڵ?+(ޅfќ#? ~H? ?Ң?I?H? iyƬ( 4???]Ymⳑ𰽥-??B3??z?IZ ?LaӇ?Y?t k%sI???? 楸L9?7֫Ԫ???? _?E??$E? ?'?N݉?y?; ,?ӀX?? m}꒹夐e?????4ԁ搭Ὤ? ???Ϳ?ꢮ?1?ʮ ,;A ǐ ny آr ?B?謐"Ɇ?E ˕ɍ??=ɪ踀Dµ?Ӟصe?}_IJ? m?,?? hYmx?? Ňy7?G?Č???] my`9Bㆥ?8䣖m[???Ĩ ?? ~??Ѓ1??媵}fo8僀f ]v!?>?iY?p/(Ej??n?????'?c?O??h?$䳹Ӽ¬???\ ?ER)DJ)? ?}?FN?q:?ˊY㮘? 봐轊 Ø??Йx?͡7??K???? endstream endobj 1 0 obj <> endobj 5 0 obj <> endobj 2 0 obj << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI] /Font << /F1 5 0 R >> /XObject << >> >> endobj 6 0 obj << /Producer (FPDF 1.7) /CreationDate (D:20120427161022) >> endobj 7 0 obj << /Type /Catalog /Pages 1 0 R >> endobj xref 0 8 0000000000 65535 f 0000000725 00000 n 0000000908 00000 n 0000000009 00000 n 0000000087 00000 n 0000000812 00000 n 0000001012 00000 n 0000001087 00000 n trailer << /Size 8 /Root 7 0 R /Info 6 0 R >> startxref 1136 %%EOF
I searched the web but i haven't find a solution, so i tried to generate my files with Zend_PDF but i got the same message and not a pdf file.
Please help!
Thanks
Looks like you're not setting your headers correctly, I'm guessing you're using render() in Zend_PDF so try adding this in place on your current render()
$this->getResponse()->setHeader('Content-type', 'application/x-pdf', true);
$this->getResponse()->setHeader('Content-disposition', 'inline; filename=my-file.pdf', true);
$this->getResponse()->setBody($pdf->render());
See Zend Framework PDF problems
Related
Let us say that I have 7 values: a, b, c, d, e, f and g
I would like to construct an m by n matrix in this way:
[ a b c d 0 0 0 0 . . . .
[ b e f g 0 0 0 0 . . . .
[ c f a b c d 0 0 . . . .
[ d g b e f g 0 0 . . . .
[ 0 0 c f a b c d 0 0 . .
[ 0 0 d g b e f g 0 0 . .
[ . . 0 0 c f a b c d . .
[ . . 0 0 d g b e f g . .
And so forth...
Therefore, the desired matrix is symmetrical. Values a and e alternate on the main diagonal; values b and f alternate on the 1st upper diagonal; values c and g alternate on the 2nd upper diagonal; values d and 0 alternate on the 3rd upper diagonal. I would like to be able to specify the matrix size with m by n parameters.
I used to do this easily with the SparseArray and Band functions in Mathematica, but I cannot find equivalent functions in Matlab. Would there be an efficient way to construct this kind of matrix in Matlab?
You can use spdiags to specify the upper diagonals in a sparse matrix and then add the transpose of the strictly upper triangular part for exact symmetry:
>> n = 6;
>> a = 1;b = 2;c = 3;d = 4;e = 5;f = 6;g = 7;
>> n = 6;
>> A = spdiags(repmat([[a;e] , [f;b] , [c;g] , [0;d]],n/2,1),0:3,n,n);
>> A = A + triu(A,1).';
>> issymmetric(A)
ans =
1
>> full(A)
ans =
1 2 3 4 0 0
2 5 6 7 0 0
3 6 1 2 3 4
4 7 2 5 6 7
0 0 3 6 1 2
0 0 4 7 2 5
You might notice I flipped b/f and 0/d to adjust for the filling behavior; there may be a better way to do this.
For non-square matrices with potentially odd dimension number, I would build the minimum-sized square sparse matrix that has the actual one as a sub-matrix and mask out the unneeded portion at the end:
>> m = 13;
>> n = 6;
>> p = max([m,n]);
>> p = p + mod(p,2); % added to make p even.
>> A = spdiags(repmat([[a;e] , [f;b] , [c;g] , [0;d]],p/2,1),0:3,p,p);
>> A = A + triu(A,1).';
>> A = A(1:m,1:n);
>> full(A)
ans =
1 2 3 4 0 0
2 5 6 7 0 0
3 6 1 2 3 4
4 7 2 5 6 7
0 0 3 6 1 2
0 0 4 7 2 5
0 0 0 0 3 6
0 0 0 0 4 7
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
It's a tad inefficient to build, but easy and straight-forward.
You can use the spdiags function
Using numbers instead of letters (sparse does not support symbols) like this:
m = 10;
n = 10;
B = repmat([1:4;[5:7 0]],n/2,1);
B=[B(:,end:-1:2) B];
d=-3:3;
A = spdiags(B,d,m,n);
full(A)
which outputs:
1 6 3 0 0 0 0 0 0 0
2 5 2 7 4 0 0 0 0 0
3 6 1 6 3 0 0 0 0 0
4 7 2 5 2 7 4 0 0 0
0 0 3 6 1 6 3 0 0 0
0 0 4 7 2 5 2 7 4 0
0 0 0 0 3 6 1 6 3 0
...
Explanation:
The B matrix contains the values needed on the diagonals in its columns. It is first constructed using B = repmat([1:4;[5:7 0]],n/2,1); which makes the first two rows repeat n/2 times. At that point it looks like:
1 2 3 4
5 6 7 0
1 2 3 4
5 6 7 0
1 2 3 4
5 6 7 0
1 2 3 4
...
Then it is mirrored to give it the diagonals that are in the lower diagonal part using B=[B(:,end:-1:2) B]; which makes it look like:
4 3 2 1 2 3 4
0 7 6 5 6 7 0
4 3 2 1 2 3 4
0 7 6 5 6 7 0
4 3 2 1 2 3 4
0 7 6 5 6 7 0
4 3 2 1 2 3 4
...
These are the diagonals passed to the spdiags function.
The end is a MATLAB keyword which refers to the last column or row. That indexing line says, in words: "Take all the rows of B, and the columns starting from the end, going back 1 step at a time until the second column, and place that submatrix before B." That is how the mirroring is accomplished.
I have input files containing data in the following format.
65910/A
22 9 4 2
9 10 4 1
2 5 2 0
4 1 1 0
65910/T
14 7 0 4
8 4 0 2
1 2 0 0
1 1 1 1
.
.
.
I need to take the input where the first line is a combination of %d and %c with a / in between and the next four line as a 4x4 integer matrix. I need to perform some work on the matrix and then identify them with the header information.
How can I take this input format in MATLAB?
Since your file contains data that may be considered structured (or "formatted", if using MATLAB's terms), you can use the textscan function to read its contents. The main advantage of this function is that you don't need to specify how many times your "header+data" structure appears - the function just keeps going until it reaches the end of the file.
Given an input file with the following structure (let's call it q35853578.txt):
65910/A
22 9 4 2
9 10 4 1
2 5 2 0
4 1 1 0
65910/T
14 7 0 4
8 4 0 2
1 2 0 0
1 1 1 1
We can write something like this:
function [data,headers] = q35853578(filepath)
%// Default input
if nargin < 1
filepath = 'q35853578.txt';
end
%// Define constants
N_ROWS = 4;
VALS_PER_ROW = 4;
NEWLINE = '\r\n';
%// Read structured file contents
fid = fopen(filepath);
headers = textscan(fid,['%u/%c' repmat([NEWLINE repmat('%u',1,VALS_PER_ROW)],1,N_ROWS)]);
fclose(fid);
%// Parse contents and prepare outputs
data = cell2mat(reshape(cellfun(#(x)reshape(x,1,1,[]),headers(3:end),...
'UniformOutput',false),VALS_PER_ROW,N_ROWS).'); %'
headers = headers(1:2);
%// Output checking
if nargout < 2
warning('Not all outputs assigned, some outputs will not be returned!')
end
%// Debug
clear ans fid N_ROWS NEWLINE VALS_PER_ROW filepath
keyboard; %// For debugging, delete/comment when done.
The resulting output is a 3d array of uint32 (the output class can be changed by adjusting the inputs to textscan, as permitted by formatSpec):
ans(:,:,1) =
22 9 4 2
9 10 4 1
2 5 2 0
4 1 1 0
ans(:,:,2) =
14 7 0 4
8 4 0 2
1 2 0 0
1 1 1 1
Hi I am trying to use tiff2pdf to convert some tiff files captured by the fax application in asterisk to PDF
I have installed tiff2pdf by the following method:
sudo yum install ghostscript libtiff
When I execute the command to convert I get the following:
[root#cloud01 tmp]# tiff2pdf FAX-443439791001-2015-09-26_00-34-40.tiff
II*%PDF-1.1
%âãÏÓ
1 0 obj
<<
/Type /Catalog
/Pages 3 0 R
>>
endobj
2 0 obj
<<
/CreationDate (D:20150926003458)
/ModDate (D:20150926003458)
/Producer (libtiff / tiff2pdf - 20100615)
/Creator (Spandsp 20110122 075024)
/Subject (01279 850795)
>>
endobj
3 0 obj
<<
/Type /Pages
/Kids [ 4 0 R ]
/Count 1
>>
endobj
4 0 obj
<<
/Type /Page
/Parent 3 0 R
/MediaBox [0.0000 0.0000 609.8823 833.8776]
/Contents 5 0 R
/Resources <<
/XObject <<
/Im1 7 0 R >>
/ProcSet [ /ImageB ]
>>
>>
endobj
5 0 obj
<<
/Length 6 0 R
>>
stream
q 609.8823 0.0000 0.0000 833.8776 0.0000 0.0000 cm /Im1 Do Q
endstream
endobj
6 0 obj
62
endobj
7 0 obj
<<
/Length 8 0 R
/Type /XObject
/Subtype /Image
/Name /Im1
/Width 1728
/Height 1135
/BitsPerComponent 1
/ColorSpace /DeviceGray
/Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 1728 /Rows 1135>>
>>
stream
ó"yËhªŠf.f)àù˜¦b™Šf))dJ†Nï…3dO<)P)àç…<𧃖îØsÁ ó<Ÿ)ò|¾Ol¸97päù S`ä\S7™Šfág³#Ìú#ÌöyžÏ3ÙæqS¼#Ìâù÷¡æ{;Â<Ϥ#Ìâ3Ùô<Ϥ#Ìövúgsœó9ÿüÏ:s›èsŸ‚/„yÎyžÎðó=ÿü(A…ÂøþyáGð‚ÿð¡ÿÿðÿÿÿ|(þxøAaøA„wáÿòïÇÿä'B;ÿú_„g°‹þoÿ ïÂ
ïá!Â
, °‚ð‚Ãá<ó>î^AØpžg¸Aay½ŽCŸøg¿ñü„7â¾l/ð‚øAO3ðPü ‚
:xAcÃð‚Ê|B<Ϧ”øóÌî{>‚
ï
ïþsþs} AäüáaøACøA
, ¡p/…á_ð°‚ÿÃ9ðøAÿÿø_ÂøAxA~Aÿáty?þ_æÿüßþÏœü8aÿÎxgïø‡à°Âðˆ0ŒÅ"á!úN0ð#ˆyɆaH0‚!îì„¿ÿæÂrnÿ
“ä\#Á0Â<""""""""""""""""""""†ÊÐ`ÃÃÁ·ÃÛvØpÏn‚#Ì8»D|·vÛaÓ
†G 0Èl0s.a†pÑ0í°Ão[•6
“c<Ž¥ºª
838—Á²:†Q±œÙÍŒÂ#¢?hŽ¡¢:#òÜÎàÎoSQa¶áÃ`ÌÔ
‘û: 0qg:# `ì60pØaƒÎ`î`ÁĆÁƒ†RˆüCDt9œÃÐn´pÎpÃD
C†Q æøCMˆÚ#Ñ#â
8‘Ó ÍA{
;(€Á¢=g!†ì2l;‰ ìM9¼ñf Ù6/ƒ32ÎÎn€áœÝÃ9ºˆ35+&ÂH0â
0vpØ0pÊÐ0hYômÄŽ˜`ÈÚåB ÍB °¦ÑaÄš–M‹qf¡©6#ʦ™‘Ón“e4šdŒÆâ0eˆMLHèm0Q&êù6JØ8“r|›lIºNm00aÉ¿`ÌÓV ÎMφ[L`ƒ‘Õ‡&õ `ø0âGÃÍÄŒÓÀÊ7;NŽƒ-¤hÊ7%ÐaÄŽ–ÒXe”
›\8—#Ëi2Êq:³´‹ ¹b
°Ãƒ ¡ÎÒ(>!¤,ᙤ&ÎvØg73Hè0â
0ᆠÍ%Ýa;H‰†f•AÈê6GRÈjƒ$tMÕh†šC†å’h33L™ÍÉC‰už$tÁÄpe³BË"t
ƒá»1²ƒ5•C °`á†8aƒD~ØhŽ¡°ÁØ0`àØr:†cdáÛGáÃe› ;9ºXq.™šTÎn—#¨em`¶hÃaÈü0Á²:¶
ÌÑ0ÖA¤ C†
ÌÐ! pØdšÃb
82™¤Ë ®$z ÎÍ™µƒ;7PÌÍ C”Í£q#ðÎÍ€ÎÍ33
Ãøg6*Dua†Aƒ–á2mRVs`³5U1°P83›paٔʦ©P3›)2:ˆ4G帲#¡aDGxlÁ˜–Ù‹a–Ì%Gá”l.Ìl.6
¦b›-˜ ¶¨ÛDt8³›"?l[‰0{&Ëuƒ
82‡)˜TðËf
Pp`ááœr™„Æ0á¸ff'veMÃ;00Î9LÊàÎÌàÎ9LÇ,°‰B
ã”Îf,ìƒ$u:n!¸fgXfuPggS
ÌáMÁœµÈüC(r™ÅÞÇ)œL0àäu;O †PægV؆í†S8FÙ™Ä6
Ìõ¶Ë ªft
A”9LómÈü0Ãv0á†på‘ÐaØ1v„°Ã
í
a†ÚC
ˆgh(ÃveSB“bÎÐl8a†îh0ɹšv‚¡
0Ì9Ml0n`ÌÐdÜÉ)0ÙLº”9Ú†ÄC)¡C
Hô0Á”Ð00Ùm†jVˆêÛpaƒ;Ea™£ƒ
òlD C”ц,ã”Êh
8lNG3(#ÊeXlDYÇ)•P0Ɔ
¡Êe
1e2‚tËe*l›¢Ê*¡ƒ[(«eob
Ì£A†YðgelC)”À`ÙC”9L¡‚G†Å™”C`ÎÊ¢>YfeÔ6$t
ã”ʀ؋;-eMPå2ðlXv
µ
CbÎÈhÙdAÈ0Ä2ÙŠÞe¨¢Û3! l³ŠàÎȨÃ,‚hC(r™Ú#¡+‹(s²†ˆùdÄC)±±e²0ËQf†ÁM°Ê¦A¦dBÎÈD|C;"FÃ3"€ÃfBí‰Ô6Ã°Ë ¢,£jسŽS!Ãa¢?aˆgdæÃ)“
HêÙdÄ¿lDÃD|3ŽQºËe]0ÄŽ»læó*#f7S
1HHý±
ÛÎ9Fá £pPÛ)Ê7+aŠVÄŽá†Z¥øl2ÅlæâFE;aœÜhCDtÌ0Ë!J
7aƒ9¸€Øg7NÙd*A”oXaˆ‘øhŽƒ9¹
0Ë7˜lvnØÃ
²"Ê«‘Õ±sc0Øg6Ka–B¤FÉA†$tÌl²Øƒ(Ù`0Ù•[,…H7
6vU£›)4GÄ2‚ÃbGPØ‘û
†Q²#ÑB¤$zÃg6.#áœØB¤Í«Ä3›jÃ,…(3ŽQ²DtÎʬå{ 3BGPÃ,…)”l,âÊ£a0Ùd,BÎl6ÃÎl†sc
Rf6˜lAœÛš#¢ÈT˜vƒ(ÚDtY
БղÈT™Û’†vêË!ZŽ…á†$u
¡ÊnÎÈTS#gn
L…ESB²mRB›–ÙÛ•‹!^Û”3µVJn.l…4jvâa¢:Èè0pÑtÃ… 2š*؆a‡GEY7r:ƈùdÃhŽƒ)¢·ÎÑXpÎ9L‚Å4'pÃ:
0ŸhŽƒrÈ-‡.¡œsµVpÓš«AÃdt
6pÁ†ˆü9dMÛ.™M
8°pÙ
0ᙪ´0eÂåÔ2Ú«HŽ¡Ë Þ0pÊd)¡[™3µRÈgj¥¸g¦ªË‡#àÁÃE
89è7hCpÌÕZr:aÑÑdHƒpÑt!¢?i‡
¶ªË†Ë"M‡
†4GA»
†áœrš«á†Y¦¡¡ 0àá‡g¦Bgh0¡Å“‘fj¬‡
Ðghpì;†[UT©l°ƒ&ÕUvVÔ˜aÄebAÃ8å5IQ†Æš¤í–#xhÃdtMn#¡.ƒÃe4
Œ3ŽS\Ì0á²Éª†
KB¯n
ÃDu`à݇7d)˜¬f
Ãd¥a†áÈè3³¸eµë 1†á–×GE’Šc
”ÌpÃ
²QYšÆA‡
8a–OW#¡#¨mœ°8ÙlžS9Hla‡xgk[X¡¢:‡†fL)œ Èèa‡GPÙd…
1†
²ðÑtÝ¡†vAÎÏXeµªGPÑtMÌÕ¢>0ðÃ&éju
Û†qÊ7S) ”60e5JÚ¢Á–Õ ÍaÁ”9MS6჆áìíU€Î9MU#ðÊrš¡O
-¨”#¨³µXw#¨n 8jÎå5Rƒ;U[ÙmRá¢:Œ8`àäur:‹;V™«ÅrÔÑE¸2š°ÎÕ3µ
ÆãE4TÃn
íBÆᙨPpÃ)¨&$z
qÊj
Ã;L˜gi¨ 87aÄXpx‘Ôe˜±Ã8å5 9Fá¦fM3"È ˆfi¬šjA¸fi‚;L°3´Ê„Û†qÊi‰
í0a¦ 34ëSN¦f˜`ÌÓ8lŽ£pÌÓ‡#¨aÃpfi%2Òú%Õ™¤Êí"Ñ
í"°Êi2‡)¤.ÉuNpÙ6PÎÒHÚJÃ+f§fƒf\ÌíÁs,3´«
Í-‘ÔYC”Ò£Ã2à…4(På4 x‘øe.[#êðÌÍ[
82™«
¦i(‘è2™ªLÌÐPÙ‡†0á¸gfŠ2lÑ aÃpÃ;5CpÎÍ.LÑ]YÙº†På3HS”͘ áá›l†a˜g¦bØr:gf†vb¨g¦`XaÑÔ<Hý¸ff
ᙘ$pÃ;1 gf+
ã”Ì.ܦeA¨gfj™„á™™0e3=™ƒ-C.Ä‹n¬×Ã2*†eáCiÔHðÈêLêB]Ylå`ñ#«38°3³Š7
Ìã#ÊgfgH$tGV¬¡Êg."GVfzƒÄŽˆêäu
Œ3³Àe´pÌДpÜHü2šYÚÃ)aR<0ÁÃgh
Ã;A0ÎÐ 2‡;# ã”Ð&/Ň
¦‚GVM €n
í`àÃ3#íÔYl©e¯jÎÊ´l¤…®…geS
¡Êe
,мY‡)”¬E”¤´–÷#¨Hn"Gì832
µÅh3²„
ÄCeq¥ ¡Ê7Ny‹;*pÌ˨3²†ÙPl¾
¶C"Ø…e²,–ÄÕ”9C”Ȧ-ÔYC”È
ĺ³2Êd+fd(vA`Ì9LƒcpÎÈ™ ƒ;"€Ëd
¶JÙl˜[ HŽø†ss0Ê72?aÁœÜ”3í(¦ë!œÝL3›…‰DŽˆê,æå!˜ÜXHèŽÆ["|3p‚Gâ]YFõ ‰ÔF[+J&”n8—â]YFËB_†se#Ê]ÊP—ÆÍ‹F[#è‘øe
Í€ƒ9²#Ê£eÊ&8e$~9m,(‘øg6/Æ[n¢]G-°ÔHê9L£-µj2ÛQ.£ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿø€
endstream
endobj
8 0 obj
4041
endobj
xref
0 9
0000000000 65535 f
0000000016 00000 n
0000000068 00000 n
0000000253 00000 n
0000000317 00000 n
0000000493 00000 n
0000000611 00000 n
0000000629 00000 n
0000004913 00000 n
trailer
<<
/Size 9
/Root 1 0 R
/Info 2 0 R
/ID[<67458B6BC6237B3269983C6473483366><67458B6BC6237B3269983C6473483366>]
>>
startxref
4933
%%EOF
[root#cloud01 tmp]#
Am I missing a library or some other dependency?
Thanks
From the man page:
tiff2pdf opens a TIFF image and writes a PDF document to standard output.
Perhaps if you tried:
tiff2pdf FAX-443439791001-2015-09-26_00-34-40.tiff > FAX-443439791001-2015-09-26_00-34-40.pdf
Hello I have a char matrix that represents a binary numbers. For example:
0000
1010
0111
.
.
.
1010
How can I convert it to a logical matrix?
You can compare it with character '1'
>> A=['0101';'1011']
A =
0101
1011
>> A=='1'
ans =
0 1 0 1
1 0 1 1
Is this what you want?
a = {'0000'; '1010'; '0111'};
b = logical(double(cell2mat(a)) - 48);
gives,
>> b
b =
0 0 0 0
1 0 1 0
0 1 1 1
>> class(b)
ans =
logical
Try
b_bin = logical(b(:)'-'0')
if b is the name of your matrix.
I'm using CAM::PDF to merge several PDF files. This works fine. Now I need to add a stamp on each page using PDF::API2. This works fine for some pages, but not for others.
PDF files created with wkhtmltopdf seem to have their coordination system flipped and the scaling is off as well.
When running through the pages I add a stamp like this:
my $pdf2 = PDF::API2->open_scalar($pdf_data);
my $page_count = $pdf2->pages;
for my $i ( 1 .. $page_count ) {
my $page = $pdf2->openpage($i);
my $content = $page->gfx();
my $text = $page->text();
$content->linewidth(2);
$content->rectxy( 5, 10, 140, 40 );
$content->stroke;
my $font = $pdf2->ttfont('calibri.ttf');
$text->scale( 1.0, 1.0 );
$text->font( $font, 12 );
$text->translate( 10, 14 );
$text->text( sprintf( 'PAGINA %d VAN %d', $i, $page_count ) );
$text->translate( 10, 26 );
$text->text('some ID');
}
my $pdf_data = $pdf2->stringify;
Now, the pages that are from the wkhtmltopdf have a tiny box with even tinier text in the top left corner (but inside the page margins) and it's mirrored. The non-wkhtmltopdf page has a properly sized box with properly sized text in the bottom left corner (ignoring page margins).
Using $content->scale and $content->rotate(180) I can properly display the stamp on the pages created by wkhtmltopdf. But then the other pages are messed up.
So, is there any way to make sure that each document has the same orientation, rotation and scale on all pages?
++Htbaa has already answered HOW to get around this problem.
I've had a chance to look at wkhtmltopdf. This answer describes WHY it's output is causing problems.
I wrote a trivial /tmp/hw.html
<html>
<body>hello world!</body>
</html>
Then created and uncompressed a pdf:
% wkhtmltopdf --version
Name:
wkhtmltopdf 0.9.9
...
% xvfb-run wkhtmltopdf /tmp/hw.html /tmp/hw.pdf
% pdftk /tmp/hw.pdf output /tmp/hw1.pdf uncompress
Here's what the page content (object 8) looks like.
8 0 obj <</Length 751>>stream /GSa gs /CSp cs /CSp CS 0.060000000 0 0
-0.060000000 28.3200000 813.679999 cm q q Q Q q q Q q /CSp cs 0 0 0
scn /GSa gs Q Q q 0 0 m 8963.99983 0 l 8963.99983 345.507488 l 0
345.507488 l 0 0 l h W* n q /CSp cs 0 0 0 scn /GSa gs /CSp cs 1 1 1
scn /GSa gs q 9.59743022 0 0 9.59743022 0 0 cm 0 0 934 36 re f Q Q q
9.59743022 0 0 9.59743022 0 0 cm /CSp cs 0 0 0 scn /GSa gs 0 0 0 SCN 0
w 2 J 2 j [] 0 d q /CSp cs 0 0 0 scn /GSa gs BT /F7 16 Tf 1 0 0 -1 0 0
Tm 8 -24 Td <0001> Tj 9 0 Td <0002> Tj 9 0 Td <0003> Tj 4 0 Td <0003>
Tj 4 0 Td <0004> Tj 9 0 Td <0005> Tj 4 0 Td <0006> Tj 12 0 Td <0004>
Tj 9 0 Td <0007> Tj 5 0 Td <0003> Tj 4 0 Td <0008> Tj 9 0 Td <0009> Tj
ET Q Q Q q q 12 0 0 12 0 0 cm /CSp cs 0 0 0 scn /GSa gs 0 0 0 SCN 0 w
2 J 2 j [] 0 d Q Q
endstream endobj
The answer is in the very first instruction on the page /GSa gs is setting the graphics state, occurs before the first q instruction (save graphics state).
So the page is being left in an untidy graphics state. When further content is then added to the PDF by PDF::API2, it is using the altered state.
The answer pointed out by #snoopy seems to fix the problem I'm experiencing. Text and image size of the stamp-pdf/overlay-pdf are the same size on all pages.