DrawRect usage

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

DrawRect usage

Post by whoit »

Hi -

Can you point me to an example of using DrawRect within the CoreAPI ?
Or, whatever similar methods are available - I only need to draw a simple rectangle on my pdf.

(I'm actually trying to draw a simple frame around TextBlock, in case there's another way)

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawRect usage

Post by Sasha - Tracker Dev Team »

Hello Wayne,

Here's a sample on this matter:
https://gist.github.com/Polaringu/bee53 ... 7741e8bf79

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: DrawRect usage

Post by whoit »

Hi Alex -

Do you have similar code using CoreAPI instead of Editor?
Most of the code refers to APIs that don't exist in the Core...pen, brush, drawrect, etc....
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawRect usage

Post by Sasha - Tracker Dev Team »

Hello Wayne,

You have referred to the DrawRect method, and the only DrawRect method that I found was the IUIX_RenderContext::DrawRect method. Thus I gave you a sample that I had.
What you need is the IPXC_ContentCreator - it does all of the drawing/output that you require. Here's a small sample, that you can modify to your needs:

Code: Select all

PXC_Rect rc;
IPXC_Document doc = CreateNewDocument(out rc);
PDFXEdit.IPXC_ContentCreator CC = doc.CreateContentCreator();
PDFXEdit.PXC_Rect rcText;
rcText.left = 100;
rcText.bottom = 600;
rcText.top = 700;
rcText.right = 300;

PDFXEdit.PXC_Rect rcBlock;
PDFXEdit.IPXC_CharFormat cf = pxcInst.CreateCharFormat();
CC.ShowTextBlock("Test Text Block Text", rcText, rcText, 0, -1, null, null, null, out rcBlock);  //draw text block
CC.SetLineWidth(2);
CC.Rect(rcBlock.left, rcBlock.bottom, rcBlock.right, rcBlock.top);
CC.StrokePath(true);
doc.Pages[0].PlaceContent(CC.Detach(), (UInt32)PDFXEdit.PXC_PlaceContentFlags.PlaceContent_After);

pdfCtl.OpenDocFrom(doc);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: DrawRect usage

Post by whoit »

Yeah, I assumed that there was a comparable API in Core but wasn't sure of the name....thanks.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: DrawRect usage

Post by Tracker Supp-Stefan »

You are welcome whoit,

Regards,
Stefan
Post Reply