From 1c01d7d9007df6612f22f12e64e1e20aab3b4f56 Mon Sep 17 00:00:00 2001 From: jingeli Date: Thu, 8 Feb 2024 21:02:13 -0600 Subject: [PATCH 1/3] PPF-485: not sure if it's reportlab or pypdf --- docs/draw.md | 92 +++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/docs/draw.md b/docs/draw.md index ef8363b7..cc7520f3 100644 --- a/docs/draw.md +++ b/docs/draw.md @@ -1,44 +1,48 @@ -# Draw stuffs - -PyPDFForm allows you to draw certain elements on a PDF. The purpose is in case there is a missing widget on your PDF -form, and you need to put certain texts on it, or if you need to draw images. - -This section of the documentation will use -[this PDF](https://github.com/chinapandaman/PyPDFForm/raw/master/pdf_samples/sample_template.pdf) as an example. - -This section of the documentation requires a basic understanding of [the PDF coordinate system](coordinate.md). - -## Draw text - -```python -from PyPDFForm import PdfWrapper - -pdf = PdfWrapper("sample_template.pdf").draw_text( - text="random text", - page_number=1, - x=300, - y=225 -) - -with open("output.pdf", "wb+") as output: - output.write(pdf.read()) -``` - -## Draw image - -```python -from PyPDFForm import PdfWrapper - -pdf = PdfWrapper("sample_template.pdf").draw_image( - image="sample_image.jpg", - page_number=1, - x=100, - y=100, - width=400, - height=225, - rotation=0 -) - -with open("output.pdf", "wb+") as output: - output.write(pdf.read()) -``` +# Draw stuffs + +PyPDFForm allows you to draw certain elements on a PDF. The purpose is in case there is a missing widget on your PDF +form, and you need to put certain texts on it, or if you need to draw images. + +This section of the documentation will use +[this PDF](https://github.com/chinapandaman/PyPDFForm/raw/master/pdf_samples/sample_template.pdf) as an example. + +This section of the documentation requires a basic understanding of [the PDF coordinate system](coordinate.md). + +**NOTE:** Due to a known bug in a dependency, it is advised that these draw methods are called after +a PDF form is filled. Otherwise, part (most noticeably radio buttons) or even all widgets of the PDF form might +get removed after drawing things on it. + +## Draw text + +```python +from PyPDFForm import PdfWrapper + +pdf = PdfWrapper("sample_template.pdf").draw_text( + text="random text", + page_number=1, + x=300, + y=225 +) + +with open("output.pdf", "wb+") as output: + output.write(pdf.read()) +``` + +## Draw image + +```python +from PyPDFForm import PdfWrapper + +pdf = PdfWrapper("sample_template.pdf").draw_image( + image="sample_image.jpg", + page_number=1, + x=100, + y=100, + width=400, + height=225, + rotation=0 +) + +with open("output.pdf", "wb+") as output: + output.write(pdf.read()) +``` From 96519da0ba7c4da5f64fed91d1dec7a6b146c13f Mon Sep 17 00:00:00 2001 From: chinapandaman Date: Thu, 8 Feb 2024 21:10:52 -0600 Subject: [PATCH 2/3] PPF-485: update pdf samples --- docs/draw.md | 92 +++++++++--------- .../sample_filled_customized_widgets.pdf | Bin 66260 -> 66222 bytes ...le_filled_font_liberation_serif_italic.pdf | Bin 118886 -> 118772 bytes 3 files changed, 44 insertions(+), 48 deletions(-) diff --git a/docs/draw.md b/docs/draw.md index cc7520f3..ef8363b7 100644 --- a/docs/draw.md +++ b/docs/draw.md @@ -1,48 +1,44 @@ -# Draw stuffs - -PyPDFForm allows you to draw certain elements on a PDF. The purpose is in case there is a missing widget on your PDF -form, and you need to put certain texts on it, or if you need to draw images. - -This section of the documentation will use -[this PDF](https://github.com/chinapandaman/PyPDFForm/raw/master/pdf_samples/sample_template.pdf) as an example. - -This section of the documentation requires a basic understanding of [the PDF coordinate system](coordinate.md). - -**NOTE:** Due to a known bug in a dependency, it is advised that these draw methods are called after -a PDF form is filled. Otherwise, part (most noticeably radio buttons) or even all widgets of the PDF form might -get removed after drawing things on it. - -## Draw text - -```python -from PyPDFForm import PdfWrapper - -pdf = PdfWrapper("sample_template.pdf").draw_text( - text="random text", - page_number=1, - x=300, - y=225 -) - -with open("output.pdf", "wb+") as output: - output.write(pdf.read()) -``` - -## Draw image - -```python -from PyPDFForm import PdfWrapper - -pdf = PdfWrapper("sample_template.pdf").draw_image( - image="sample_image.jpg", - page_number=1, - x=100, - y=100, - width=400, - height=225, - rotation=0 -) - -with open("output.pdf", "wb+") as output: - output.write(pdf.read()) -``` +# Draw stuffs + +PyPDFForm allows you to draw certain elements on a PDF. The purpose is in case there is a missing widget on your PDF +form, and you need to put certain texts on it, or if you need to draw images. + +This section of the documentation will use +[this PDF](https://github.com/chinapandaman/PyPDFForm/raw/master/pdf_samples/sample_template.pdf) as an example. + +This section of the documentation requires a basic understanding of [the PDF coordinate system](coordinate.md). + +## Draw text + +```python +from PyPDFForm import PdfWrapper + +pdf = PdfWrapper("sample_template.pdf").draw_text( + text="random text", + page_number=1, + x=300, + y=225 +) + +with open("output.pdf", "wb+") as output: + output.write(pdf.read()) +``` + +## Draw image + +```python +from PyPDFForm import PdfWrapper + +pdf = PdfWrapper("sample_template.pdf").draw_image( + image="sample_image.jpg", + page_number=1, + x=100, + y=100, + width=400, + height=225, + rotation=0 +) + +with open("output.pdf", "wb+") as output: + output.write(pdf.read()) +``` diff --git a/pdf_samples/sample_filled_customized_widgets.pdf b/pdf_samples/sample_filled_customized_widgets.pdf index 3511bf2efa928643d1939a0a7de63379cf796e5a..08eb16b11971168cea65f04da6c17d8820962428 100644 GIT binary patch delta 875 zcmcc8%CfGNWrN`JdNT_{E;~D};*z4 Xe5IjvXkW=RE#v^^|dpTrmKb@A=5Y{wRp zOotcpTg?-W8OnAn?s=wAe*f#w)|AW5VHdvk8B5FeU;9#3x>@R1vGHF+xm%^>d1Ze$ z$nL)UurO!$vvs@Qw|mYszrD}aK0em&_TOg~GoL;Ddimv@x8aB18AR6W%zAl#Po-7A z|Jm8APrtr9{ogui^XLBz*6iMRe{cL;bN<@jWk!GP@;-Mz{P*8~oqYfC_PqPN&(q8z z^=9X8KRy57F3Y;xZ+55sI{$b*|Nknhva^4RVt@GGI=szV);w2E`rYo6NoLVz-8*9a zb|wD4zSrpg0ps%B-@d2S)Rj$JpITPGvMO$C$lB28t8t|ve;2;$4~-A~yYkiRRr#y_ z#e996J^fU?R{hF9OF!XZoPRk#e%3#kn_r%vSZ42T_SbUL%kvX`>-%zk6{lRDuRI&O zl#iIx{sa2;U%3B(Xp$(e{fE|n(f&g+<+lG|{uk*#$W%Ql7YEO8|KayvtpAWqIo2PL z|HA$U4`qW*(mucAxo<;kW9*Mj{kM)6o(V0DoH6}q^VG}ycTfA-%Jo^aewTM=T(fEO zyO$gi^%iDk3I-sckf*=}W|&%9ni`;qnHd;anxKoB7@HVjh?!vOHL)--MOSBPVrmEy c6F{=q%+%D>a(XKhqZ_A*F_)^UtG^o;00$1do&W#< delta 913 zcmZ42%5tTZWrN`JdUHcdE;~D};*z4 Xe5IjvVuXWdQ^X}!2}zSH4pL34`z4@eZX zI^>(wGP+L-cGQu+Df#5>>bJ5{FBXX2sM++ddAeJAU2T1_{g>lu|8nna<-fb}=9j}& zZ}@gk-}rXc@pmib(-xiGmEWIVzWjaJ?px=dUH)+R^}`#v@7vGjZHq9e|NQ>);lqVB zx%Xn{t>d5n>v&#_?C-lDF7*C=_V{n%*E`$ar+;4mxawD8#jpP-+o%8ixAS({;fUO|yXC#}-nHgmdUx$^;{L4V8y~Kmt$Xg=w6lxe zP1~Fo@&BvOmpR7$v%fvhsciNLrbG(EI-;j^)mn6_j7mMe{0x!UO&-l9oyy;FF7RYEe%W* z3_w63Pk{@}FtxO_us{%@me>W}wsX^!Y diff --git a/pdf_samples/sample_filled_font_liberation_serif_italic.pdf b/pdf_samples/sample_filled_font_liberation_serif_italic.pdf index bd52f96bab4840ac34f940d8d2b0f3328e5ab404..ab4c897b89770783ac57a7cabbe9783dbe3e271e 100644 GIT binary patch delta 2451 zcmaF1fc?vS_6;)6>&+|-x$Nw?ic5-86LYyL=CoeDnaSxaXNd`TegyTT?DKhh6yEXDlt>f9*?E>1L^4#m0XP*bes-i9B3XAoJhGwbE~J(X7d z{%2>eKK=Uc^ndH5&7c1>ShIWM{k`#X&G~D8ml^%F%lq8@@ZW#`b@Khk+w<=8K2I}? z)SI2V{q+2QyDaN&zuBGk>-^*O{Qs-0%Fg~Niv8h#>+m*fS@T>u>36$NCYeQ>b?=Dv z+m-nH`d*{|2aL;ifBT+RQ&%=^eQH_#%Br}nA!|dUuf~;z{9X8}KQun{@5)!NSLLtz z7xVRP_ViQnTJ_8(gRMf(rQl-vG;`Cp{}AXD|ITpT>V{fFOwvHn9cn$d%~LP)-#zVTE7xby`d!|gam}X9 zKVR0Bj;7$z6pWd!(GxPsNf)XCPtt{^T#8cg_K+mT*Xg54cr*zQ-6Sk?mhm)Wy@k2C zf&mC9VkTx7>P*cHjnLJZT3CSXtw*xh!qUPL zU7@9cnJKy@mWBoxjgw;t1pxAT5h?%x delta 2594 zcmew|pZ(ba_6;)6>&*=X2_z%jiBW*ilFNrsR{itKZ5-y;vZ6qh`~;=IL(fb+z@y_Fs;t{mZ?xmH+O>n_muB zz2VzEedF6%$KS1#Pg`_$SAKtf`SSN=yKkL;cKO5M*AH*xzHdL9w=Ke?{`33GhYuIl z_Rsvs^?d&;?w0q?d)JzO>D{%viTksbZ+y6Nw(hxe)6On> zH*IrX#Q(28U*;J1&;Is2tH!$8EcW!uR^9rHRP9?g+RC;qZkBzKqQ2`!t6lp1#rikI zUwD60{nb_5x-Tt$asCbS7t!BzfA!h!edzQ;{6}kDV?4>!%kUpl>ssT{sCulT$b$D@ znE&XlYbKp~S^i^gUHg6fR6V8|`xpE_n*TMBPQCR1G5KGMJxNqOP{;lk`ain=HIYhf z=l!^ibA$ERXxrU_F56vz~w9f?FIg%J(r;jG|(S$zS z6Z)z%jHemvEe%Z-3_w63Pk{@}Ftr2%G%+&+V^cG9F%x4;3k)$+0}OShW~K({>P#(- z!1mT7S!`ixX^gJW(!ksZ-9Sr214|P$11$~BjWNY6OpMUg8ChB&n`a2}vZb++nIWn| jLqnjw$O?hV3=J&|%#5ZlInU_EWoTl?rK;-c@5TiHKR%s( From 3222b5c56e719b839726388fc7d525d06c2c3bd4 Mon Sep 17 00:00:00 2001 From: chinapandaman Date: Thu, 8 Feb 2024 21:11:34 -0600 Subject: [PATCH 3/3] PPF-485: re-update --- docs/draw.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/draw.md b/docs/draw.md index ef8363b7..f8b9e873 100644 --- a/docs/draw.md +++ b/docs/draw.md @@ -8,6 +8,10 @@ This section of the documentation will use This section of the documentation requires a basic understanding of [the PDF coordinate system](coordinate.md). +**NOTE:** Due to a known bug in a dependency, it is advised that these draw methods are called after +a PDF form is filled. Otherwise, part (most noticeably radio buttons) or even all widgets of the PDF form might +get removed after drawing things on it. + ## Draw text ```python