Re: Removing the image from PDF Document Programetiically

119 views
Skip to first unread message

Support

unread,
Apr 9, 2013, 8:34:46 PM4/9/13
to pdfne...@googlegroups.com
 
Are you sure thay you want to edit PDF content directly? You can definitely accomplish this with ElementReader/Writer (ala ElementEdit sample),  but working with image annotations may be simpler. This way you can also take advantage of provided annotation tools and source code to select, move, scale, delete annotations etc.
 
To make this happen you could create a custom annotation and generate its apperance (e.g. see https://groups.google.com/d/msg/pdfnet-sdk/q51fmeKjmWw/HyRpQ9jEpYwJ  also search for SetAppearance() - for more samples https://groups.google.com/forum/?hl=en&fromgroups#!searchin/pdfnet-sdk/SetAppearance), you would then modify tools source code (which is priovided to all licensees) to diplay your image during interactive editing.
 
Hope this makes sense.
 
 
 

On Tuesday, April 9, 2013 3:49:30 AM UTC-7, Prince Sachdeva wrote:
currently i am working on pdftron APi on Android . I have added an image in pdf doc what i need now that when the user click or long press the image it shows the text "Remove image" and on selecting that the added image can be removed .

I have used the following code to add the image at pdf document

public void processCameraResult(PDFDoc doc, Bitmap bitmap)
{
    try
    {
        ElementBuilder elementBuilder = new ElementBuilder();  
        ElementWriter writer = new ElementWriter();            

        doc.lock();                                            

        Page page = doc.pageCreate();       // Create a new page
        writer.begin(page);             // Begin writing to this page
        Image img = Image.create(doc.getSDFDoc(), bitmap);
        //Element element = elementBuilder.createImage(img,new Matrix2D(img.getImageWidth(), 0, 0, img.getImageHeight(),100, 450));
        Element element = elementBuilder.createImage(img,new Matrix2D(img.getImageWidth(), 0, 0, img.getImageHeight(),150, 450));
        writer.writePlacedElement(element);                     // Write the graphic image to page
        writer.end();                                           // Save the page

        doc.pagePushBack(page);                                 // Add the page to the document page sequence
        doc.save(SDFDoc.e_linearized, null);                    // Update the doc with the image
        doc.unlock();                                           // unlock doc

        mPDFView.updatePageLayout();                            // Update the Page Layout after change
        mPDFView.setDoc(doc);                                   // Update the view with the new appended document
    }
    catch (PDFNetException exception)
    {
        handleException(exception, "processCameraResult", "E1032");
    }
    catch (InterruptedException exception)
    {
        handleException(exception, "processCameraResult", "E1033");
    }

}

Reply all
Reply to author
Forward
0 new messages