Android Question How to insert Image in pdf file as 1.pdf?

Theera

Expert
Licensed User
Longtime User
For this line code as belows, Is there way inserting Image to be a part of 1.pdf, or not?
B4X:
printer.PrintHtml("job", $"<img src="${WebViewAssetFile("smiley.png")}"/>"$)
 

Attachments

  • InsertImageInPDF.zip
    9 KB · Views: 41

DonManfred

Expert
Licensed User
Longtime User
- This line is not related to PDFs
- No. You need to edit a PDF first (and save again) to use it in a html-code
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
I think Teddybear's strategy may be done.(Merge pdfs)

But I have a new problem in Teddybear'strategy about drive d: which is not in Android OS

B4X:
Private Sub  CreatePDF
'Assume I have 2 pdfs,1.pdf and 2.pdf which are in File.DirInternal
 Me.as(JavaObject).RunMethod("mulFile2One", Null)
End Sub

#if java
import org.apache.pdfbox.io.IOUtils;
import org.apache.pdfbox.multipdf.PDFMergerUtility;
import org.apache.pdfbox.io.RandomAccessStreamCache;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public static void mulFile2One() throws IOException{
        PDFMergerUtility mergePdf = new PDFMergerUtility();
        mergePdf.addSource(new File("D:\\test\\f1.pdf"));
        mergePdf.addSource(new File("D:\\test\\f2.pdf"));
        mergePdf.setDestinationFileName("D:\\test\\mul2one.pdf");
        RandomAccessStreamCache.StreamCacheCreateFunction streamCache
        = IOUtils.createMemoryOnlyStreamCache();
        mergePdf.mergeDocuments(streamCache);
    }
#End If
 
Last edited:
Upvote 0

Theera

Expert
Licensed User
Longtime User
Here is my the lastest project which is attached. there is still error code
 

Attachments

  • InsertImageInPDF2.zip
    481.6 KB · Views: 39
Upvote 0
Top