B4A Library PDFCreator

This is a shortcut wrap for this Github project. The project is started as an external activity from B4A. You will have to play around with it to see what it does. I have not tested all the functionality of the project.

You need at least Android 4.4 to run this project.

Posting the following:
1. B4A library files.
2. Link to the other Jars that are required. Download them from HERE and then copy them to your additional library folder.
3. The Java code - change it to your liking

Sample code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: PDFCreator
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\resource
#AdditionalRes: ..\PDFCreator_res

'IMPORTANT!!!! YOU NEED TO SET THE FOLLOWING PATHS CORRECTLY FOR YOUR OWN COMPUTER!!!!!!!!!!!!!!!!!!
'THE BELOW PATH IS THE PATH FOR MY COMPUTER
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design

#Extends: android.support.v7.app.AppCompatActivity

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
   
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
    Private Label1 As Label
    Dim pdfcreator As PDFCreator
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
   
    Activity.LoadLayout("main")
    pdfcreator.Initialize("pdfcreator")
    Label1.Visible = True
    Label1.Text = "Wrapped by Johan Schoeman"

End Sub

Sub Activity_Resume
   
   
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
   
  pdfcreator.StartPDFCreator
 
End Sub

Take note of the following in the B4A project and set your path to whatever the path might be on your own computer:

B4X:
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design

Also take note of the B4A manifest in case you start a new project:

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="22"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
AddApplicationText(<activity
            android:name="de.baumann.pdfcreator.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">

<!--            <intent-filter>   -->
<!--                <action android:name="android.intent.action.MAIN" /> -->
<!--                <category android:name="android.intent.category.LAUNCHER" />  -->
<!--            </intent-filter>   -->

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="image/*" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="text/plain" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="application/pdf" />
            </intent-filter>

        </activity>

        <activity
            android:name="de.baumann.pdfcreator.ActivityEditor"
            android:theme="@style/AppTheme.NoActionBar">
        </activity>


        <activity
            android:name="de.baumann.pdfcreator.UserSettingsActivity" />

        <activity
            android:name="com.theartofdev.edmodo.cropper.sample.MainActivity" />

        <activity
            android:name="com.theartofdev.edmodo.cropper.sample.CropResultActivity" />

        <activity
            android:name="com.theartofdev.edmodo.cropper.CropImageActivity" />)

        SetActivityAttribute(Main, android:screenOrientation, "portrait")

1.png


2.png


3.png


The B4A wrapper is very simple but it took me a while to get the rest of the library sorted out...Enjoy!
 

Attachments

  • TheJavaCode.zip
    241.6 KB · Views: 354
  • PDFCreatorLibFiles.zip
    338.4 KB · Views: 362
  • b4aPDFCreator.zip
    224.3 KB · Views: 362

Richard O'Sullivan

Member
Licensed User
PDF - I've been trying to get printing to PDF working.

Not sure exactly what to do with the JavaCode.zip file above.

Receiving the following error message:

Generating R file. Error
c:\androidsdk\extras\android\support\v7\appcompat\res\values-v23\styles_base.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
c:\androidsdk\extras\android\support\v7\appcompat\res\values-v23\styles_base_text.xml:19: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.


Any help appreciated.

Richard
 

Johan Schoeman

Expert
Licensed User
Longtime User
PDF - I've been trying to get printing to PDF working.

Not sure exactly what to do with the JavaCode.zip file above.

Receiving the following error message:

Generating R file. Error
c:\androidsdk\extras\android\support\v7\appcompat\res\values-v23\styles_base.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
c:\androidsdk\extras\android\support\v7\appcompat\res\values-v23\styles_base_text.xml:19: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.


Any help appreciated.

Richard
You need to set your own paths in this part of the code:

#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design
 

Richard O'Sullivan

Member
Licensed User
Johan,

Thanks for the reply. Your work is amazing but a bit above my head. I've added all the libraries, I've changed the paths to my own as per the error message above
( I use AndroidSDK) and plenty other messages were removed but I cant understand that just 2 items based around Buttons are referred to in the program and they are stopping me getting to know your utility. Could you upload a fully functional project extract?

The Javacode.zip file - what exactly do I do with that file?

Richard
 

Richard O'Sullivan

Member
Licensed User
Most probably; eating if you need to ask :D

Honestly: It is the java source of the lib which you can use to change the lib. java knowledge needed.

