Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Windows 8.1, 10, WindowsPhone, Windows UWP

NewImageJPEG always returns nullptr

More
IP: 192.168.0.71 11 years 6 months ago #6693 by Einstein
Hi,

using this code I was unable to draw a JPEG using your pdf library:

Code:
pageContent->GSSave(); auto imagePosition = imageShape->Position; auto imageMatrix = ref new RDPDFLib::pdf::PDFMatrix(1, 1, imagePosition.X, imagePosition.Y); pageContent->GSSetMatrix(imageMatrix); auto abc = imageShape->File; auto documentImage = document->NewImageJPEG(abc); auto pageImage = page->AddResImage(documentImage); pageContent->DrawImage(pageImage); pageContent->GSRestore();

document->NewImageJPEG(abc) always returns nullptr on several images. I've triple-checked that imageShape->File is always a valid path to a JPEG file.

P.S. Is there a way to use Document.NewImage(Bitmap, boolean) using the WinRT bindings?
(this one: www.androidpdf.mobi/documentation/javado...cument.html#NewImage (Bitmap, boolean))
More
IP: 192.168.0.71 11 years 6 months ago - 11 years 6 months ago #6694 by radaee
a premium license is needed for this method and SetCache() need to be invoked.
like:
Document doc = new Document();
doc.Open( "pdf path-name" ); //must be writeable.
doc.SetCache( "temp path-name" ); //must be writeable.
Last edit: 11 years 6 months ago by .
More
IP: 192.168.0.71 11 years 6 months ago - 11 years 6 months ago #6697 by Einstein
Thanks very much! I got working. I have another question though. I'd also like to render PDF documents to images. I saw there's a PDFPage::RenderToBmp method that allows this, but it's missing from the Windows Phone library. Is it possible to render PDF documents to images on Windows Phone 8.1?
Last edit: 11 years 6 months ago by tien4720.
More
IP: 192.168.0.71 11 years 6 months ago - 11 years 6 months ago #6698 by radaee
yes, WP8 has some extra codes:
Code:
m_page.RenderPrepare(); int[] pixels = m_dib_tmp.Pixels;//where m_dib_tmp is WriteableBitmap object. PDFPage.ResetBuf(pixels, m_dibw, m_dibh);//m_dibw is width of m_dib_tmp, m_dibh is height of m_dib_tmp. m_dib = m_dib_tmp; m_dib_tmp = null; if (m_status == 2) return; PDFMatrix mat = new PDFMatrix(m_scale, -m_scale, 0, m_dibh); m_page.Render(pixels, m_dibw, m_dibh, mat, true, PDFView.renderQuality);
Last edit: 11 years 6 months ago by .
More
IP: 192.168.0.71 11 years 6 months ago #6699 by Einstein
Hi, I'm using C++/CX on Windows Phone 8.1, could you provide me a sample code that would render a pdf page to a WriteableBitmap?
More
IP: 192.168.0.71 11 years 6 months ago #6700 by radaee
it seems C++/CX can't access WriteableBitmap directly.
only way is: use int array instead.
Time to create page: 0.388 seconds
Powered by Kunena Forum