Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Windows 8.1, 10, WindowsPhone, Windows UWP
  • Page:
  • 1
  • 2

TOPIC:

NewImageJPEG always returns nullptr 9 years 9 months ago #6693

  • Einstein
  • Einstein's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 19
  • Thank you received: 0
Hi,

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

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))

Please Log in or Create an account to join the conversation.

NewImageJPEG always returns nullptr 9 years 8 months ago #6694

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
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.
The following user(s) said Thank You: tien4720

Please Log in or Create an account to join the conversation.

Last edit: by .

NewImageJPEG always returns nullptr 9 years 8 months ago #6697

  • Einstein
  • Einstein's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 19
  • Thank you received: 0
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?

Please Log in or Create an account to join the conversation.

Last edit: by tien4720.

NewImageJPEG always returns nullptr 9 years 8 months ago #6698

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
yes, WP8 has some extra codes:
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);

Please Log in or Create an account to join the conversation.

Last edit: by .

NewImageJPEG always returns nullptr 9 years 8 months ago #6699

  • Einstein
  • Einstein's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 19
  • Thank you received: 0
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?

Please Log in or Create an account to join the conversation.

NewImageJPEG always returns nullptr 9 years 8 months ago #6700

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
it seems C++/CX can't access WriteableBitmap directly.
only way is: use int array instead.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Powered by Kunena Forum