Well that's a really "helpful" sarcastic answer. There are people here still trying to get to grips with B4A. I've tried Java and then found B4A which is a fantastic product. If you cannot LOWER yourself to my level then I'd rather you refrained.

Maybe somebody else out there may explain (in simple instructions) where the code fits into project setup. Thanks in advance.

Richard
 

Richard O'Sullivan

Member
Licensed User
Were getting somewhere. Now I realise it was a red herring.

I've done what I needed in the project but it still does not work. I think that maybe its an issue with my recent upgrade in B4A to 6.5 or that the Android SDK is not properly upgraded to the latest versions - 23 or something like that.

The same issue has occurred with some other projects so maybe it's my setup.

Thanks

Richard
 

DonManfred

Expert
Licensed User
Longtime User
upgraded to the latest versions - 23

I guess you mean the SDK Number. 25 ist most up to date.

Make sure to have the 2 new Respositories installed...

41 is most up to date for both repositories... Make sure your have both in v41
Please update your SDK if you do not have the repos at all or a older version of them...
 

Phayao

Active Member
Licensed User
Longtime User
Well, I'm obviously also missing something - when trying to compile the example, i get the error messages:

B4A version: 6.50
Parsing code. (0.01s)
Compiling code. (0.21s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.00s)
Generating R file. Error
..\pdfcreator_res\values-de\dialogs.xml:6: warning: string 'about_title' marked untranslatable but exists in locale 'de'
..\pdfcreator_res\values-de\dialogs.xml:7: warning: string 'about_text' marked untranslatable but exists in locale 'de'
..\pdfcreator_res\values-de\dialogs.xml:28: warning: string 'lib_text' marked untranslatable but exists in locale 'de'
..\pdfcreator_res\values-de\dialogs.xml:45: warning: string 'dialog_help' marked untranslatable but exists in locale 'de'
..\pdfcreator_res\values-de\dialogs.xml:64: warning: string 'dialog_createImage' marked untranslatable but exists in locale 'de'
..\pdfcreator_res\values-de\dialogs.xml:85: warning: string 'dialog_addImage' marked untranslatable but exists in locale 'de'
....... and much more like this.

I made sure to have the right paths for #AdditionalRes

Any idea what's going wrong ? Help is very appreciated,

Chris
 

Phayao

Active Member
Licensed User
Longtime User
Thanks Manfred, though I just try to reproduce the example, i did not add other libraries....
 

Johan Schoeman

Expert
Licensed User
Longtime User
Thanks Manfred, though I just try to reproduce the example, i did not add other libraries....
Need to find this one again - it is somewhere on my laptop. But best option is to probably comment out lines

#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design
#Extends: android.support.v7.app.AppCompatActivity

...and enable Appcompat V3.20 and Designer V2.00 in your libraries tab
 

Phayao

Active Member
Licensed User
Longtime User
thanks for the feedback - sounds good but ... same error messages.
I agree, it must be some messed up libraries... i keep trying...
 

Johan Schoeman

Expert
Licensed User
Longtime User
thanks for the feedback - sounds good but ... same error messages.
I agree, it must be some messed up libraries... i keep trying...
OK - try with the attached library files. First part of the B4A code is as follows (rest of the code remains as is):
B4X:
#Region  Project Attributes
    #ApplicationLabel: PDFCreator
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\resource
#AdditionalRes: ..\PDFCreator_res

'IMPORTANT!!!! YOU NEED TO SET THE FOLLOWING PATHS CORRECTLY FOR YOUR OWN COMPUTER!!!!!!!!!!!!!!!!!!
'THE BELOW PATH IS THE PATH FOR MY COMPUTER
'#AdditionalRes: C:\Android\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\Android\extras\android\support\design\res, android.support.design

'#Extends: android.support.v7.app.AppCompatActivity

Note the two lines (#AdditionalRes) that have now been commented out as well as the line #Extends that has been commented out. Now you need to make sure that AppCompat V3.20 and DesignSupport V2.00 are enabled. It should then work. Have just tested it this way on my S4 mini with KitKat and all OK.

The other jars still need to be downloaded from the link in post #1
 

Attachments

  • PDFCreatorLibFiles_V1.01.zip
    336.9 KB · Views: 233

Phayao

Active Member
Licensed User
Longtime User
Thank you very much Johan, that did work without any problems.
I appreciate the additional work you did for me and hope it's helpful for others as well.
Chris
 
Top