logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
brettr Posted: Sunday, August 14, 2016 8:27:41 AM(UTC)
 
Excellent! Thanks.
Paul Rayman Posted: Friday, August 12, 2016 6:07:28 PM(UTC)
 
Firstly you have not properly configured project.
You forgot to add the pdfium.dll files into it.
Please find detailed instructions how to configure project here: https://pdfium.patagames.com/help/

Secondly, you forgot to set the bitmap to the PdfImageObject. please look at following code

Code:

PdfBitmap bmp = new PdfBitmap(200, 100, true);
bmp.FillRect(0, 0, 200, 100, System.Drawing.Color.Red);
var img = PdfImageObject.Create(e.Page.Document);
//--------------------- you should do this--------------------------------
img.SetBitmap(bmp);
//------------------------------------------------------------------------
img.SetMatrix(1, 0, 0, 1, 0, 0);
img.Transform(bmp.Width, 0, 0, bmp.Height, 0, 0);
e.Page.PageObjects.InsertObject(img);
pdfViewer1.UpdateLayout();
brettr Posted: Friday, August 12, 2016 9:25:03 AM(UTC)
 
wpf_sig.zip (848kb) downloaded 41 time(s).I've created a new WPF app. It has a pdfviewer and button on it plus the discussed code. But I can't get the project to start. When I add PdfCommon.Initialize() to the MainWindow.xaml.cs constructor, the app crashes on startup with this error:

Quote:
XamlParsedException occurred

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

The invocation of the constructor on type 'my_project.MainWindow that matches the specified binding constraints threw an exception. Line number 4 line position 9.


Commenting out PdfCommon.Initialize() removes the error. Getting past that error is the first step then we can look at the remaining code.

Project is attached.
Paul Rayman Posted: Friday, August 12, 2016 3:36:09 AM(UTC)
 
It is difficult to say something without seeing your code. I have checked the example from the link above. Everything works perfectly.
Maybe you did not set up the transformation matrix?
Or did not subscribe to pdfViewer1.DocumentLoaded event?
Could you please create a simple msvc project with this issue and provide it to me?
brettr Posted: Thursday, August 11, 2016 8:44:13 PM(UTC)
 
I added that as the last line but still nothing. I do see e.Page.PageObjects.Count increment after my image is added to the collection.

I also added this line:

e.Page.PageObjects[0].FillColor = Color.Red;

I see one of the text objects change to red.

Any other suggestions?
Paul Rayman Posted: Thursday, August 11, 2016 7:36:18 PM(UTC)
 
Maybe you need to call pdfViewer.ClearRenderBuffer()?
brettr Posted: Thursday, August 11, 2016 4:01:19 PM(UTC)
 
I'm running the same exact code from here https://forum.patagames....t154-Add-string-in-a-pdf , minus the text part. The red image never appears.

Do you have some idea what could be wrong?