Jan 2, 2023 Replies: 61 Hi, This class cPDF.bas (version 0.6 - 2024-01-03) generate PDF File with limited fonctionnalities (but enough for me) Add pages with different paper size (use constants or custom size) PDF standards font (Courier, Helvetica, Times, Symbol and Zapfdingbats), style (Normal, Bold, Italic, Underline and StrikeThrough), encoding cp1252 draw text : single line of text at position x, y draw text flow with explicit and automatic CR at current x,y position with alignment (left, center, right, justify) Measure text (width and height) Measure multiline text (width and height) draw line draw rectangle draw images (only PNG, all format that can be loaded with xui.loadbitmap) use pdf commands directly save to file with/without compression Source full commented, example for B4J and B4A, I don't use B4I (but should be OK) dependencies : B4XCollections RandomAccessFile Help welcome to add support for : PNG image wih colorspace = 6 JPG image loading font from file spsp Attachments 1672644870818.png 7.1 KB · Views: 1,996 1672644931064.png 48.8 KB · Views: 3,772 pdfgen.zip pdfgen.zip 284.4 KB · Views: 1,588 Last edited: Jan 3, 2024 Click to expand...
Hi, This class cPDF.bas (version 0.6 - 2024-01-03) generate PDF File with limited fonctionnalities (but enough for me) Add pages with different paper size (use constants or custom size) PDF standards font (Courier, Helvetica, Times, Symbol and Zapfdingbats), style (Normal, Bold, Italic, Underline and StrikeThrough), encoding cp1252 draw text : single line of text at position x, y draw text flow with explicit and automatic CR at current x,y position with alignment (left, center, right, justify) Measure text (width and height) Measure multiline text (width and height) draw line draw rectangle draw images (only PNG, all format that can be loaded with xui.loadbitmap) use pdf commands directly save to file with/without compression Source full commented, example for B4J and B4A, I don't use B4I (but should be OK) dependencies : B4XCollections RandomAccessFile Help welcome to add support for : PNG image wih colorspace = 6 JPG image loading font from file spsp
mcqueccu Expert Licensed User Longtime User Jan 2, 2023 #2 Great. Please is it able to specify paper sizes example A4 and create multiple pages if the information on a page 1 is more than the page?
Great. Please is it able to specify paper sizes example A4 and create multiple pages if the information on a page 1 is more than the page?
S spsp Active Member Licensed User Longtime User Jan 2, 2023 #3 mcqueccu said: Great. Please is it able to specify paper sizes example A4 and create multiple pages if the information on a page 1 is more than the page? Click to expand... Hi, Yes, there is constants for standards paper size or you can set your own paper size. You ca add add as many pages you want with differents sizes spsp
mcqueccu said: Great. Please is it able to specify paper sizes example A4 and create multiple pages if the information on a page 1 is more than the page? Click to expand... Hi, Yes, there is constants for standards paper size or you can set your own paper size. You ca add add as many pages you want with differents sizes spsp
S spsp Active Member Licensed User Longtime User Jan 2, 2023 #4 Hi, New version 0.2 for image, PNG support for Indexed colorspace (palette) Zip in first post updated spsp
Hi, New version 0.2 for image, PNG support for Indexed colorspace (palette) Zip in first post updated spsp
S spsp Active Member Licensed User Longtime User Jan 3, 2023 #6 Hi, New version 0.3 Add outRaw method, allow you to enter PDF command directly https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/pdfstandards/pdf/PDF32000_2008.pdf chapter 8 explains all the command to draw path, bezier curve....... Code: 'start point (command m) : 20 260 m 'line to (command l) : 60 240 l 'line to (command l) : 20 220 l 'close fill and stroke the path (command b) pdf.outRaw($"20 260 m 100 260 l 60 220 l b"$) Code: 'draw a bezier curve 'start point (command m) : 15 150 m 'control point 1, control point 2, end point (command c) and close path (command S) : 75 200 135 100 195,150 c S pdf.outRaw($"15 150 m 75 200 135 100 195 150 c S"$) Code: 'draw 10 line with random points and fill the path Dim s As String For i=0 To 9 s=s & Rnd(20,190) & " " & Rnd(80,120) & " " & IIf(i=0,"m ","l ") Next s=s & "b" pdf.outRaw(s) pdfGen.zip upated in post #1 spsp
Hi, New version 0.3 Add outRaw method, allow you to enter PDF command directly https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/pdfstandards/pdf/PDF32000_2008.pdf chapter 8 explains all the command to draw path, bezier curve....... Code: 'start point (command m) : 20 260 m 'line to (command l) : 60 240 l 'line to (command l) : 20 220 l 'close fill and stroke the path (command b) pdf.outRaw($"20 260 m 100 260 l 60 220 l b"$) Code: 'draw a bezier curve 'start point (command m) : 15 150 m 'control point 1, control point 2, end point (command c) and close path (command S) : 75 200 135 100 195,150 c S pdf.outRaw($"15 150 m 75 200 135 100 195 150 c S"$) Code: 'draw 10 line with random points and fill the path Dim s As String For i=0 To 9 s=s & Rnd(20,190) & " " & Rnd(80,120) & " " & IIf(i=0,"m ","l ") Next s=s & "b" pdf.outRaw(s) pdfGen.zip upated in post #1 spsp
bleber Member Jan 3, 2023 #7 Great work !!! Some method to merge 2 pages, Base page as template, and add other pdf stuff to merge together. Or generate pdf and add another as backgraud and mege all. Thanks!
Great work !!! Some method to merge 2 pages, Base page as template, and add other pdf stuff to merge together. Or generate pdf and add another as backgraud and mege all. Thanks!
S spsp Active Member Licensed User Longtime User Jan 3, 2023 #8 bleber said: Great work !!! Some method to merge 2 pages, Base page as template, and add other pdf stuff to merge together. Or generate pdf and add another as backgraud and mege all. Thanks! Click to expand... Hi, No, this class doesn't allow that. spsp
bleber said: Great work !!! Some method to merge 2 pages, Base page as template, and add other pdf stuff to merge together. Or generate pdf and add another as backgraud and mege all. Thanks! Click to expand... Hi, No, this class doesn't allow that. spsp
C Chicao99 Member Licensed User Longtime User Jan 7, 2023 #9 Hi, I can't load the attached image, is there any problem? I always get "Insufficient data for an image" error. Attachments image.png 19.4 KB · Views: 868
Hi, I can't load the attached image, is there any problem? I always get "Insufficient data for an image" error.
S spsp Active Member Licensed User Longtime User Jan 7, 2023 #10 Chicao99 said: Hi, I can't load the attached image, is there any problem? I always get "Insufficient data for an image" error. Click to expand... Hi, the color space of your image (6) is not supported. I just open your image with 'Irfan view' and save it, now the color space is 2 and it's OK. I will try to modifiy the class to support this color space. attached, your new image. spsp Attachments image.png 17 KB · Views: 834
Chicao99 said: Hi, I can't load the attached image, is there any problem? I always get "Insufficient data for an image" error. Click to expand... Hi, the color space of your image (6) is not supported. I just open your image with 'Irfan view' and save it, now the color space is 2 and it's OK. I will try to modifiy the class to support this color space. attached, your new image. spsp
behnam_tr Active Member Licensed User Longtime User Jan 8, 2023 #12 Great work Thank you plz add support for persian and arabic characters.
S spsp Active Member Licensed User Longtime User Jan 9, 2023 #13 Hi, Version 0.4 add style StrikeThrough to font add constants for style (fontNormal, fontBold, fontItalic, fontUnderline and fontStrikeThrough) add constants for color (colorBlack, colorWhite, colorBlue, colorGreen, colorRed and colorGray) add method gMultilineTextSize. support automatic and explicit CR add method outDrawFlow to write multiline text pdfgen.zip in post#1 updated spsp
Hi, Version 0.4 add style StrikeThrough to font add constants for style (fontNormal, fontBold, fontItalic, fontUnderline and fontStrikeThrough) add constants for color (colorBlack, colorWhite, colorBlue, colorGreen, colorRed and colorGray) add method gMultilineTextSize. support automatic and explicit CR add method outDrawFlow to write multiline text pdfgen.zip in post#1 updated spsp
S spsp Active Member Licensed User Longtime User Jan 9, 2023 #14 behnam_tr said: Great work Thank you plz add support for persian and arabic characters. Click to expand... Hi, The standard PDF font use encoding cp1252 so no persian or arabic characters. Sorry spsp
behnam_tr said: Great work Thank you plz add support for persian and arabic characters. Click to expand... Hi, The standard PDF font use encoding cp1252 so no persian or arabic characters. Sorry spsp
MichalK73 Well-Known Member Licensed User Longtime User Jan 9, 2023 #15 Hello. I'm testing this library right now. It's simple and fun to create pdf. However, I have a problem to solve. Namely, I have text for several pages. Now, when I insert a longer text, the page ends, the text as much as possible is on the PDF, the rest is not. How to detect the end of a PDF page so that further text goes to the next page?
Hello. I'm testing this library right now. It's simple and fun to create pdf. However, I have a problem to solve. Namely, I have text for several pages. Now, when I insert a longer text, the page ends, the text as much as possible is on the PDF, the rest is not. How to detect the end of a PDF page so that further text goes to the next page?
Johan Hormaza Well-Known Member Licensed User Longtime User Jan 13, 2023 #16 B4i This code is not compatible with iOS
Erel B4X founder Staff member Licensed User Longtime User Jan 15, 2023 #17 You should use ByteConverter.HexFromBytes in all platforms.
Johan Hormaza Well-Known Member Licensed User Longtime User Jan 15, 2023 #18 Erel said: You should use ByteConverter.HexFromBytes in all platforms. Click to expand... Ok I have solved that problem. Also, I also modified the cPDF class a bit to make it work with iOS, I'll share the settings tomorrow.
Erel said: You should use ByteConverter.HexFromBytes in all platforms. Click to expand... Ok I have solved that problem. Also, I also modified the cPDF class a bit to make it work with iOS, I'll share the settings tomorrow.
Johan Hormaza Well-Known Member Licensed User Longtime User Jan 17, 2023 #19 Hello, I made several adjustments to the cPDF class so that it is also compatible with iOS (B4i). Any questions I will be available. Attachments Project.zip Project.zip 138.4 KB · Views: 954
Hello, I made several adjustments to the cPDF class so that it is also compatible with iOS (B4i). Any questions I will be available.