Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

Add bitmap to certain position

More
IP: 192.168.0.71 8 years 5 months ago - 8 years 5 months ago #13050 by msanchezv
Hi!

I'm testing how the SDK works with images. I have created a view where I draw some lines, then i get its bitmap (i have checked it's not null setting it in an ImageView) and have tried to insert it in the PDF unsuccesfuly.

I have used this method I create in PDFLayoutView:
Code:
public void addImage(Bitmap image) { Page page = m_doc.GetPage(m_pageno); if (page != null) { Document.DocImage docImage = m_doc.NewImage(image, true); PageContent pageContent = new PageContent(); pageContent.Create(); pageContent.GSSave(); com.radaee.pdf.Matrix mat = new com.radaee.pdf.Matrix(200, 112.5f, 100, 300); pageContent.GSSetMatrix(mat); mat.Destroy(); ResImage rimage = page.AddResImage(docImage); pageContent.DrawImage(rimage); pageContent.GSRestore(); page.AddContent(pageContent, false); pageContent.Destroy(); page.Close(); m_doc.Save(); } }

The bitmap has been created with a canvas, drawing on it. When i execute that method, there is no feedback or behaviour in the UI lo let me know anything has happened to that PDF (the image is not inserted). When I re-open the app the PDF document has no changes.

Why the method is not working? How can I add an image in a certain position from the pdf page (for example, at the bottom Y pdf from the bottom and X from the right, like a signature?
Last edit: 8 years 5 months ago by msanchezv.
More
IP: 192.168.0.71 8 years 5 months ago #13051 by Davide
Hi,
are you testing it with the demo project or in your own app?
If you are using your project without a premium license, some methods will not work, I suggest you to check this article for the tests www.radaeepdf.com/support/knowledge-base?view=kb&kbartid=4

You can use this to refresh the view and see the changes :
Code:
public void refreshView(int pageToRefresh){ if(m_layout != null) { m_layout.vRenderSync(m_layout.vGetPage(pageToRefresh)); invalidate(); } }

To change image position, you have to change Matrix values.
More
IP: 192.168.0.71 8 years 5 months ago - 8 years 5 months ago #13052 by msanchezv
I am using the test app with the following configuration:
Code:
public static int mLicenseType = 2; public static String mCompany = "radaee"; public static String mEmail = "[email protected]"; public static String mKey = "LNJFDN-C89QFX-9ZOU9E-OQ31K2-FADG6Z-XEBCAO";

I have debugged and see that this line return null:
Code:
Document.DocImage docImage = m_doc.NewImage(image, true);

my image value is not null but docImage yes. What is the problem?

And, matrix params (sx,sy,x0,y0) What do they represent? (sx and sy) Screen phone pixel? Because I don't know the screen pixel, what I need is something "relative", example: I need the image at the bottom right, with X pixels in document margin right and X below.
Last edit: 8 years 5 months ago by msanchezv. Reason: Debug and find null values
More
IP: 192.168.0.71 8 years 5 months ago #13053 by Davide
Hi,
I have checked your code with the demo project and it works properly.
Please check if page.AddContent(pageContent, false); returns true. If this returns false the problem is related to the license activation.
For NewImage method try to change the bitmap you are using for tests

In the matrix the 0,0 position is in the bottom-left.
Here you will find the documentation about matrix : www.radaeepdf.com/documentation/javadocs...daee/pdf/Matrix.html

I suggest you to check the PDFTestAct, here you will find some examples about creating page contents.
More
IP: 192.168.0.71 8 years 5 months ago - 8 years 5 months ago #13054 by msanchezv
Hi, I am testing with other image (this time, some png image found on the Internet), but newImage is still returning null.

It it's usefull... I have tried some codes from PDFTestAct like this:
Code:
Document.DocGState dgs = m_doc.NewGState(); etc

But even that line return null... Is anything wrong with the opened doc?

I opened it by this way:
Code:
PDFAssetStream stream = new PDFAssetStream(); stream.open(getAssets(), getIntent().getStringExtra("file")); final Document doc = new Document(); int ret = doc.OpenStream(stream, null); pdf_view.PDFOpen(doc, this);
Last edit: 8 years 5 months ago by msanchezv. Reason: More info
More
IP: 192.168.0.71 8 years 5 months ago #13055 by msanchezv
Even with the fragment of code from PDFTestAct doesn't work:
Code:
PageContent content = new PageContent(); content.GSSave(); Bitmap bmp = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);//must be ARGB_8888 bmp.eraseColor(0xc0000080); Document.DocImage dimg = m_doc.NewImage(bmp, true);

newImage(...) returns null.

Anyone could imagine where's the origin of the problem?
Time to create page: 0.404 seconds
Powered by Kunena Forum